|
@@ -59,6 +59,21 @@ generate_keys() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+create_httpauth() {
|
|
|
|
|
+ local cfg="$1"
|
|
|
|
|
+ local prefix username password
|
|
|
|
|
+
|
|
|
|
|
+ config_get prefix "$cfg" prefix
|
|
|
|
|
+ config_get username "$cfg" username
|
|
|
|
|
+ config_get password "$cfg" password
|
|
|
|
|
+
|
|
|
|
|
+ if [ -z "$prefix" ] || [ -z "$username" ] || [ -z "$password" ]; then
|
|
|
|
|
+ return
|
|
|
|
|
+ fi
|
|
|
|
|
+ echo "${prefix}:${username}:${password}" >>$httpdconf
|
|
|
|
|
+ haveauth=1
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
start_instance()
|
|
start_instance()
|
|
|
{
|
|
{
|
|
|
UHTTPD_CERT=""
|
|
UHTTPD_CERT=""
|
|
@@ -66,13 +81,25 @@ start_instance()
|
|
|
|
|
|
|
|
local cfg="$1"
|
|
local cfg="$1"
|
|
|
local realm="$(uci_get system.@system[0].hostname)"
|
|
local realm="$(uci_get system.@system[0].hostname)"
|
|
|
- local listen http https interpreter indexes path handler
|
|
|
|
|
|
|
+ local listen http https interpreter indexes path handler httpdconf haveauth
|
|
|
|
|
|
|
|
procd_open_instance
|
|
procd_open_instance
|
|
|
procd_set_param respawn
|
|
procd_set_param respawn
|
|
|
procd_set_param stderr 1
|
|
procd_set_param stderr 1
|
|
|
procd_set_param command "$UHTTPD_BIN" -f
|
|
procd_set_param command "$UHTTPD_BIN" -f
|
|
|
|
|
|
|
|
|
|
+ config_get config "$cfg" config
|
|
|
|
|
+ if [ -z "$config" ]; then
|
|
|
|
|
+ mkdir -p /var/etc/uhttpd
|
|
|
|
|
+ httpdconf="/var/etc/uhttpd/httpd.${cfg}.conf"
|
|
|
|
|
+ rm -f ${httpdconf}
|
|
|
|
|
+ config_list_foreach "$cfg" httpauth create_httpauth
|
|
|
|
|
+ if [ "$haveauth" = "1" ]; then
|
|
|
|
|
+ procd_append_param command -c ${httpdconf}
|
|
|
|
|
+ [ -r /etc/httpd.conf ] && cat /etc/httpd.conf >>/var/etc/uhttpd/httpd.${cfg}.conf
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
append_arg "$cfg" home "-h"
|
|
append_arg "$cfg" home "-h"
|
|
|
append_arg "$cfg" realm "-r" "${realm:-OpenWrt}"
|
|
append_arg "$cfg" realm "-r" "${realm:-OpenWrt}"
|
|
|
append_arg "$cfg" config "-c"
|
|
append_arg "$cfg" config "-c"
|