mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 20:43:56 +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
+95
@@ -0,0 +1,95 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
CONFIG=cqustdotnet
|
||||
APP_FILE=/usr/share/${CONFIG}/app.lua
|
||||
LOCK_FILE_DIR=/var/lock
|
||||
LOCK_FILE=${LOCK_FILE_DIR}/${CONFIG}.lock
|
||||
|
||||
set_lock() {
|
||||
if [ ! -d "$LOCK_FILE_DIR" ]; then
|
||||
mkdir -p "$LOCK_FILE_DIR"
|
||||
fi
|
||||
exec 789>"$LOCK_FILE"
|
||||
flock -xn 789
|
||||
}
|
||||
|
||||
unset_lock() {
|
||||
flock -u 789
|
||||
rm -rf "$LOCK_FILE"
|
||||
}
|
||||
|
||||
unlock() {
|
||||
local fail_count=1
|
||||
while [ "$fail_count" -le 10 ]; do
|
||||
if [ -f "$LOCK_FILE" ]; then
|
||||
let "fail_count++"
|
||||
sleep 1s
|
||||
if [ "$fail_count" -ge 10 ]; then
|
||||
unset_lock
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
boot() {
|
||||
$APP_FILE boot
|
||||
}
|
||||
|
||||
start() {
|
||||
set_lock
|
||||
if [ $? == 1 ]; then
|
||||
$APP_FILE log '脚本已在运行,不再重复运行,退出'
|
||||
exit 0
|
||||
fi
|
||||
$APP_FILE start
|
||||
unset_lock
|
||||
}
|
||||
|
||||
stop() {
|
||||
unlock
|
||||
set_lock
|
||||
if [ $? == 1 ]; then
|
||||
$APP_FILE log '停止脚本等待超时,不重复运行,退出'
|
||||
exit 0
|
||||
fi
|
||||
$APP_FILE stop
|
||||
unset_lock
|
||||
}
|
||||
|
||||
restart() {
|
||||
set_lock
|
||||
if [ $? == 1 ]; then
|
||||
$APP_FILE log '脚本已在运行,不重复运行,退出'
|
||||
exit 0
|
||||
fi
|
||||
$APP_FILE stop
|
||||
$APP_FILE start
|
||||
unset_lock
|
||||
}
|
||||
|
||||
disable() {
|
||||
rm -f "$IPKG_INSTROOT"/etc/rc.d/S??${CONFIG}
|
||||
rm -f "$IPKG_INSTROOT"/etc/rc.d/K??${CONFIG}
|
||||
}
|
||||
|
||||
enable() {
|
||||
err=1
|
||||
if [ "$START" ]; then
|
||||
ln -sf "../init.d/${CONFIG}" "$IPKG_INSTROOT/etc/rc.d/S${START}${CONFIG}"
|
||||
err=0
|
||||
fi
|
||||
if [ "$STOP" ]; then
|
||||
ln -sf "../init.d/${CONFIG}" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${CONFIG}"
|
||||
err=0
|
||||
fi
|
||||
return $err
|
||||
}
|
||||
|
||||
enabled() {
|
||||
[ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${CONFIG}" ]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-cqustdotnet.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-cqustdotnet.json << EEOF
|
||||
{
|
||||
"config": "cqustdotnet",
|
||||
"init": "cqustdotnet"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@cqustdotnet[-1]
|
||||
add ucitrack cqustdotnet
|
||||
set ucitrack.@cqustdotnet[-1].init=cqustdotnet
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
[ ! -s '/etc/config/cqustdotnet' ] && cp -f /usr/share/cqustdotnet/0_default_config /etc/config/cqustdotnet
|
||||
rm -f /tmp/luci-indexcache
|
||||
rm -rf /tmp/luci-modulecache/
|
||||
exit 0
|
||||
Reference in new issue
Block a user