#!/bin/bash ########################################################################### # First Created: 17082021 Author: Allan Desc: DokuWiki postinstall script # ########################################################################### # # Are we root # if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo ""; exit 1; fi # # Are we in the right directory # scriptdir="dokuwiki-install" && whereami=$(pwd |awk -F'/' '{print $NF}') if [ "$whereami" != "$scriptdir" ]; then printf "\nWrong directory! Script must be run from %s\n\n" "$scriptdir"; exit 1; fi # # Define variables and functions # line () { printf -- '-%.0s' {1..50}; printf '\n'; } hostname=$(cat hostname) nginxconfig="/etc/nginx/conf.d" # # Function to check if a service is already running or not # serviceno () { printf "\n%s" $service ; printf " is not running cannot continue...\n\n"; } servicedead () { status=$(systemctl is-active $service); if [[ "$status" != "active" ]]; then serviceno ; exit; fi; } # # Function title # title () { printf "\nDokuwiki postinstall script V1.0\n\n"; } # # If Nginx is not running then die # service="nginx" ; servicedead # # Hardening DokuWiki # sed -i 's/# location /location /g' $nginxconfig/"$hostname".conf # # Restart Nginx in order for changes to take effect # systemctl restart nginx # # Cleaning up # rm hostname # # All done # clear ; printf "\n" ; line ; printf "All Done...\n" ; line ; printf "\n" # # End of script #