From 70a46203baa51e7b3cf58c738895181d5c3641b5 Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Tue, 8 Aug 2023 10:32:28 -0300 Subject: [PATCH] Replace service command with systemctl Service command isn't available on current Debian Stable onwards. --- 2-install-guacamole.sh | 16 ++++++++-------- 4b-install-ssl-letsencrypt-nginx.sh | 2 +- add-smtp-relay-o365.sh | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/2-install-guacamole.sh b/2-install-guacamole.sh index a737514..44b3e7d 100644 --- a/2-install-guacamole.sh +++ b/2-install-guacamole.sh @@ -78,7 +78,7 @@ if [ $? -ne 0 ]; then else echo -e "${LGREEN}OK${GREY}" fi -service postfix restart +sudo systemctl restart postfix # Download Guacamole Server echo @@ -330,7 +330,7 @@ fi # Restart Tomcat echo -e "${GREY}Restarting Tomcat service & enable at boot..." -service ${TOMCAT_VERSION} restart +sudo systemctl restart ${TOMCAT_VERSION} if [ $? -ne 0 ]; then echo -e "${LRED}Failed${GREY}" 1>&2 exit 1 @@ -348,8 +348,8 @@ export MYSQL_PWD=${MYSQL_ROOT_PWD} if [ "${INSTALL_MYSQL}" = true ]; then echo -e "${GREY}Restarting MySQL service & enable at boot..." # Set MySQl to start at boot - systemctl enable mysql - service mysql restart + sudo systemctl enable mysql + sudo systemctl restart mysql if [ $? -ne 0 ]; then echo -e "${LRED}Failed${GREY}" 1>&2 exit 1 @@ -390,7 +390,7 @@ else mysql_tzinfo_to_sql /usr/share/zoneinfo 2>/dev/null | mysql -u root -D mysql -h ${MYSQL_HOST} -P ${MYSQL_PORT} crudini --set ${mysqlconfig} mysqld default_time_zone "${timezone}" # Restart to apply - service mysql restart + sudo systemctl restart mysql fi fi if [ $? -ne 0 ]; then @@ -480,9 +480,9 @@ fi # Ensure guacd is started echo -e "${GREY}Starting guacd service & enable at boot..." -systemctl enable guacd -service guacd stop 2>/dev/null -service guacd start +sudo systemctl enable guacd +sudo systemctl stop guacd 2>/dev/null +sudo systemctl start guacd if [ $? -ne 0 ]; then echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2 exit 1 diff --git a/4b-install-ssl-letsencrypt-nginx.sh b/4b-install-ssl-letsencrypt-nginx.sh index e0013de..cebfbe8 100644 --- a/4b-install-ssl-letsencrypt-nginx.sh +++ b/4b-install-ssl-letsencrypt-nginx.sh @@ -151,7 +151,7 @@ sed -i '/# certbot renew/d' cron_1 # Randomly choose a daily update schedule and append this to the cron schedule HOUR=$(shuf -i 0-23 -n 1) MINUTE=$(shuf -i 0-59 -n 1) -echo "${MINUTE} ${HOUR} * * * /usr/bin/certbot renew --quiet --pre-hook 'service nginx stop' --post-hook 'service nginx start'" >>cron_1 +echo "${MINUTE} ${HOUR} * * * /usr/bin/certbot renew --quiet --pre-hook 'systemctl stop nginx' --post-hook 'systemctl start nginx'" >>cron_1 # Overwrite old cron settings and cleanup crontab cron_1 rm cron_1 diff --git a/add-smtp-relay-o365.sh b/add-smtp-relay-o365.sh index 171f7d6..185d12f 100644 --- a/add-smtp-relay-o365.sh +++ b/add-smtp-relay-o365.sh @@ -108,7 +108,7 @@ sudo postmap /etc/postfix/generic # Restart and test echo -e "${GREY}Restarting Postfix..." -sudo service postfix restart +sudo systemctl restart postfix if [ $? -ne 0 ]; then echo -e "${LRED}Postfix restart failed. ${GREY}" 1>&2 exit 1