From 24b669b157403cf52a3c90ea7371be7283b11409 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 11 Nov 2019 13:37:06 +0000 Subject: [PATCH] Added -r option, changed msgs --- installers/configport.sh | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/installers/configport.sh b/installers/configport.sh index c3f4165c..add2d309 100755 --- a/installers/configport.sh +++ b/installers/configport.sh @@ -6,11 +6,29 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin server_port=$1 lighttpd_conf=$2 host=$3 +restart_service=0 -echo "Changing lighttpd server.port to $server_port..." -sed -i "s/^\(server\.port *= *\)[0-9]*/\1$server_port/g" "$lighttpd_conf" +while :; do + case $1 in + -r|--restart) + restart_service=1 + shift + ;; + *) + break + ;; + esac +done + +if [ "$restart_service" = 1 ]; then + echo "Restarting lighttpd in 3 seconds..." + sleep 3 + systemctl restart lighttpd.service +else + echo "Changing lighttpd server.port to $server_port..." + sed -i "s/^\(server\.port *= *\)[0-9]*/\1$server_port/g" "$lighttpd_conf" + + echo "RaspAP will now be available at $host:$server_port" + echo "Restart lighttpd for new setting to take effect" +fi -echo "RaspAP will now be available at $host:$server_port" -echo "Restarting lighttpd in 5 seconds..." -sleep 5 -systemctl restart lighttpd.service