Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
A lot small fixes after testing.
  • Loading branch information
QROkes committed Jan 11, 2022
1 parent 6b4df56 commit c057036
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Webinoly provides a set of tools and commands that facilitate web server adminis
- Unique commands to create, delete, disable sites.
- Free SSL certificates for your sites with Let’s Encrypt and automatic server configuration.
- HTTP/2 dramatically increases the speed of serving your content.
- PHP v8.0 and support for earlier versions if needed (7.4 or 7.3) and the newest v8.1.
- PHP v8.0 and support for earlier versions if needed (7.4) and the newest v8.1.
- FastCGI Cache and Redis Object Cache for your WordPress sites.
- Install WP in any subfolder and support for external databases, multisite and domain mapping.
- Reverse Proxy for any app (Java, React, Node, Angular, Vue, etc) or to use your own domain with any external file repo like S3.
Expand Down
58 changes: 37 additions & 21 deletions lib/bkp
Original file line number Diff line number Diff line change
Expand Up @@ -440,32 +440,38 @@ END


conf_read_exported() {
local val=$(grep -w "^${1}:.*" /opt/webinoly/webinoly.conf.exported | cut -f 2 -d ':')
echo $val
echo $(grep -w "^${1}:.*" /opt/webinoly/webinoly.conf.exported | cut -f 2- -d ':')
}


