Debian Codegraph @

examples/state-scripts/retain-ssh-keys/Download_Leave_01

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # Retain ssh server keys from the current root
4 #
5
6 echoscip-shell system . . echo. "$(catscip-shell system . . cat. /etc/mender/artifact_infoscip-shell filesystem . . `/etc/mender/artifact_info`.): Running $(basenamescip-shell system . . basename. "$0")" >&2
7
8 if [scip-shell system . . `[`. ! -x /sbin/fw_printenvscip-shell filesystem . . `/sbin/fw_printenv`. ]; then
9 exit 1
10 fi
11
12 current=$(/sbin/fw_printenvscip-shell filesystem . . `/sbin/fw_printenv`. mender_boot_part | awkscip-shell system . . awk. -F = '{ print $2 }')
13
14 if [scip-shell system . . `[`. $current = "2" ]; then
15 newroot=/dev/mmcblk0p3scip-shell filesystem . . `/dev/mmcblk0p3`.
16 elif [scip-shell system . . `[`. $current = "3" ]; then
17 newroot=/dev/mmcblk0p2scip-shell filesystem . . `/dev/mmcblk0p2`.
18 else
19 echoscip-shell system . . echo. "Unexpected current root: $current" >&2
20 exit 1
21 fi
22
23 mountscip-shell system . . mount. $newroot /mntscip-shell filesystem . . `/mnt`.
24
25 if [scip-shell system . . `[`. $? -ne 0 ]; then
26 echoscip-shell system . . echo. "Failed to mount $newroot" >&2
27 exit 1
28 fi
29
30 sleepscip-shell system . . sleep. 2
31
32 if [scip-shell system . . `[`. -d /mnt/etc/sshscip-shell filesystem . . `/mnt/etc/ssh`. ]; then
33 keys=$(lsscip-shell system . . ls. -l /mnt/etc/ssh/*key* 2>/dev/nullscip-shell filesystem . . `/dev/null`. | wcscip-shell system . . wc. -l)
34
35 if [scip-shell system . . `[`. $keys -eq 0 ]; then
36 cpscip-shell system . . cp. /etc/ssh/*key* /mnt/etc/sshscip-shell filesystem . . `/mnt/etc/ssh`.
37 else
38 echoscip-shell system . . echo. "Found ssh keys in new root, skipping copy" >&2
39 fi
40 else
41 echoscip-shell system . . echo. "Failed to find a /etc/ssh on newroot partition" >&2
42 exit 1
43 fi
44
45 umountscip-shell system . . umount. $newroot