Errors in log and status when mysql is installed.
Error when mysql root password is changed.
Error when datadog is purged.
Now we use systemctl instead of service.
This commit is contained in:
Cristhian Martínez Ochoa 2021-12-21 17:10:10 -07:00
parent 1becfe2a60
commit 7fbbdb48a5
9 changed files with 32 additions and 47 deletions

View file

@ -547,7 +547,7 @@ check_exported_conf() {
if [[ $(conf_read mysql) == "true" ]]; then
if tar -tvf $file --absolute-names | grep -oq "/etc/mysql/mariadb.conf.d/90-webinoly.cnf"; then
tar -C / -xf $file /etc/mysql/mariadb.conf.d/90-webinoly.cnf --absolute-names
sudo service mysql restart
sudo systemctl restart mysql
fi
fi
}

View file

@ -410,7 +410,7 @@ instances:
dd_purge() {
if [[ -d /etc/datadog-agent ]]; then
sudo apt-get remove --purge datadog-agent -y
sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$(conf_read tools-port)
[[ -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$(conf_read tools-port)
echo "${gre}Datadog Agent has been removed successfully from your server!${end}"
else
echo "${red}[ERROR] Datadog Agent is not installed on your server!${end}"
@ -443,7 +443,7 @@ dd_install() {
[[ $(conf_read php-tool-redis) == "true" ]] && dd_redis
fi
sudo service datadog-agent start
sudo systemctl start datadog-agent
echo "${gre}Datadog Agent has been successfully installed in your server!${end}"
fi
fi

View file

@ -116,9 +116,7 @@ WantedBy=multi-user.target" >> /etc/systemd/system/webinoly-disable-thp.service
set_timezone
sudo systemctl daemon-reload
[[ -s /run/nginx.pid && -n $(cat /run/nginx.pid) ]] && sudo kill $(cat /run/nginx.pid) && sudo service nginx start
# For an unknown reason "sudo systemctl start nginx" fails to start nginx here!
sudo systemctl restart nginx # We need to kill the process, don't use reload
conf_write linux-optim true
api-events_update in9
}
@ -146,10 +144,7 @@ linux_purge() {
[[ $recalculate == "on" ]] && swap_delete
sudo systemctl daemon-reload
# Never reload nginx here - high chances of getting errors due to still-none-updated conf files in the server-reset process
#[[ -s /run/nginx.pid && -n $(cat /run/nginx.pid) ]] && sudo kill $(cat /run/nginx.pid) && sudo service nginx start
# Never reload/restart nginx here!
conf_write linux-optim purged
api-events_update pn8
fi
@ -242,7 +237,6 @@ mysql_install() {
#Instead of mysql_secure_installation we do this: (same but manually, because not acept unattended)
sudo mysql --user=root -p$AUTOGENPASS_ROOT <<_EOF_
ALTER USER 'root'@'localhost' IDENTIFIED BY '${AUTOGENPASS_ROOT}';
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DROP DATABASE IF EXISTS test;
@ -729,13 +723,14 @@ stack_builder() {
[[ $4 == "postfix" || $4 == "redis" || $4 == "memcached" || $4 == "pma" ]] && check_for_php -ask
[[ $4 == "pma" ]] && check_for_mysql -ask
# Set Welcome Message
[[ -n $4 ]] && local mess=$4 # We trust in build variable validation
[[ -n $lemp && -z $4 ]] && local mess="full"
# Check for missing essential packages
if [[ $(conf_read pre-packs) != true ]]; then
# Set Welcome Message
[[ -n $4 ]] && local mess=$4 # We trust in build variable validation
[[ -n $lemp && -z $4 ]] && local mess="full"
message_welcome $mess
# Any action run after the meesage is displayed!
api-events_update i1
sudo apt -qq update

View file

@ -144,7 +144,7 @@ onefive_to_onesix() {
# Just to be sure in case of added with new nginx package
[[ -f /etc/nginx/conf.d/default.conf ]] && sudo rm /etc/nginx/conf.d/default.conf
sudo nginx -t && sudo service nginx start
sudo nginx -t && sudo systemctl start nginx
sudo systemctl enable nginx
[[ $(conf_read php) == "true" ]] && sudo apt -y install ghostscript

View file

@ -202,7 +202,7 @@ smtp_setup() {
sudo chmod 0600 /etc/postfix/sasl_passwd.db
conf_write smtp true
sudo service postfix restart
sudo systemctl restart postfix
echo "${gre}SMTP was successfully enabled!${end}"
}
@ -229,18 +229,8 @@ mysql_change_password() {
exit 1
fi
sudo mysql --connect-timeout=10 --user=root -p$( echo $(conf_read mysql-root) | openssl enc -d -a -salt ) -e "ALTER USER '${user}'@'localhost' IDENTIFIED BY '${pass}';FLUSH PRIVILEGES;"
[[ $? != 0 ]] && catcherror=true
if [[ $user == "root" && -z $catcherror ]]; then
sudo mysql --connect-timeout=10 --user=root -p$pass -e "ALTER USER '${user}'@'127.0.0.1' IDENTIFIED BY '${pass}';FLUSH PRIVILEGES;"
[[ $? != 0 ]] && catcherror=true
sudo mysql --connect-timeout=10 --user=root -p$pass -e "ALTER USER '${user}'@'::1' IDENTIFIED BY '${pass}';FLUSH PRIVILEGES;"
[[ $? != 0 ]] && catcherror=true
fi
if [[ -z $catcherror ]]; then
sudo mysql --connect-timeout=10 --user=admin -p$ADMIN_PASS -e "ALTER USER '${user}'@'localhost' IDENTIFIED BY '${pass}';FLUSH PRIVILEGES;"
if [[ $? == 0 ]]; then
conf_write mysql-${user} $( echo $pass | openssl enc -a -salt )
echo "${gre}MySQL Password successfully changed!${end}"
else
@ -594,7 +584,7 @@ Match Group sftponly
[[ -n $falus ]] && sudo sed -i "s/$falus/$falus www-data/" /etc/ssh/sshd_config
conf_write login-www-data true
sudo service ssh restart
sudo systemctl restart ssh
echo "${gre}SFTP access for www-data user has been successfuly enabled! ${end}"
elif [[ $login_www_data == "off" ]]; then
@ -614,7 +604,7 @@ Match Group sftponly
fi
conf_write login-www-data purged
sudo service ssh restart
sudo systemctl restart ssh
echo "${gre}SFTP access for www-data user has been successfuly disabled! ${end}"
else
echo "${red}[ERROR] Invalid value for login-www-data! ${end}"

View file

@ -363,5 +363,5 @@ else
exit 1
fi
[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo service nginx reload
[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo systemctl reload nginx
api-events_update hae

20
usr/log
View file

@ -124,11 +124,11 @@ elif [[ -n $mysql ]]; then
if [[ -n $enable ]]; then
cnf_write general_log 1
cnf_write general_log_file /var/log/mysql/mysql.log
sudo service mysql restart
sudo systemctl restart mysql
echo "${gre}MariaDB General log was successfully enabled!${end}"
elif [[ -n $disable ]]; then
cnf_write general_log 0
sudo service mysql restart
sudo systemctl restart mysql
echo "${gre}MariaDB General log was successfully disabled!${end}"
elif [[ -f /var/log/mysql/mysql.log && $(cnf_read general_log) == 1 ]]; then
[[ ! -s /var/log/mysql/mysql.log ]] && waiting_for_log
@ -145,11 +145,11 @@ elif [[ -n $mysql ]]; then
elif [[ $mysql == "slow" ]]; then
if [[ -n $enable ]]; then
cnf_write slow_query_log 1
sudo service mysql restart
sudo systemctl restart mysql
echo "${gre}MariaDB Slow Query log was successfully enabled!${end}"
elif [[ -n $disable ]]; then
cnf_write slow_query_log 0
sudo service mysql restart
sudo systemctl restart mysql
echo "${gre}MariaDB Slow Query log was successfully disabled!${end}"
elif [[ -f /var/log/mysql/mariadb-slow.log && $(cnf_read slow_query_log) == 1 ]]; then
[[ ! -s /var/log/mysql/mariadb-slow.log ]] && waiting_for_log
@ -168,13 +168,13 @@ elif [[ -n $mysql ]]; then
cnf_delete skip-log-bin
cnf_write log_bin /var/log/mysql/mariadb-bin
cnf_write log_bin_index /var/log/mysql/mariadb-bin.index
sudo service mysql restart
sudo systemctl restart mysql
echo "${gre}MariaDB Binary log was successfully enabled!${end}"
elif [[ -n $disable ]]; then
cnf_delete log_bin
cnf_delete log_bin_index
cnf_write skip-log-bin
sudo service mysql restart
sudo systemctl restart mysql
echo "${gre}MariaDB Binary log was successfully disabled!${end}"
elif [[ -f /var/log/mysql/mariadb-bin && -n $(cnf_read log_bin) ]]; then
[[ ! -s /var/log/mysql/mariadb-bin ]] && waiting_for_log
@ -229,7 +229,7 @@ elif [[ -n $only_error ]]; then
if [[ -z $islog ]]; then
[[ $(conf_read nginx) == "true" ]] && sudo sed -i '/access_log/c \ access_log off;' /etc/nginx/nginx.conf
conf_write global-access-log-off true
sudo service nginx reload
sudo systemctl reload nginx
echo "${gre}Only-Error Log was successfully enabled (global)!${end}"
else
echo "${gre}Only-Error Log is already enabled (global)!${end}"
@ -239,7 +239,7 @@ elif [[ -n $only_error ]]; then
if [[ -n $islog || ( -z $islog && $(conf_read nginx) != "true" ) ]]; then
[[ $(conf_read nginx) == "true" ]] && sudo sed -i "/access_log/c \ access_log \/var\/log\/nginx\/access.log;" /etc/nginx/nginx.conf
conf_write global-access-log-off purged
sudo service nginx reload
sudo systemctl reload nginx
echo "${gre}Only-Error Log was successfully disabled (global)!${end}"
else
echo "${gre}Only-Error Log is already disabled (global)!${end}"
@ -259,7 +259,7 @@ elif [[ -n $only_error ]]; then
api-events_update lg3
if [[ $(is_log $domain) == "true" ]]; then
sudo sed -i '/access_log/c \ access_log off;' /etc/nginx/sites-available/$domain
sudo service nginx reload
sudo systemctl reload nginx
echo "${gre}Only-Error Log was successfully enabled for ${blu}${domain} ${gre}site!${end}"
else
echo "${gre}Access Log is already enabled for ${blu}${domain} ${gre}site!${end}"
@ -268,7 +268,7 @@ elif [[ -n $only_error ]]; then
api-events_update lg4
if [[ $(is_log $domain) != "true" ]]; then
sudo sed -i "/access_log/c \ access_log \/var\/log\/nginx\/${domain}.access.log we_log;" /etc/nginx/sites-available/$domain
sudo service nginx reload
sudo systemctl reload nginx
echo "${gre}Only-Error Log was successfully disabled for ${blu}${domain} ${gre}site!${end}"
else
echo "${gre}Access Log is already disabled for ${blu}${domain} ${gre}site!${end}"

View file

@ -441,5 +441,5 @@ else
fi
shopt -u extglob
[[ $(conf_read nginx) == "true" && -z $nginx_not && $(conf_read nginx-reload) != "false" ]] && sudo service nginx reload
[[ $(conf_read nginx) == "true" && -z $nginx_not && $(conf_read nginx-reload) != "false" ]] && sudo systemctl reload nginx
api-events_update sie

View file

@ -157,7 +157,7 @@ elif [[ -n $smtp && -n $purge ]]; then
rm -rf /etc/postfix/sasl_passwd
rm -rf /etc/mailname
conf_write smtp purged
sudo service postfix restart
sudo systemctl restart postfix
echo "${gre}SMTP configuration has been successfully removed!${end}"
elif [[ -n $smtp ]]; then
check_for_php_tool_postfix -ask
@ -212,7 +212,7 @@ elif [[ -n $datadog ]]; then
if [[ -n $integrations ]]; then
dd_logs_disable
sudo service datadog-agent restart
sudo systemctl restart datadog-agent
fi
elif [[ -n $integrations && $integrations != "off" ]]; then
@ -238,7 +238,7 @@ elif [[ -n $datadog ]]; then
exit 1
fi
sudo service datadog-agent restart
sudo systemctl restart datadog-agent
else
dd_install
fi
@ -306,5 +306,5 @@ else
fi
[[ -n $err_cont ]] && exit 1
[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo service nginx reload
[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo systemctl reload nginx
api-events_update wye