Verified Commit 753f01a3 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

files/immediate_reboot: block shutdown when updater or opkg is running

This protects against reboots breaking system if they happen in
inappropriate time during update. It is not ultimate solution as user
can simply unplug router but it helps in some cases.
parent 71a3ea87
......@@ -5,6 +5,7 @@
# as soon as possible.
status() {
return 0
......@@ -22,7 +23,20 @@ start() {
stop() {
# Block shutdown when update is running
# We have to use Python3 as there seems to be no shell tool to simply use
# POSIX file locks (lockf instead of flock)
python3 - <<-EOF
import fcntl
f = open("/var/lock/opkg.lock", 'w')
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
except BlockingIOError:
print("Waiting for opkg or updater to terminate...")
fcntl.lockf(f, fcntl.LOCK_EX)
print("Temination of updater/opkg detected, unblocking shutdown.")
restart() {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment