dokuwiki-install/postinstall

54 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2024-10-24 13:00:24 +02:00
#!/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 $scriptdir\n\n"; exit 1; fi
#
# Define variables and functions
#
line (){ for i in {1..50}; do echo -n "$1"; done && printf "\n"; }
hostname=$(cat hostname)
nginxconfig="/etc/nginx/conf.d"
#
# Function to check if a service is already running or not
#
serviceno () { printf "\n$service 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${normal}\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
#