blob: 33d420ab9c6957dc4583757ba4bfb5565aa621b4 [file] [log] [blame]
Jan Kundrát1cfb1982017-10-30 18:05:47 +01001#!/bin/sh
2
3case "$1" in
4 slot-post-install)
5 case "$RAUC_SLOT_CLASS" in
6 cfg)
Jan Kundrát68f98ad2019-11-01 20:18:04 +01007 # whitelist so that we don't copy cruft or lost+found
8 for ITEM in \
Jan Kundrát54ed52b2020-01-29 21:08:37 +01009 calibration \
Jan Kundrát68f98ad2019-11-01 20:18:04 +010010 etc \
Jan Kundrát1c6643e2019-11-01 19:39:34 +010011 journald-remote \
Jan Kundrát13541652021-03-24 22:24:18 +010012 network \
Jan Kundrát68f98ad2019-11-01 20:18:04 +010013 random-seed \
Jan Kundrát34d2f482021-01-11 19:24:09 +010014 sysrepo \
Jan Kundrát68f98ad2019-11-01 20:18:04 +010015 ssh-user-auth \
16 ; do
Jan Kundrát1c6643e2019-11-01 19:39:34 +010017 if [[ -d /cfg/${ITEM} || -f /cfg/${ITEM} ]]; then
Jan Kundrát68f98ad2019-11-01 20:18:04 +010018 cp -a /cfg/${ITEM} ${RAUC_SLOT_MOUNT_POINT}/
Jan Kundrát2af054a2018-06-06 13:45:04 +020019 fi
20 done
Jan Kundrát1cfb1982017-10-30 18:05:47 +010021 ;;
22 *)
23 echo "Internal error: hook mismatched"
24 exit 11
25 esac
26 ;;
27 *)
28 echo "Internal error: unrecognized hook"
29 exit 11
30 ;;
31esac
32
Jan Kundrát2f100fc2020-11-02 22:10:16 +010033if [[ -f /lib/libsysrepo.so.0.7 ]]; then
34 # Updating from old sysrepo with incompatible repository layout
35 rm -rf ${RAUC_SLOT_MOUNT_POINT}/etc/sysrepo
36 # No more netopeer2-keystored, different config
37 rm -rf ${RAUC_SLOT_MOUNT_POINT}/etc/keystored
38 echo "sysrepo configuration not preserved"
Jan Kundrát34d2f482021-01-11 19:24:09 +010039elif [[ -d /cfg/etc/sysrepo ]]; then
40 # switch from "persisting whole /etc/sysrepo" to "exporting config via JSON"
41 rm -rf ${RAUC_SLOT_MOUNT_POINT}/etc/sysrepo
42 umask 0077
43 mkdir ${RAUC_SLOT_MOUNT_POINT}/sysrepo
44 sysrepocfg -d startup -f json -X > ${RAUC_SLOT_MOUNT_POINT}/sysrepo/startup.json
Jan Kundrát2f100fc2020-11-02 22:10:16 +010045fi
46
Jan Kundrát1cfb1982017-10-30 18:05:47 +010047exit 0