1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00
raspap-webgui/installers/configport.sh

55 lines
1.3 KiB
Bash
Raw Normal View History

2019-11-10 23:09:36 +01:00
#!/bin/bash
2019-11-17 11:11:52 +01:00
#
2020-07-29 16:52:31 +02:00
# Updates lighttpd config settings and restarts the service
2019-11-17 11:11:52 +01:00
# @author billz
# license: GNU General Public License v3.0
2019-11-10 23:09:36 +01:00
2020-07-29 16:52:31 +02:00
# Exit on error
set -o errexit
# Exit on error inside functions
set -o errtrace
# Turn on traces, disabled by default
#set -o xtrace
2019-11-10 23:09:36 +01:00
server_port=$1
2020-07-29 16:52:31 +02:00
server_bind=$2
lighttpd_conf=$3
host=$4
2019-11-11 14:37:06 +01:00
restart_service=0
2019-11-10 23:09:36 +01:00
2019-11-11 14:37:06 +01:00
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
2020-08-05 19:58:29 +02:00
fi
if [ -n "$server_port" ]; then
echo "Changing lighttpd server.port to $server_port ..."
2019-11-11 14:37:06 +01:00
sed -i "s/^\(server\.port *= *\)[0-9]*/\1$server_port/g" "$lighttpd_conf"
2020-08-06 00:07:55 +02:00
echo "RaspAP will now be available at port $server_port"
conf_change=1
2019-11-11 14:37:06 +01:00
fi
2020-08-05 19:58:29 +02:00
if [ -n "$server_bind" ]; then
echo "Changing lighttpd server.bind to $server_bind ..."
grep -q 'server.bind' "$lighttpd_conf" && \
sed -i "s/^\(server\.bind.*= \)\".*\"*/\1\"$server_bind\"/g" "$lighttpd_conf" || \
2020-08-06 09:34:14 +02:00
printf "server.bind \t\t\t\t = \"$server_bind\"\n" >> "$lighttpd_conf"
2020-08-06 00:07:55 +02:00
echo "RaspAP will now be available at address $server_bind"
conf_change=1
fi
if [ "$conf_change" == 1 ]; then
echo "Restart lighttpd for new settings to take effect"
2020-08-05 19:58:29 +02:00
fi
2019-11-10 23:09:36 +01:00