Jan Kundrát | 1cfb198 | 2017-10-30 18:05:47 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | case "$1" in |
| 4 | slot-post-install) |
| 5 | case "$RAUC_SLOT_CLASS" in |
| 6 | cfg) |
Jan Kundrát | 68f98ad | 2019-11-01 20:18:04 +0100 | [diff] [blame] | 7 | # whitelist so that we don't copy cruft or lost+found |
| 8 | for ITEM in \ |
Jan Kundrát | 54ed52b | 2020-01-29 21:08:37 +0100 | [diff] [blame] | 9 | calibration \ |
Jan Kundrát | 68f98ad | 2019-11-01 20:18:04 +0100 | [diff] [blame] | 10 | etc \ |
Jan Kundrát | 1c6643e | 2019-11-01 19:39:34 +0100 | [diff] [blame] | 11 | journald-remote \ |
Jan Kundrát | 68f98ad | 2019-11-01 20:18:04 +0100 | [diff] [blame] | 12 | random-seed \ |
Jan Kundrát | 34d2f48 | 2021-01-11 19:24:09 +0100 | [diff] [blame] | 13 | sysrepo \ |
Jan Kundrát | 68f98ad | 2019-11-01 20:18:04 +0100 | [diff] [blame] | 14 | ssh-user-auth \ |
| 15 | ; do |
Jan Kundrát | 1c6643e | 2019-11-01 19:39:34 +0100 | [diff] [blame] | 16 | if [[ -d /cfg/${ITEM} || -f /cfg/${ITEM} ]]; then |
Jan Kundrát | 68f98ad | 2019-11-01 20:18:04 +0100 | [diff] [blame] | 17 | cp -a /cfg/${ITEM} ${RAUC_SLOT_MOUNT_POINT}/ |
Jan Kundrát | 2af054a | 2018-06-06 13:45:04 +0200 | [diff] [blame] | 18 | fi |
| 19 | done |
Jan Kundrát | 1cfb198 | 2017-10-30 18:05:47 +0100 | [diff] [blame] | 20 | ;; |
| 21 | *) |
| 22 | echo "Internal error: hook mismatched" |
| 23 | exit 11 |
| 24 | esac |
| 25 | ;; |
| 26 | *) |
| 27 | echo "Internal error: unrecognized hook" |
| 28 | exit 11 |
| 29 | ;; |
| 30 | esac |
| 31 | |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 32 | if [[ -f /lib/libsysrepo.so.0.7 ]]; then |
| 33 | # Updating from old sysrepo with incompatible repository layout |
| 34 | rm -rf ${RAUC_SLOT_MOUNT_POINT}/etc/sysrepo |
| 35 | # No more netopeer2-keystored, different config |
| 36 | rm -rf ${RAUC_SLOT_MOUNT_POINT}/etc/keystored |
| 37 | echo "sysrepo configuration not preserved" |
Jan Kundrát | 34d2f48 | 2021-01-11 19:24:09 +0100 | [diff] [blame] | 38 | elif [[ -d /cfg/etc/sysrepo ]]; then |
| 39 | # switch from "persisting whole /etc/sysrepo" to "exporting config via JSON" |
| 40 | rm -rf ${RAUC_SLOT_MOUNT_POINT}/etc/sysrepo |
| 41 | umask 0077 |
| 42 | mkdir ${RAUC_SLOT_MOUNT_POINT}/sysrepo |
| 43 | sysrepocfg -d startup -f json -X > ${RAUC_SLOT_MOUNT_POINT}/sysrepo/startup.json |
Jan Kundrát | 2f100fc | 2020-11-02 22:10:16 +0100 | [diff] [blame] | 44 | fi |
| 45 | |
Jan Kundrát | 1cfb198 | 2017-10-30 18:05:47 +0100 | [diff] [blame] | 46 | exit 0 |