Commit 4b95de9 1 parent dcb7216 commit 4b95de9 Copy full SHA for 4b95de9
File tree 9 files changed +64
-14
lines changed
raspberrypi/rootfs-overlay/etc/swupdate
remote/rootfs-overlay/etc/swupdate
9 files changed +64
-14
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
+ systemctl is-active --quiet app || {
4
+ echo " Remote app not running!"
5
+ exit 1
6
+ }
7
+
3
8
ISUPGRADING=$( fw_printenv upgrade_available | awk -F' =' ' {print $2}' )
4
9
echo " upgrade_available=$ISUPGRADING "
5
10
if [ -z " $ISUPGRADING " ]
6
11
then
7
- echo " No RootFs update pending"
12
+ echo " No system update pending"
8
13
else
9
- echo " RootFs update pending, verifying system"
14
+ echo " System update pending, verifying system..."
15
+ # TODO refactor once there are any common system checks:
16
+ # - call script from systemd right after app start (instead of delayed timer)
17
+ # - get pid of app
18
+ # - perform system checks
19
+ # - wait ~ 3 min
20
+ # - check if app is still running and has same pid (i.e. didn't get auto-restarted)
21
+
10
22
# Perform extra checks here.
11
23
# If anything went wrong, reboot again until the bootlimit is reached
12
24
# which triggers a rollback of the RootFs
25
+
26
+ # It's all good! Clear upgrade status and mark partition ok.
13
27
fw_setenv upgrade_available
14
28
fw_setenv bootcount 0
29
+ echo " System update successful. Marked current partition OK."
15
30
fi
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
+ systemctl is-active --quiet app || {
4
+ echo " Remote app not running!"
5
+ exit 1
6
+ }
7
+
3
8
ISUPGRADING=$( fw_printenv upgrade_available | awk -F' =' ' {print $2}' )
4
9
echo " upgrade_available=$ISUPGRADING "
5
10
if [ -z " $ISUPGRADING " ]
6
11
then
7
- echo " No RootFs update pending"
12
+ echo " No system update pending"
8
13
else
9
- echo " RootFs update pending, verifying system"
14
+ echo " System update pending, verifying system..."
15
+ # TODO refactor once there are any common system checks:
16
+ # - call script from systemd right after app start (instead of delayed timer)
17
+ # - get pid of app
18
+ # - perform system checks
19
+ # - wait ~ 3 min
20
+ # - check if app is still running and has same pid (i.e. didn't get auto-restarted)
21
+
10
22
# Perform extra checks here.
11
23
# If anything went wrong, reboot again until the bootlimit is reached
12
24
# which triggers a rollback of the RootFs
25
+
26
+ # It's all good! Clear upgrade status and mark partition ok.
13
27
fw_setenv upgrade_available
14
28
fw_setenv bootcount 0
29
+ echo " System update successful. Marked current partition OK."
15
30
fi
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =Run bootcount reset check after app update script
3
+ RefuseManualStart =no
4
+ RefuseManualStop =no
5
+
6
+ [Service]
7
+ Type =oneshot
8
+ ExecStart =/etc/swupdate/reset-bootcount.sh
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description=Bootcount reset check after app update timer
3
+
4
+ [Timer]
5
+ OnBootSec=180
6
+
7
+ [Install]
8
+ WantedBy=multi-user.target
Original file line number Diff line number Diff line change @@ -3,9 +3,14 @@ Description=YIO remote app
3
3
After =display-init.service
4
4
5
5
[Service]
6
- Type =simple
6
+ Type =exec
7
7
ExecStart =/opt/yio/app-launch.sh
8
- RemainAfterExit =yes
8
+ # Force reboot if app failed to startup 2 times within 60 seconds
9
+ StartLimitIntervalSec =60
10
+ StartLimitBurst =2
11
+ Restart =always
12
+ RestartSec =1
13
+ StartLimitAction =reboot-force
9
14
10
15
[Install]
11
16
WantedBy =multi-user.target
Original file line number Diff line number Diff line change
1
+ ../app-update-bootcount.timer
Original file line number Diff line number Diff line change @@ -14,4 +14,5 @@ if [[ ! -d $YIO_APP_DIR ]] && [[ -d ${YIO_HOME}/app-previous ]]; then
14
14
mv ${YIO_HOME} /app-previous $YIO_APP_DIR
15
15
fi
16
16
17
- ${YIO_APP_DIR} /remote &
17
+ # Do not fork! Otherwise systemd unit service doesn't work anymore
18
+ ${YIO_APP_DIR} /remote
Original file line number Diff line number Diff line change 151
151
# Replace old backup with the current app version
152
152
# ------------------------------------------------------------------------------
153
153
log " Stopping remote app..."
154
- killall -9 remote >> $LOGFILE 2>&1 && sleep 2 || true
155
- # stopService app >> $LOGFILE 2>&1#
154
+ stopService app >> $LOGFILE 2>&1
156
155
157
156
# fbv -d 1 "${YIO_SPLASH_DIR}/update.png"
158
157
@@ -195,6 +194,4 @@ fbv -d 1 "${YIO_SPLASH_DIR}/splash.png"
195
194
# TODO rather reboot? If yes: it would be a good time to check & repair file systems
196
195
log " Update finished! Launching app..."
197
196
198
- # 'systemctl start app' doesn't work reliably!?
199
- # startService app
200
- $YIO_HOME /app-launch.sh >> /dev/null 2>&1
197
+ startService app
Original file line number Diff line number Diff line change 148
148
# ------------------------------------------------------------------------------
149
149
# Replace old backup with the current app version
150
150
# ------------------------------------------------------------------------------
151
- killall -9 remote >> $LOGFILE 2>&1 && sleep 2 || true
151
+ stopService app >> $LOGFILE 2>&1
152
152
153
153
if [[ -d $YIO_APP_DIR ]]; then
154
154
YIO_BACKUP=${YIO_HOME} /app-previous
@@ -189,4 +189,4 @@ log "Update finished! Launching app..."
189
189
190
190
fbv -d 1 " ${YIO_SPLASH_DIR} /splash.png"
191
191
192
- $YIO_HOME /app-launch.sh >> /dev/null 2>&1
192
+ startService app
You can’t perform that action at this time.
0 commit comments