Replace service command with systemctl (#11)

Service command isn't available on current Debian Stable onwards.

remove unneeded sudo calls
This commit is contained in:
Eduardo Mozart de Oliveira 2023-08-08 10:58:08 -03:00 committed by itiligent
parent e906a85266
commit f5fc746b4c
3 changed files with 12 additions and 12 deletions

View file

@ -78,7 +78,7 @@ if [ $? -ne 0 ]; then
else
echo -e "${LGREEN}OK${GREY}"
fi
service postfix restart
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
systemctl restart ${TOMCAT_VERSION}
if [ $? -ne 0 ]; then
echo -e "${LRED}Failed${GREY}" 1>&2
exit 1
@ -349,7 +349,7 @@ 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
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
systemctl restart mysql
fi
fi
if [ $? -ne 0 ]; then
@ -481,8 +481,8 @@ 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
systemctl stop guacd 2>/dev/null
systemctl start guacd
if [ $? -ne 0 ]; then
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
exit 1
@ -539,10 +539,10 @@ fi
if [ "${CHANGE_ROOT}" = true ]; then
echo -e "${GREY}Setting default Guacamole url to http root...${DGREY}"
sudo systemctl stop ${TOMCAT_VERSION}
sudo rm -rf /var/lib/${TOMCAT_VERSION}/webapps/ROOT
sudo mv /var/lib/${TOMCAT_VERSION}/webapps/guacamole.war /var/lib/${TOMCAT_VERSION}/webapps/ROOT.war
sudo systemctl start ${TOMCAT_VERSION}
systemctl stop ${TOMCAT_VERSION}
rm -rf /var/lib/${TOMCAT_VERSION}/webapps/ROOT
mv /var/lib/${TOMCAT_VERSION}/webapps/guacamole.war /var/lib/${TOMCAT_VERSION}/webapps/ROOT.war
systemctl start ${TOMCAT_VERSION}
if [ $? -ne 0 ]; then
echo -e "${LRED}Failed. See ${LOG_LOCATION}${GREY}" 1>&2
exit 1

View file

@ -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

View file

@ -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