#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: http://mirrors.slickstack.io/bash/ss-restart-services.txt ############################# #### path: /var/www/ss-restart-services ############################################################ #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Restarts all of the SlickStack LEMP module services (e.g. Ubuntu packages) ########### #### module version: Ubuntu 20.04 LTS ############################################################## #################################################################################################### ## YOU CAN RUN SS-RESTART FOR AN EASY WAY TO RESTART ALL CORE SLICKSTACK (LEMP) MODULES ## ## THIS DOES NOT INCLUDE ANY CUSTOM UBUNTU PACKAGES THAT YOU MAY HAVE INSTALLED ## ## include SlickStack configuration ## source /var/www/ss-config ## include SlickStack functions ## source /var/www/ss-functions #################################################################################################### #### SS-Restart-Services: Message (Begin Script) ################################################### #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## echo -e "${PURPLE}Running ss-restart-services: Restarts all of the SlickStack LEMP module services (e.g. Ubuntu packages)... ${NOCOLOR}" sleep "$SLEEP_MESSAGE_BEGIN" #################################################################################################### #### SS-Restart-Services: Forcefully Restart LEMP Modules (Systemd Services, Etc) ################## #################################################################################################### ## this script is using init.d instead of systemd shortcuts to allow for absolute paths ## ## we are looking into including other snippets here such as unmasking (etc) ## ## unmask services ## # systemctl unmask mysql.service ## reload .bashrc settings ## source /root/.bashrc source /home/${SUDO_USER}/.bashrc ## restart all LEMP modules (Ubuntu services) ## /etc/init.d/clamav-freshclam restart /etc/init.d/redis-server restart /etc/init.d/php*-fpm restart /etc/init.d/nginx restart /etc/init.d/mysql restart /etc/init.d/ufw force-reload /etc/init.d/ufw restart # /etc/init.d/cron reload # source /var/www/bash/ss-restart-services-nginx # source /var/www/bash/ss-restart-services-php #################################################################################################### #### SS-Restart-Services: Touch Timestamp File (End Script) ######################################## #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ## script timestamp ## touch /var/www/meta/.timestamp-ss-restart-services #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: https://unix.stackexchange.com/questions/370942/do-you-need-to-reload-after-adding-a-rule-in-ufw/370947 ## Ref: http://blog.jonathanargentiero.com/failed-to-restart-mysql-service-unit-mysql-service-is-masked/ ## Ref: https://support.plesk.com/hc/en-us/articles/360021187734-The-service-fails-to-start-on-a-Linux-server-service-is-masked ## Ref: https://jira.percona.com/browse/PS-5226 ## Ref: https://blog.ruanbekker.com/blog/2017/12/09/unmask-a-masked-service-in-systemd/ ## Ref: https://askubuntu.com/questions/992464/version-agnostic-php-fpm-restart ## Ref: https://serverfault.com/questions/189940/how-do-you-restart-php-fpm ## Ref: https://stackoverflow.com/questions/41319291/ufw-blocks-most-ports-until-disabled-and-re-enabled-after-reboot ## Ref: https://www.vultr.com/docs/configure-ubuntu-firewall-ufw-on-ubuntu-18-04 ## Ref: https://askubuntu.com/questions/2075/whats-the-difference-between-service-and-etc-init-d ## Ref: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units ## Ref: https://stackoverflow.com/questions/10193788/restarting-cron-after-changing-crontab-file ## SS_EOF