mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-31 10:35:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
Executable
+13
@@ -0,0 +1,13 @@
|
||||
|
||||
config webd
|
||||
option enable '0'
|
||||
option webd_port '9212'
|
||||
|
||||
config users
|
||||
option enable_read '1'
|
||||
option enable_read_list '1'
|
||||
option enable_upload '1'
|
||||
option enable_move '1'
|
||||
option enable_showhide '0'
|
||||
option username 'root'
|
||||
option password 'password'
|
||||
Executable
+123
@@ -0,0 +1,123 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
LOGGER="logger -t [Webd]"
|
||||
|
||||
start_service() {
|
||||
local basic_list="enable webd_conf webd_bin webd_port webd_root enable_recyclebin enable_anonymous anonymous_perm enable_ipv6"
|
||||
local users_list="enable_read enable_read_list enable_upload enable_move enable_showhide"
|
||||
for i in $(echo $basic_list);do
|
||||
local eval $i="$(uci_get_by_type webd 0 $i)"
|
||||
done;unset i
|
||||
if [ "$enable" == 1 ]
|
||||
then
|
||||
[ ! -r "$webd_root" -o ! -d "$webd_root" ] && EXIT "Unable to access $webd_root,exit ..."
|
||||
[ ! -x "$webd_bin" ] && EXIT "Unable to access $webd_bin,exit ..."
|
||||
if [ "$enable_recyclebin" == 1 -a ! -d "$webd_root/.Trash" ]
|
||||
then
|
||||
${LOGGER} "Creating Recycle Bin directory ..."
|
||||
mkdir -p $webd_root/.Trash || EXIT "Failed to create Recycle Bin directory,exit ..."
|
||||
fi
|
||||
${LOGGER} "Removing old config file ..."
|
||||
rm -f $webd_conf
|
||||
touch -a $webd_conf || EXIT "Failed to create config,exit ..."
|
||||
[ "$enable_ipv6" == 1 ] && webd_port="[::]:${webd_port}"
|
||||
if [ "$enable_anonymous" != 0 ]
|
||||
then
|
||||
if [ -n "$anonymous_perm" ]
|
||||
then
|
||||
|
||||
unset enable_anonymous
|
||||
for i in $(echo $anonymous_perm);do
|
||||
enable_anonymous="$enable_anonymous$i"
|
||||
done
|
||||
unset i
|
||||
else
|
||||
enable_anonymous=0
|
||||
uci set webd.@webd[0].enable_anonymous=0
|
||||
uci commit webd
|
||||
fi
|
||||
fi
|
||||
echo "Webd.Listen $webd_port" >> $webd_conf
|
||||
echo "Webd.Root $webd_root" >> $webd_conf
|
||||
echo "Webd.Guest $enable_anonymous" >> $webd_conf
|
||||
|
||||
for u in 0 1;do
|
||||
for i in $(echo $users_list);do
|
||||
eval ${i}=$(uci_get_by_type users $u $i 0)
|
||||
echo "$users_list" | grep -q $i
|
||||
[ "$?" == 0 ] && eval perm_bin=$(eval echo '$'perm_bin)$(uci_get_by_type users $u $i)
|
||||
done
|
||||
unset i
|
||||
username=$(uci_get_by_type users $u username)
|
||||
password=$(uci_get_by_type users $u password)
|
||||
if [ -n "$username" ]
|
||||
then
|
||||
eval perm=$(perm_converter $(eval echo '$'perm_bin) | tail -n 1)
|
||||
if [ -n "$(eval echo '$'perm)" ]
|
||||
then
|
||||
${LOGGER} "Creating account for User $username ..."
|
||||
echo "Webd.User $(eval echo '$'perm) $username $password" >> $webd_conf
|
||||
else
|
||||
${LOGGER} "Removing excessive user config ..."
|
||||
uci delete webd.@users[$u]
|
||||
uci commit webd
|
||||
fi
|
||||
unset perm_bin
|
||||
fi
|
||||
done
|
||||
unset u
|
||||
ps -efww | grep "$webd_bin" | awk '{print $1}' | xargs kill -9 2> /dev/null
|
||||
${LOGGER} "Starting Webd Service ..."
|
||||
procd_open_instance
|
||||
procd_set_param command $webd_bin -c $webd_conf
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
else
|
||||
stop_service
|
||||
${LOGGER} "Webd Service is now disabled ..."
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
${LOGGER} "Stopping Webd Service ..."
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "webd"
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get webd.@$1[$2].$3 2>/dev/null)
|
||||
echo ${ret:=$4}
|
||||
}
|
||||
|
||||
EXIT() {
|
||||
${LOGGER} $*
|
||||
exit
|
||||
}
|
||||
|
||||
perm_converter() {
|
||||
local u i=1
|
||||
echo $1 | egrep -o [0-1] | while read X
|
||||
do
|
||||
if [ "$X" == 1 ]
|
||||
then
|
||||
case $i in
|
||||
1)u=r;;
|
||||
2)u=l;;
|
||||
3)u=u;;
|
||||
4)u=m;;
|
||||
5)u=S;;
|
||||
esac
|
||||
[ -n "$u" ] && a="$a$u"
|
||||
echo "$a"
|
||||
fi
|
||||
i=$(($i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-webd.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-webd.json << EEOF
|
||||
{
|
||||
"config": "webd",
|
||||
"init": "webd"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@webd[-1]
|
||||
add ucitrack webd
|
||||
set ucitrack.@webd[-1].init=webd
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
Reference in new issue
Block a user