mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-31 22:15:13 +08:00
update 2026-09-26 11:07:27
This commit is contained in:
1 parent
7b88b273d0
commit
97ae9f68da
4898 files changed
-1712274
No files matched your search
@@ -1,86 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
STOP=15
|
||||
|
||||
ROOT="${IPKG_INSTROOT:-}"
|
||||
. "$ROOT/usr/share/passwall/utils.sh"
|
||||
APP_FILE=${APP_PATH}/app.sh
|
||||
LOCK_FILE_DIR=/var/lock
|
||||
LOCK_FILE=${LOCK_FILE_DIR}/${CONFIG}.lock
|
||||
|
||||
set_lock() {
|
||||
[ ! -d "$LOCK_FILE_DIR" ] && mkdir -p $LOCK_FILE_DIR
|
||||
exec 999>"$LOCK_FILE"
|
||||
flock -xn 999
|
||||
}
|
||||
|
||||
unset_lock() {
|
||||
flock -u 999
|
||||
rm -rf "$LOCK_FILE"
|
||||
}
|
||||
|
||||
unlock() {
|
||||
failcount=1
|
||||
while [ "$failcount" -le 10 ]; do
|
||||
if [ -f "$LOCK_FILE" ]; then
|
||||
let "failcount++"
|
||||
sleep 1s
|
||||
[ "$failcount" -ge 10 ] && unset_lock
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
boot_func() {
|
||||
local delay=$(uci -q get ${CONFIG}.@global_delay[0].start_delay || echo 1)
|
||||
if [ "$delay" -gt 0 ]; then
|
||||
echolog "执行启动延时 $delay 秒后再启动!"
|
||||
sleep $delay
|
||||
fi
|
||||
restart boot
|
||||
touch ${LOCK_FILE_DIR}/${CONFIG}_ready.lock
|
||||
}
|
||||
|
||||
boot() {
|
||||
boot_func >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
start() {
|
||||
set_lock
|
||||
[ $? == 1 ] && echolog "脚本已经在运行,不重复运行,退出." && exit 0
|
||||
$APP_FILE start
|
||||
unset_lock
|
||||
}
|
||||
|
||||
stop() {
|
||||
unlock
|
||||
set_lock
|
||||
[ $? == 1 ] && echolog "停止脚本等待超时,不重复运行,退出." && exit 0
|
||||
$APP_FILE stop
|
||||
unset_lock
|
||||
}
|
||||
|
||||
restart() {
|
||||
set_lock
|
||||
[ $? == 1 ] && echolog "脚本已经在运行,不重复运行,退出." && exit 0
|
||||
rule_lock=${LOCK_FILE_DIR}/${CONFIG}_rule_update.lock
|
||||
sub_lock=${LOCK_FILE_DIR}/${CONFIG}_subscribe.lock
|
||||
for i in $(seq 1 300); do
|
||||
if [ ! -f "$rule_lock" ] && [ ! -f "$sub_lock" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
rm -f "$rule_lock" "$sub_lock"
|
||||
$APP_FILE stop
|
||||
$APP_FILE start $1
|
||||
unset_lock
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo "Warning: This service does not support configuration reloading"
|
||||
echo "Performing full restart instead..."
|
||||
restart
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
boot_func() {
|
||||
config_load passwall_server
|
||||
config_get start_delay global start_delay 90
|
||||
case "$start_delay" in
|
||||
''|*[!0-9]*) start_delay=90 ;;
|
||||
*) [ "$start_delay" -le 600 ] 2>/dev/null || start_delay=90 ;;
|
||||
esac
|
||||
[ "$start_delay" -gt 0 ] && sleep "$start_delay"
|
||||
restart
|
||||
}
|
||||
|
||||
boot() {
|
||||
boot_func >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
start() {
|
||||
lua /usr/lib/lua/luci/passwall/server_app.lua start
|
||||
}
|
||||
|
||||
stop() {
|
||||
lua /usr/lib/lua/luci/passwall/server_app.lua stop
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo "Warning: This service does not support configuration reloading"
|
||||
echo "Performing full restart instead..."
|
||||
restart
|
||||
}
|
||||
Reference in new issue
Block a user