mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
sulu: Fix migration scripts
This commit is contained in:
parent
2528cde629
commit
9a36c0310f
2 changed files with 29 additions and 40 deletions
|
|
@ -1,15 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
UCI_TEMPLATE="/etc/nginx/uci.conf.template"
|
||||
|
||||
if [ ! -f "/etc/config/mosquitto" ]; then
|
||||
echo "Local mosquitto broker not available"
|
||||
return 0
|
||||
logger -t sulu.ucidefault "Local mosquitto broker not available"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${UCI_TEMPLATE}" ]; then
|
||||
echo "nginx utils not installed, sulu can't run"
|
||||
return 0
|
||||
logger -t sulu.ucidefault "nginx utils not installed, sulu can't run"
|
||||
return 1
|
||||
fi
|
||||
|
||||
update_nginx_uci_template()
|
||||
|
|
@ -19,7 +20,7 @@ update_nginx_uci_template()
|
|||
port="$(uci -q get mosquitto.sulu.port)"
|
||||
port="${port:-9009}"
|
||||
|
||||
if ! grep -q "upstream websocket" ${UCI_TEMPLATE}; then
|
||||
if ! grep -w "upstream websocket" ${UCI_TEMPLATE} | grep -wq "127.0.0.1:${port}"; then
|
||||
sed -i '/#UCI_HTTP_CONFIG$/i\ map $http_upgrade $connection_upgrade { default upgrade; "" close; }' ${UCI_TEMPLATE}
|
||||
sed -i "/#UCI_HTTP_CONFIG$/i\ upstream websocket { server 127.0.0.1:${port}; }" ${UCI_TEMPLATE}
|
||||
fi
|
||||
|
|
@ -27,7 +28,6 @@ update_nginx_uci_template()
|
|||
|
||||
add_sulu_config_to_mosquitto()
|
||||
{
|
||||
if ! uci_get mosquitto sulu >/dev/null 2>&1; then
|
||||
uci_add mosquitto listener sulu
|
||||
uci_set mosquitto sulu enabled 1
|
||||
uci_set mosquitto sulu port '9009'
|
||||
|
|
@ -35,29 +35,23 @@ add_sulu_config_to_mosquitto()
|
|||
uci_set mosquitto sulu protocol 'websockets'
|
||||
uci_set mosquitto sulu auth_plugin '/usr/lib/mosquitto_auth_shadow.so'
|
||||
uci_set mosquitto sulu acl_file '/etc/sulu/mqtt.acl'
|
||||
fi
|
||||
}
|
||||
|
||||
add_sulu_userinterface_uci()
|
||||
{
|
||||
uci_load userinterface
|
||||
|
||||
if ! uci_get userinterface _sulu_s >/dev/null 2>&1; then
|
||||
if [ -f "/etc/config/userinterface" ]; then
|
||||
uci_add userinterface http_access _sulu_s
|
||||
uci_set userinterface _sulu_s path_prefix '/sulu'
|
||||
uci_set userinterface _sulu_s port '8443'
|
||||
uci_add_list userinterface _sulu_s _nginx_include '/etc/sulu/nginx.locations'
|
||||
uci_set userinterface _sulu_s _nginx_include '/etc/sulu/nginx.locations'
|
||||
uci_set userinterface _sulu_s _nginx_uci_manage_ssl 'self-signed'
|
||||
uci_set userinterface _sulu_s _nginx_ssl_certificate '/etc/nginx/conf.d/_lan.crt'
|
||||
uci_set userinterface _sulu_s _nginx_ssl_certificate_key '/etc/nginx/conf.d/_lan.key'
|
||||
uci_set userinterface _sulu_s _nginx_ssl_session_cache 'none'
|
||||
uci_set userinterface _sulu_s _nginx_error_page '503 /maintenance.html'
|
||||
uci_set userinterface _sulu_s protocol 'HTTPS'
|
||||
uci_add_list userinterface _sulu_s role 'admin'
|
||||
uci_add_list userinterface _sulu_s role 'user'
|
||||
fi
|
||||
uci_set userinterface _sulu_s role 'admin user'
|
||||
|
||||
if ! uci_get userinterface _suluredirect >/dev/null 2>&1; then
|
||||
uci_add userinterface http_access _suluredirect
|
||||
uci_set userinterface _suluredirect redirect '_sulu_s'
|
||||
uci_set userinterface _suluredirect protocol 'HTTP'
|
||||
|
|
|
|||
|
|
@ -2,23 +2,16 @@
|
|||
|
||||
. /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
|
||||
|
||||
update_default_nginx_listner() {
|
||||
|
||||
if [ ! -f /etc/config/nginx ]; then
|
||||
return
|
||||
if [ ! -f "/etc/config/nginx" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! uci_get nginx _lan >/dev/null 2>&1; then
|
||||
return
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! opkg list-installed |grep -q "luci "; then
|
||||
if ! opkg list-installed | grep -q "^luci "; then
|
||||
echo "Luci not installed, removing luci config"
|
||||
uci_remove nginx _lan
|
||||
uci_remove nginx _redirect2ssl
|
||||
|
|
@ -28,7 +21,7 @@ update_default_nginx_listner() {
|
|||
uci_add_list nginx _lan listen "[::]:8443 ssl default_server"
|
||||
|
||||
if ! uci_get nginx _redirect2ssl >/dev/null 2>&1; then
|
||||
return
|
||||
return 0
|
||||
fi
|
||||
|
||||
uci_remove nginx _redirect2ssl listen
|
||||
|
|
@ -39,17 +32,19 @@ update_default_nginx_listner() {
|
|||
}
|
||||
|
||||
move_sulu_to_443_and_80() {
|
||||
uci_load userinterface
|
||||
if [ ! -f /etc/config/userinterface ]; then
|
||||
return
|
||||
if ! config_load userinterface; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
set_port() {
|
||||
local protocol
|
||||
local protocol port
|
||||
|
||||
config_get protocol "$1" protocol
|
||||
if [ "$protocol" == "HTTPS" ]; then
|
||||
config_get port "$1" port
|
||||
|
||||
if [ "$protocol" == "HTTPS" ] && [ "${port}" -eq "8443" ]; then
|
||||
uci_set userinterface "$1" port "443"
|
||||
elif [ "$protocol" == "HTTP" ]; then
|
||||
elif [ "$protocol" == "HTTP" ] && [ "${port}" -eq "8080" ]; then
|
||||
uci_set userinterface "$1" port "80"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue