mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-07 20:54:14 +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
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=90
|
||||
|
||||
run_reboot()
|
||||
{
|
||||
local enable
|
||||
config_get_bool enable $1 enable
|
||||
|
||||
if [ $enable ]; then
|
||||
local minute
|
||||
local hour
|
||||
|
||||
config_get minute $1 minute
|
||||
config_get hour $1 hour
|
||||
|
||||
sed '/reboot/ d' /etc/crontabs/root > /tmp/crontab_root_tmp
|
||||
cp /tmp/crontab_root_tmp /etc/crontabs/root
|
||||
echo "$minute $hour * * * reboot &" >> /etc/crontabs/root
|
||||
|
||||
echo "Auto REBOOT has started."
|
||||
/etc/init.d/cron restart
|
||||
else
|
||||
sed '/reboot/ d' /etc/crontabs/root > /tmp/crontab_root_tmp
|
||||
cp /tmp/crontab_root_tmp /etc/crontabs/root
|
||||
echo "Auto REBOOT has started."
|
||||
/etc/init.d/cron restart
|
||||
fi
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
config_load autoreboot
|
||||
config_foreach run_reboot login
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
echo "Auto REBOOT has stoped."
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
log_file="/tmp/log/autoshell.log"
|
||||
|
||||
start() {
|
||||
state=$(pgrep -f "/etc/autoshell.sh")
|
||||
|
||||
config_content=$(cat /etc/config/autoshell)
|
||||
if echo "$config_content" | grep -q "禁用"; then
|
||||
echo "[$(date "+%Y-%m-%d %H:%M:%S")]: 脚本已禁用" >> "$log_file"
|
||||
return 1
|
||||
|
||||
else
|
||||
/etc/autoshell.sh &
|
||||
echo "[$(date "+%Y-%m-%d %H:%M:%S")]: 已启动认证脚本" >> "$log_file"
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
kill -9 $(pgrep -f "/etc/autoshell.sh") 2>/dev/null
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S"): 已停止认证" >>
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
echo "$(date "+%Y-%m-%d %H:%M:%S"): 已重新启动 /etc/autoshell.sh"
|
||||
}
|
||||
|
||||
disable() {
|
||||
echo "禁用功能未实现"
|
||||
}
|
||||
Reference in new issue
Block a user