mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 08:23: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
@@ -0,0 +1,9 @@
|
||||
|
||||
config schedule
|
||||
option enabled '0'
|
||||
option week '0'
|
||||
option hour '2'
|
||||
option minute '0'
|
||||
option month '*'
|
||||
option day '*'
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=50
|
||||
USE_PROCD=1
|
||||
|
||||
CONF="autoreboot"
|
||||
CRON_FILE="/tmp/autoreboot.cron"
|
||||
|
||||
setup_cron() {
|
||||
local cfg="$1"
|
||||
|
||||
local enabled
|
||||
config_get_bool enabled "$cfg" "enabled" "0"
|
||||
|
||||
[ "$enabled" -eq "1" ] || return 1
|
||||
|
||||
local minute hour day month week
|
||||
config_get minute "$cfg" "minute"
|
||||
config_get hour "$cfg" "hour"
|
||||
config_get day "$cfg" "day"
|
||||
config_get month "$cfg" "month"
|
||||
config_get week "$cfg" "week"
|
||||
|
||||
echo "$minute $hour $day $month $week sleep 5 && touch /etc/banner && reboot #${CONF}_$cfg" >> "$CRON_FILE"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
crontab -l | sed "/#${CONF}_/d" > "$CRON_FILE"
|
||||
|
||||
config_load "$CONF"
|
||||
config_foreach setup_cron schedule
|
||||
|
||||
crontab "$CRON_FILE"
|
||||
rm -f "$CRON_FILE"
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
sed -i "/#${CONF}_/d" "/etc/crontabs/root"
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONF"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-autoreboot.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-autoreboot.json << EEOF
|
||||
{
|
||||
"config": "autoreboot",
|
||||
"init": "autoreboot"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
if uci -q get "autoreboot.@login[0]" > "/dev/null"; then
|
||||
uci rename "autoreboot.@login[0].enable"="enabled"
|
||||
uci set "autoreboot.@login[0].day"="*"
|
||||
uci set "autoreboot.@login[0].month"="*"
|
||||
[ "$(uci get "autoreboot.@login[0]".week)" = "7" ] && uci set "autoreboot.@login[0].week"="*"
|
||||
uci commit "autoreboot"
|
||||
sed -i "s,config login,config schedule,g" "/etc/config/autoreboot"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"admin/system/autoreboot": {
|
||||
"title": "Scheduled Reboot",
|
||||
"order": 88,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "autoreboot"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-autoreboot" ],
|
||||
"uci": { "autoreboot": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-autoreboot": {
|
||||
"description": "Grant UCI access for luci-app-autoreboot",
|
||||
"read": {
|
||||
"uci": [ "autoreboot" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "autoreboot" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user