4 # Provides: EnforcePersonality
5 # RunBefore: UmountImage
6 # RunAfter: DeleteSSHKeys
7 # Short-Description: Inject files to the instance
13 . "@commondir@/common.sh"
15 if [ ! -d "$SNF_IMAGE_TARGET" ]; then
16 log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
19 if [ -z "$SNF_IMAGE_PERSONALITY" ]; then
20 warn "This image has no personality (0 files to inject)"
23 if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows" ]; then
24 echo "$SNF_IMAGE_PERSONALITY" |
25 @scriptsdir@/inject-files.py "$SNF_IMAGE_TARGET"
27 elif [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "linux" ]; then
28 tmpdir=$(chroot "$SNF_IMAGE_TARGET" mktemp -d)
29 add_cleanup rm -rf "$SNF_IMAGE_TARGET/$tmpdir"
30 echo "$SNF_IMAGE_PERSONALITY" |
31 @scriptsdir@/inject-files.py -d "$SNF_IMAGE_TARGET/$tmpdir"
33 while read -d $'\0' src; do
38 chroot "$SNF_IMAGE_TARGET" chown "$owner:$group" "$tmpdir/$src"
39 chroot "$SNF_IMAGE_TARGET" su -l "$owner" -c \
40 "umask 0007; install -D -m $mode $(printf "%q" "$tmpdir")/$src \
41 $(printf "%q" "$dest")"
43 } < "$SNF_IMAGE_TARGET/$tmpdir/manifest"
48 # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :