2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-03-05 12:36:04 +03:00
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
2021-04-09 20:39:41 +03:00
set -eux
2019-03-07 08:47:43 +03:00
set -o pipefail
2021-03-05 12:36:04 +03:00
export SYSTEMD_LOG_LEVEL = debug
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
portablectl attach --now --runtime /usr/share/minimal_0.raw app0
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
systemctl is-active app0.service
systemctl is-active app0-foo.service
set +o pipefail
set +e
systemctl is-active app0-bar.service && exit 1
set -e
set -o pipefail
portablectl reattach --now --runtime /usr/share/minimal_1.raw app0
systemctl is-active app0.service
systemctl is-active app0-bar.service
set +o pipefail
set +e
systemctl is-active app0-foo.service && exit 1
set -e
set -o pipefail
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
portablectl list | grep -q -F "minimal_1"
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
portablectl detach --now --runtime /usr/share/minimal_1.raw app0
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
portablectl list | grep -q -F "No images."
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
# portablectl also works with directory paths rather than images
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
unsquashfs -dest /tmp/minimal_0 /usr/share/minimal_0.raw
unsquashfs -dest /tmp/minimal_1 /usr/share/minimal_1.raw
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
portablectl attach --copy= symlink --now --runtime /tmp/minimal_0 app0
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
systemctl is-active app0.service
systemctl is-active app0-foo.service
set +o pipefail
set +e
systemctl is-active app0-bar.service && exit 1
set -e
set -o pipefail
portablectl reattach --now --enable --runtime /tmp/minimal_1 app0
systemctl is-active app0.service
systemctl is-active app0-bar.service
set +o pipefail
set +e
systemctl is-active app0-foo.service && exit 1
set -e
set -o pipefail
2019-03-07 08:47:43 +03:00
2021-03-05 12:36:04 +03:00
portablectl list | grep -q -F "minimal_1"
2020-09-14 09:44:30 +03:00
2021-03-05 12:36:04 +03:00
portablectl detach --now --enable --runtime /tmp/minimal_1 app0
2020-09-14 09:44:30 +03:00
2021-03-05 12:36:04 +03:00
portablectl list | grep -q -F "No images."
2020-09-14 09:44:30 +03:00
2020-06-23 15:09:42 +03:00
root = "/usr/share/minimal_0.raw"
app1 = "/usr/share/app1.raw"
portablectl attach --now --runtime --extension ${ app1 } ${ root } app1
systemctl is-active app1.service
portablectl reattach --now --runtime --extension ${ app1 } ${ root } app1
systemctl is-active app1.service
portablectl detach --now --runtime --extension ${ app1 } ${ root } app1
# portablectl also works with directory paths rather than images
mkdir /tmp/rootdir /tmp/app1 /tmp/overlay
mount ${ app1 } /tmp/app1
mount ${ root } /tmp/rootdir
mount -t overlay overlay -o lowerdir = /tmp/app1:/tmp/rootdir /tmp/overlay
portablectl attach --copy= symlink --now --runtime /tmp/overlay app1
systemctl is-active app1.service
portablectl detach --now --runtime overlay app1
umount /tmp/overlay
umount /tmp/rootdir
umount /tmp/app1
2021-04-08 01:09:55 +03:00
echo OK >/testok
2019-03-07 08:47:43 +03:00
exit 0