Skip to content

Commit 9bfaf3d

Browse files
committed
2026-5-6 13:36 Code check by Copilot on Github
1 parent 843b47f commit 9bfaf3d

4 files changed

Lines changed: 31 additions & 11 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ If you find this project elsewhere, treat it as untrusted.
221221

222222
---
223223

224+
## 📚 Documentation
225+
226+
See Wiki for detailed usage (Keep on update):
227+
https://github.com/Tetsuya1126/raspi_overlay-auto-update/wiki
228+
229+
---
230+
224231
## 🤝 Contributing
225232

226233
Issues and Pull Requests are welcome.
@@ -246,3 +253,7 @@ MIT License
246253
Actively used in real-world deployments and maintained as needed.
247254

248255
Reliable updates for read-only Raspberry Pi systems.
256+
257+
---
258+
259+
Keywords: Raspberry Pi OverlayFS auto update safe upgrade systemd.

libs/overlay_mode_change.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
overlay_on() {
66
echo "[INFO] Turning overlay ON"
7-
sudo "$OVERLAY_CMD" "$OVERLAY_SUBCMD" "$OVERLAY_OP" "$OVERLAY_TURN_ON" || return 1
7+
"$OVERLAY_CMD" "$OVERLAY_SUBCMD" "$OVERLAY_OP" "$OVERLAY_TURN_ON" || return 1
88
systemctl daemon-reload || return 1
99
}
1010

1111
overlay_off() {
1212
echo "[INFO] Turning overlay OFF"
13-
sudo "$OVERLAY_CMD" "$OVERLAY_SUBCMD" "$OVERLAY_OP" "$OVERLAY_TURN_OFF" || return 1
13+
"$OVERLAY_CMD" "$OVERLAY_SUBCMD" "$OVERLAY_OP" "$OVERLAY_TURN_OFF" || return 1
1414
systemctl daemon-reload || return 1
1515
}
1616

modules/actions.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ action_raspi_only() {
2525
done_after_maintenance
2626
;;
2727
IDLE)
28-
log_info "Run maintenance tasks. $ACTION"
28+
log_info "Initial state detected. Running first maintenance. $ACTION"
2929
run_maintenance
3030
done_after_maintenance
3131
;;
@@ -45,10 +45,14 @@ action_pc_only() {
4545
#export DRY=true
4646

4747
case "$ACTION" in
48-
DO_MAINTENANCE | MAINTENANCE_CONTINUE | IDLE)
48+
DO_MAINTENANCE | MAINTENANCE_CONTINUE)
4949
log_info "Run maintenance tasks. $ACTION"
5050
run_maintenance
5151
;;
52+
IDLE)
53+
log_info "Initial state detected. Running first maintenance. $ACTION"
54+
run_maintenance
55+
;;
5256
NEED_OVERLAY_OFF | RESUME_TO_OVERLAY_OFF)
5357
log_info "Stay, Irregular $ACTION"
5458
;;

modules/state_manager.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,23 @@ state_set() {
4949
}
5050

5151
# --------------------------------------------
52-
# return 0 = cooldown elapsed (実行可能)
53-
# return 1 = still cooling down (まだ実行不可)
52+
# return 0 = still cooling down (まだ実行不可)
53+
# return 1 = cooldown elapsed (実行可能)
5454
# --------------------------------------------
55-
state_is_cooldown_elapsed() {
55+
is_cooldown_state() {
5656
local done_at="$1"
5757

5858
# done_at が無い or 0 の場合は即 elapsed 判定
5959
if [[ -z "$done_at" || "$done_at" -le 0 ]]; then
60-
return 0
60+
return 1
6161
fi
6262

63-
[ -n "$done_at" ] && [ $(( $(date +%s) - done_at )) -lt "$COOLDOWN" ]
63+
# クールダウン中ならアクティブ(return 0)
64+
if [ $(( $(date +%s) - done_at )) -lt "$COOLDOWN" ]; then
65+
return 0
66+
else
67+
return 1
68+
fi
6469
}
6570

6671
# ---- Decide action ----
@@ -89,7 +94,7 @@ state_decide_action() {
8994
# shellcheck disable=SC2153
9095
case "$state" in
9196
"$STATE_DONE")
92-
if state_is_cooldown_elapsed "$done_at"; then
97+
if is_cooldown_state "$done_at"; then
9398
echo "COOL_DOWN"
9499
else
95100
echo "NEED_OVERLAY_OFF"
@@ -109,7 +114,7 @@ state_decide_action() {
109114
else
110115
case "$state" in
111116
"$STATE_DONE")
112-
if state_is_cooldown_elapsed "$done_at"; then
117+
if is_cooldown_state "$done_at"; then
113118
echo "COOL_DOWN"
114119
else
115120
echo "DO_MAINTENANCE"

0 commit comments

Comments
 (0)