mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-01-27 17:37:18 +01:00
54 lines
1.2 KiB
Bash
Executable file
54 lines
1.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
. /lib/functions.sh
|
|
|
|
uci_load nginx
|
|
# this is to make sure to not mess up existing config
|
|
if uci_get nginx _sulu_s >/dev/null 2>&1; then
|
|
exit 0
|
|
fi
|
|
|
|
move_default_nginx_listener_to_8443() {
|
|
|
|
if [ ! -f /etc/config/nginx ]; then
|
|
return
|
|
fi
|
|
|
|
if ! uci_get nginx _lan >/dev/null 2>&1; then
|
|
return
|
|
fi
|
|
|
|
uci_remove nginx _lan listen
|
|
uci_add_list nginx _lan listen "8443 ssl default_server"
|
|
uci_add_list nginx _lan listen "[::]:8443 ssl default_server"
|
|
|
|
if ! uci_get nginx _redirect2ssl >/dev/null 2>&1; then
|
|
return
|
|
fi
|
|
|
|
uci_remove nginx _redirect2ssl listen
|
|
uci_add_list nginx _redirect2ssl listen "8080"
|
|
uci_add_list nginx _redirect2ssl listen "[::]:8080"
|
|
uci_set nginx _redirect2ssl return '302 https://$host:8443$request_uri'
|
|
}
|
|
|
|
move_sulu_to_443_and_80() {
|
|
uci_load userinterface
|
|
if [ ! -f /etc/config/userinterface ]; then
|
|
return
|
|
fi
|
|
|
|
set_port() {
|
|
local protocol
|
|
config_get protocol "$1" protocol
|
|
if [ "$protocol" == "HTTPS" ]; then
|
|
uci_set userinterface "$1" port "443"
|
|
elif [ "$protocol" == "HTTP" ]; then
|
|
uci_set userinterface "$1" port "80"
|
|
fi
|
|
}
|
|
config_foreach set_port http_access
|
|
}
|
|
|
|
move_default_nginx_listener_to_8443
|
|
move_sulu_to_443_and_80
|