check_exported_conf() {

# Check for stack variables
[[ -n $(conf_read_exported tools-port) ]] && conf_write tools-port $(conf_read_exported tools-port)
[[ -n $(conf_read_exported fastcgi-conf) ]] && conf_write fastcgi-conf $(conf_read_exported fastcgi-conf)
[[ -n $(conf_read_exported fd-ratio) ]] && conf_write fd-ratio $(conf_read_exported fd-ratio)
[[ -n $(conf_read_exported nginx-fd-ratio) ]] && conf_write nginx-fd-ratio $(conf_read_exported nginx-fd-ratio)
[[ -n $(conf_read_exported swap-mem) ]] && conf_write swap-mem $(conf_read_exported swap-mem)
[[ -n $(conf_read_exported nginx-ppa) ]] && conf_write nginx-ppa $(conf_read_exported nginx-ppa)
[[ -n $(conf_read_exported cache-size) ]] && conf_write nginx-ppa $(conf_read_exported cache-size)
[[ -n $(conf_read_exported run-folder-size) ]] && conf_write run-folder-size $(conf_read_exported run-folder-size)
[[ -n $(conf_read_exported timezone) ]] && conf_write timezone $(conf_read_exported timezone)
[[ -n $(conf_read_exported kernel-optim) ]] && conf_write kernel-optim $(conf_read_exported kernel-optim)

[[ -n $(conf_read_exported php-ver) ]] && conf_write php-ver $(conf_read_exported php-ver)
[[ -n $(conf_read_exported php-info) ]] && conf_write php-info $(conf_read_exported php-info)
[[ -n $(conf_read_exported nginx-ppa) ]] && conf_write nginx-ppa $(conf_read_exported nginx-ppa)
[[ -n $(conf_read_exported tools-port) ]] && conf_write tools-port $(conf_read_exported tools-port)
[[ -n $(conf_read_exported fastcgi-conf) ]] && conf_write fastcgi-conf $(conf_read_exported fastcgi-conf)
[[ -n $(conf_read_exported xmlrpc) ]] && conf_write xmlrpc $(conf_read_exported xmlrpc)
[[ -n $(conf_read_exported max-mb-uploads) ]] && conf_write max-mb-uploads $(conf_read_exported max-mb-uploads)
[[ -n $(conf_read_exported redis-max-mem) ]] && conf_write redis-max-mem $(conf_read_exported redis-max-mem)

[[ -n $(conf_read_exported php-ver) ]] && conf_write php-ver $(conf_read_exported php-ver)
[[ -n $(conf_read_exported php-max-mem) ]] && conf_write php-max-mem $(conf_read_exported php-max-mem)
[[ -n $(conf_read_exported php-pm) ]] && conf_write php-pm $(conf_read_exported php-pm)
[[ -n $(conf_read_exported php-max-child) ]] && conf_write php-max-child $(conf_read_exported php-max-child)
[[ -n $(conf_read_exported php-max-time) ]] && conf_write php-max-time $(conf_read_exported php-max-time)
[[ -n $(conf_read_exported php-max-files) ]] && conf_write php-max-files $(conf_read_exported php-max-files)
[[ -n $(conf_read_exported redis-max-mem) ]] && conf_write redis-max-mem $(conf_read_exported redis-max-mem)

[[ -n $(conf_read_exported mysql-ver) ]] && conf_write mysql-ver $(conf_read_exported mysql-ver)
[[ -n $(conf_read_exported mysql-log-general) ]] && conf_write mysql-log-general $(conf_read_exported mysql-log-general)
[[ -n $(conf_read_exported mysql-log-binary) ]] && conf_write mysql-log-binary $(conf_read_exported mysql-log-binary)
[[ -n $(conf_read_exported mysql-log-slow) ]] && conf_write mysql-log-slow $(conf_read_exported mysql-log-slow)
[[ -n $(conf_read_exported mysql-long-query-time) ]] && conf_write mysql-long-query-time $(conf_read_exported mysql-long-query-time)
[[ -n $(conf_read_exported mysql-public-access) ]] && conf_write mysql-public-access $(conf_read_exported mysql-public-access)

# Built stack based on exported conf
if [[ $(conf_read_exported nginx) == "true" ]]; then
Expand All @@ -487,23 +493,32 @@ check_exported_conf() {


# Load custom conf
[[ -n $(conf_read_exported login-www-data) ]] && sudo webinoly -login-www-data=on
[[ $(conf_read_exported global-access-log-off) =~ ^(false|purged)$ ]] && sudo log -only-error=off || sudo log -only-error=on
[[ -n $(conf_read_exported login-www-data) ]] && sudo webinoly -login-www-data=on # Same as sftp-www-data
[[ -n $(conf_read_exported mail) ]] && sudo webinoly -email=$(conf_read_exported mail)
[[ -n $(conf_read_exported header-hsts) ]] && sudo webinoly -header-hsts=$(conf_read_exported header-hsts)
[[ -n $(conf_read_exported header-referrer) ]] && sudo webinoly -header-referrer=$(conf_read_exported header-referrer)
[[ $(conf_read_exported header-xssp) == "false" ]] && sudo webinoly -header-xssp=off
[[ $(conf_read_exported header-xcto) == "false" ]] && sudo webinoly -header-xcto=off
[[ $(conf_read_exported header-xfo) =~ ^(off|deny|sameorigin)$ ]] && sudo webinoly -header-xfo=$(conf_read_exported header-xfo)
[[ $(conf_read_exported header-xfo) == "allow-from" && -n $(conf_read_exported header-xfo-url) ]] && sudo webinoly -header-xfo=allow-from -url=$(conf_read_exported header-xfo-url)
[[ -n $(conf_read_exported auth-whitelist-ip) ]] && sudo httpauth -whitelist=$(conf_read_exported auth-whitelist-ip)
#[[ -n $(conf_read_exported blockip) ]] && sudo webinoly -blockip=$(conf_read blockip) # File is exported below and should have more precedence!
[[ -n $(conf_read_exported log-lines) ]] && conf_write log-lines $(conf_read_exported log-lines)
[[ -n $(conf_read_exported awsiamrole) ]] && conf_write awsiamrole $(conf_read_exported awsiamrole)
[[ -n $(conf_read_exported wp-admin-auth) ]] && conf_write wp-admin-auth $(conf_read_exported wp-admin-auth)
[[ -n $(conf_read_exported global-access-log-off) ]] && conf_write global-access-log-off $(conf_read_exported global-access-log-off)
[[ -n $(conf_read_exported php-info) ]] && conf_write php-info $(conf_read_exported php-info)

[[ -n $(conf_read_exported dbrole) ]] && conf_write dbrole $(conf_read_exported dbrole)
[[ -n $(conf_read_exported external-dbh) ]] && conf_write external-dbh $(conf_read_exported external-dbh)
[[ -n $(conf_read_exported external-dbx) ]] && conf_write external-dbx $(conf_read_exported external-dbx)
[[ -n $(conf_read_exported external-dbu) ]] && conf_write external-dbu $(conf_read_exported external-dbu)
[[ -n $(conf_read_exported external-dbp) ]] && conf_write external-dbp $(conf_read_exported external-dbp)

[[ $(conf_read_exported header-xssp) == "false" ]] && sudo webinoly -header-xssp=off
[[ $(conf_read_exported header-xcto) == "false" ]] && sudo webinoly -header-xcto=off
[[ $(conf_read_exported header-xfo) =~ ^(off|deny|sameorigin)$ ]] && sudo webinoly -header-xfo=$(conf_read_exported header-xfo)
[[ $(conf_read_exported header-xfo) == "allow-from" && -n $(conf_read_exported header-xfo-url) ]] && sudo webinoly -header-xfo=allow-from -url=$(conf_read_exported header-xfo-url)
[[ -n $(conf_read_exported header-referrer) ]] && sudo webinoly -header-referrer=$(conf_read_exported header-referrer)
[[ -n $(conf_read_exported header-hsts) ]] && sudo webinoly -header-hsts=$(conf_read_exported header-hsts)
[[ -n $(conf_read_exported header-cache-control) ]] && conf_write header-cache-control "$(conf_read_exported header-cache-control)" && sudo webinoly -header-cache-control=on
[[ -n $(conf_read_exported header-csp) ]] && conf_write header-csp "$(conf_read_exported header-csp)" && sudo webinoly -header-csp=on
[[ -n $(conf_read_exported header-permissions) ]] && conf_write header-permissions "$(conf_read_exported header-permissions)" && sudo webinoly -header-permissions-policy=on
[[ -n $(conf_read_exported header-robots) ]] && conf_write header-robots "$(conf_read_exported header-robots)" && sudo webinoly -header-robots=on

if [[ $is_tar == "true" ]]; then
if tar -tvf $file --absolute-names | grep -oq "/opt/webinoly/templates/source/csp_webinoly.data"; then
Expand Down Expand Up @@ -921,8 +936,9 @@ import_server() {
fi
fi

if [[ $import =~ ^(stack|full)$ ]]; then
if [[ $import =~ ^(true|stack|full)$ ]]; then
[[ $is_tar == "true" ]] && tar -C / -xf $file /opt/webinoly/webinoly.conf.exported --absolute-names || sudo cp $file /opt/webinoly/webinoly.conf.exported
[[ $is_tar == "true" && $import == "true" ]] && import="full"

check_exported_conf
echo "${gre}Webinoly Stack Server was built using your imported configuration!${end}"
Expand Down Expand Up @@ -963,7 +979,7 @@ import_server() {
sudo webinoly -default-site=$(conf_read_exported default-site)
fi

[[ -f /etc/nginx/sites-available/$(conf_read_exported tools-site) ]] && sudo webinoly -tools-site=$(conf_read_exported default-site)
[[ -f /etc/nginx/sites-available/$(conf_read_exported tools-site) ]] && sudo webinoly -tools-site=$(conf_read_exported tools-site)
fi

sudo mv /opt/webinoly/webinoly.conf.exported /opt/webinoly/webinoly.conf.imported_$(date +%F)-$(date +%T)
Expand Down
8 changes: 4 additions & 4 deletions lib/headers
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ http_header_csp() {
read -p "${blu}CSP header value: ${end}" csp_data

if [[ -n $csp_data ]]; then
conf_write header-csp $csp_data
conf_write header-csp "$csp_data"
echo "${blu}${dim}CSP Header... saving data!${end}"
fi
elif [[ $header_csp =~ ^(true|on)$ && -n $(conf_read header-csp) ]]; then
Expand Down Expand Up @@ -92,7 +92,7 @@ http_header_permissions_policy() {
[[ $header_permissions_policy != "floc" ]] && read -p "${blu}Permissions Policy header value: ${end}" pph_data

if [[ -n $pph_data ]]; then
conf_write header-permissions $pph_data
conf_write header-permissions "$pph_data"
echo "${blu}${dim}Permissions Policy Header... saving data!${end}"
fi
elif [[ $header_permissions_policy =~ ^(true|on|floc)$ && -n $(conf_read header-permissions) ]]; then
Expand Down Expand Up @@ -136,7 +136,7 @@ http_header_cache_control() {
read -p "${blu}Cache Control header value: ${end}" cch_data

if [[ -n $cch_data ]]; then
conf_write header-cache-control $cch_data
conf_write header-cache-control "$cch_data"
echo "${blu}${dim}Cache Control Header... saving data!${end}"
fi
elif [[ $header_cache_control =~ ^(true|on)$ && -n $(conf_read header-cache-control) ]]; then
Expand Down Expand Up @@ -179,7 +179,7 @@ http_header_robots() {
read -p "${blu}X-Robots-Tag header value: ${end}" rob_data

if [[ -n $rob_data ]]; then
conf_write header-robots $rob_data
conf_write header-robots "$rob_data"
echo "${blu}${dim}X-Robots-Tag Header... saving data!${end}"
fi
elif [[ $header_robots =~ ^(true|on)$ && -n $(conf_read header-robots) ]]; then
Expand Down
7 changes: 1 addition & 6 deletions lib/install
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,5 @@ stack_builder() {
[[ $mysql_pass_display == "true" && -z $block_password_display ]] && messagend_install
fi

if [[ $code != 0 || -n $(conf_read stack_build_error_flag) ]]; then
sudo webinoly -verify=critical
[[ $? != 0 ]] && conf_write stack_build_error_flag true || return 0 # Functions should never end with negative open!
else
return 0
fi
[[ $code != 0 || -n $(conf_read stack-build-error-flag) ]] && sudo webinoly -verify=critical || return 0 # Never end a function with negative open!
}
21 changes: 12 additions & 9 deletions lib/update
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,19 @@ onesix_to_oneseven() {


if [[ -s /opt/webinoly/templates/source/csp_webinoly.data ]]; then
echo "header-csp:$(sed -n '1p' /opt/webinoly/templates/source/csp_webinoly.data)" >> /opt/webinoly/webinoly.conf
conf_write header-csp "$(sed -n '1p' /opt/webinoly/templates/source/csp_webinoly.data)"
sudo mv /opt/webinoly/templates/source/csp_webinoly.data /opt/webinoly/templates/source/csp_webinoly.data.old
fi
if [[ -s /opt/webinoly/templates/source/pph_webinoly.data ]]; then
echo "header-permissions:$(sed -n '1p' /opt/webinoly/templates/source/pph_webinoly.data)" >> /opt/webinoly/webinoly.conf
conf_write header-permissions "$(sed -n '1p' /opt/webinoly/templates/source/pph_webinoly.data)"
sudo mv /opt/webinoly/templates/source/pph_webinoly.data /opt/webinoly/templates/source/pph_webinoly.data.old
fi
if [[ -s /opt/webinoly/templates/source/cch_webinoly.data ]]; then
echo "header-cache-control:$(sed -n '1p' /opt/webinoly/templates/source/cch_webinoly.data)" >> /opt/webinoly/webinoly.conf
conf_write header-cache-control "$(sed -n '1p' /opt/webinoly/templates/source/cch_webinoly.data)"
sudo mv /opt/webinoly/templates/source/cch_webinoly.data /opt/webinoly/templates/source/cch_webinoly.data.old
fi
if [[ -s /opt/webinoly/templates/source/rob_webinoly.data ]]; then
echo "header-robots:$(sed -n '1p' /opt/webinoly/templates/source/rob_webinoly.data)" >> /opt/webinoly/webinoly.conf
conf_write header-robots "$(sed -n '1p' /opt/webinoly/templates/source/rob_webinoly.data)"
sudo mv /opt/webinoly/templates/source/rob_webinoly.data /opt/webinoly/templates/source/rob_webinoly.data.old
fi

Expand Down Expand Up @@ -247,19 +247,22 @@ onesix_to_oneseven() {
if [[ $(conf_read nginx-tool-bkp) == "true" ]]; then
sudo apt -y purge duplicity duply python-boto
conf_write nginx-tool-bkp purged
stack -backups

# Not break the old profiles
[[ $(check_osname) == "bionic" ]] && sudo apt -y install python3-boto
[[ $(check_osname) == "bionic" ]] && sudo apt -y install python3-boto # Not break the old profiles
local reinstall_bkp="true"
fi
if [[ $(conf_read php-tool-redis) == "true" ]]; then
sudo apt -y purge redis-server
echo | sudo add-apt-repository --remove 'ppa:chris-lea/redis-server'
sudo apt-key del C7917B12
conf_write php-tool-redis purged
stack -redis
local reinstall_redis="true"
fi

# All of these is here separated to prevent errors when verify runs inside the stack command
sudo webinoly -server-reset=nginx
[[ -n $reinstall_bkp ]] && stack -backups
[[ -n $reinstall_redis ]] && stack -redis

sudo apt -yqq autoremove
}

Expand Down
11 changes: 6 additions & 5 deletions lib/verify
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ if [[ -z $critical_mode ]]; then
echo "${dim}- [WARNING] Default site not found or is not enabled!${end}${red}"
ver_two_war="1"
fi
if [[ -n $(conf_read tools-site) && ! -L /etc/nginx/sites-enabled/$(conf_read tools-site) ]]; then
if [[ -n $(conf_read tools-site) && $(conf_read tools-site) != "default" && ! -L /etc/nginx/sites-enabled/$(conf_read tools-site) ]]; then
echo "${dim}- [WARNING] Tools site not found or is not enabled!${end}${red}"
ver_two_war="1"
fi
Expand Down Expand Up @@ -438,7 +438,7 @@ if [[ $(conf_read php) == "true" ]]; then
echo "- [ERROR] PHP Apt Key not found!"
ver_two_err="1"
fi
if [[ ! -s /etc/apt/sources.list.d/ondrej-ubuntu-php-focal.list ]]; then
if [[ ! -s /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list ]]; then
echo "- [ERROR] PHP PPA not found in sources list!"
ver_two_err="1"
fi
Expand Down Expand Up @@ -742,7 +742,7 @@ if [[ $(conf_read php-tool-redis) == "true" ]]; then
echo "- [ERROR] Redis Apt Key not found!"
ver_two_err="1"
fi
if [[ ! -s /etc/apt/sources.list.d/redislabs-ubuntu-redis-focal.list ]]; then
if [[ ! -s /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list ]]; then
echo "- [ERROR] Redis PPA not found in sources list!"
ver_two_err="1"
fi
Expand Down Expand Up @@ -936,17 +936,18 @@ if [[ $ver_one_err != 0 || $ver_two_err != 0 || $ver_three_err != 0 || $ver_four
echo "******** ${bol}> > > E R R O R < < <${end}${red} ***********"
echo "******** ${bol}System could not work properly${end}${red} ***********"
echo "******************************************************* ${end}"
conf_write stack-build-error-flag true
return 1
elif [[ $ver_one_war != 0 || $ver_two_war != 0 || $ver_three_war != 0 || $ver_four_war != 0 || $ver_five_war != 0 || $ver_six_war != 0 || $ver_seven_war != 0 || $ver_eight_war != 0 || $ver_nine_war != 0 ]]; then
if [[ -z $critical_mode ]]; then
echo "${red}***************************************************************************************************"
echo "******** ${bol}[ W A R N I N G ] There are some messages that should be attended!${end}${red} ***********"
echo "*************************************************************************************************** ${end}"
fi
conf_delete stack_build_error_flag
conf_delete stack-build-error-flag
return 0
else
conf_delete stack_build_error_flag
conf_delete stack-build-error-flag
[[ -z $critical_mode ]] && echo "${bol}${gre}Integrity test successfully passed!!! ${end}"
return 0
fi
Expand Down
6 changes: 1 addition & 5 deletions usr/stack
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,6 @@ if [[ $force == 1 ]]; then
fi

# Remove all unnecessary packages!
# Bash maintains an internal hash of previously found executables in your path. (clear all hashed locations)
if [[ $purge_autoremove == "true" ]]; then
sudo apt -yqq autoremove &> /dev/null
hash -r
fi
[[ $purge_autoremove == "true" ]] && sudo apt -yqq autoremove &> /dev/null

api-events_update ste
7 changes: 4 additions & 3 deletions usr/webinoly
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ elif [[ -n $server_reset ]]; then


elif [[ -n $verify ]]; then
webinoly_verify || exit 1
webinoly_verify
[[ $? != 0 ]] && exit 1
nginx_not="true" # Nginx-Reload not-needed.


Expand Down Expand Up @@ -168,7 +169,7 @@ elif [[ -n $smtp ]]; then


elif [[ -n $backup ]]; then
[[ $import =~ ^(stack|full)$ ]] || check_for_nginx_tool_bkp -ask
[[ $import =~ ^(true|stack|full)$ ]] || check_for_nginx_tool_bkp -ask

if [[ -n $list && -z $add_db_pre ]]; then
bkp_s3_list
Expand Down Expand Up @@ -314,5 +315,5 @@ fi


[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo systemctl reload nginx
api-events_update wye
[[ -n $err_cont ]] && exit 1
api-events_update wye
6 changes: 4 additions & 2 deletions weby
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ fi
[[ $setup == 1 ]] && stack -nginx
[[ $setup == 2 ]] && stack -php=nginx
[[ $setup == 3 ]] && stack -lemp
[[ $setup != [123] && -n $(conf_read stack_build_error_flag) ]] && sudo webinoly -verify=critical
[[ $setup != [123] && -n $(conf_read stack-build-error-flag) ]] && sudo webinoly -verify=critical

# Message Center
if [[ -z $(conf_read stack_build_error_flag) ]]; then
if [[ -z $(conf_read stack-build-error-flag) ]]; then
if [[ $new_install == "true" && $setup == 0 ]]; then
echo "${blu}You have chosen the option '0', it means that you have to manually build your own stack."
echo "But, don't worry! With Webinoly this is an easy task, just use the stack command, i.e. 'sudo stack -lemp' ${end}"
Expand Down Expand Up @@ -217,6 +217,8 @@ if [[ -z $(conf_read stack_build_error_flag) ]]; then
echo "*** ${end}${dim}Your regular donations is what keep this project moving forward.${end}${blu} ***"
echo "****************************************************************************"
echo "${end}"
else
echo "${red}[ERROR] Sorry, unexpected error during installation and building stack process!${end}"
fi


Expand Down

0 comments on commit c057036

Please sign in to comment.