Skip to content
Permalink
Browse files

Implement support for remote updates via hawkBit

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  • Loading branch information
tpetazzoni committed Mar 9, 2020
1 parent a7d0c59 commit be6bfee80ceb3e43d19166e6f4e88309d57bb878
@@ -0,0 +1,60 @@
#!/bin/sh

DAEMON="swupdate"
PIDFILE="/var/run/$DAEMON.pid"

PART_STATUS=$(sgdisk -A 4:get:2 /dev/mmcblk0)
if test "${PART_STATUS}" = "4:2:1" ; then
ROOTFS=rootfs-2
else
ROOTFS=rootfs-1
fi

if test -f /update-ok ; then
SURICATTA_ARGS="-c 2"
rm -f /update-ok
fi

start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -q -m -S -p "$PIDFILE" -x "/usr/bin/$DAEMON" \
-- -f /etc/swupdate/swupdate.cfg -L -e rootfs,${ROOTFS} -u "${SURICATTA_ARGS}"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

stop() {
printf 'Stopping %s: ' "$DAEMON"
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

restart() {
stop
sleep 1
start
}

case "$1" in
start|stop|restart)
"$1";;
reload)
# Restart, since there is no true "reload" feature.
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
@@ -1,3 +1,16 @@
#!/bin/sh

PART_STATUS=$(sgdisk -A 4:get:2 /dev/mmcblk0)
if test "${PART_STATUS}" = "4:2:1" ; then
NEXT_ROOTFS=/dev/mmcblk0p5
else
NEXT_ROOTFS=/dev/mmcblk0p4
fi

# Add update marker
mount ${NEXT_ROOTFS} /mnt
touch /mnt/update-ok
umount /mnt

sgdisk -A 4:toggle:2 -A 5:toggle:2 /dev/mmcblk0
reboot
@@ -0,0 +1,11 @@
globals :
{
postupdatecmd = "/etc/swupdate/postupdate.sh";
};

suricatta :
{
tenant = "default";
id = "DEV001";
url = "http://192.168.42.1:8080";
};
@@ -0,0 +1,4 @@
CONFIG_BOOTLOADER_NONE=y
CONFIG_SURICATTA=y
CONFIG_WEBSERVER=y
CONFIG_RAW=y

0 comments on commit be6bfee

Please sign in to comment.
You can’t perform that action at this time.