Skip to content

Commit

Permalink
config: save previous firmware version on update
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Jul 27, 2024
1 parent b949f4a commit 62b7cb6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions openwrt/oob-packages/ffda-oob-firmware/files/uci-defaults.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh

PREVIOUS_FIRMWARE_VERSION="$(cat /lib/ffda-oob-firmware/configured)"
CURRENT_FIRMWARE_VERSION="$(cat /lib/ffda-oob-firmware/firmware-version)"

# Always overwrite authorized_keys
cp /lib/ffda-oob-firmware/conffiles/authorized_keys /etc/dropbear/authorized_keys

Expand Down Expand Up @@ -38,7 +41,7 @@ uci set system.@system[0].hostname="ffda-oob-$LABEL_MAC_NO_COLONS"
cp /lib/ffda-oob-firmware/banner.txt /etc/banner

# Replace %VERSION% in banner with current version
sed -i "s/%VERSION%/$(cat /lib/ffda-oob-firmware/firmware-version)/" /etc/banner
sed -i "s/%VERSION%/${CURRENT_FIRMWARE_VERSION}/" /etc/banner

# Add reboot-cronjob after 24 hours
echo "0 */24 * * * /sbin/reboot" > /etc/crontabs/root
Expand All @@ -47,6 +50,6 @@ echo "0 */24 * * * /sbin/reboot" > /etc/crontabs/root
passwd -l root

# Mark device as configured
touch /lib/ffda-oob-firmware/configured
echo "$CURRENT_FIRMWARE_VERSION" > /lib/ffda-oob-firmware/configured

exit 0

0 comments on commit 62b7cb6

Please sign in to comment.