]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - test/units/testsuite-29.sh
Merge pull request #20303 from andir/sysconfig-example
[thirdparty/systemd.git] / test / units / testsuite-29.sh
index 5abdb53eb31cdba5f8b3a7e8bc0ee53067d335fd..77bb6db15a70944cc50639ecdbc032af3c4c1f04 100755 (executable)
 #!/usr/bin/env bash
-set -ex
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+set -eux
 set -o pipefail
 
-mkdir -p /run/udev/rules.d/
+export SYSTEMD_LOG_LEVEL=debug
+mkdir -p /run/systemd/system/systemd-portabled.service.d/
+cat <<EOF >/run/systemd/system/systemd-portabled.service.d/override.conf
+[Service]
+Environment=SYSTEMD_LOG_LEVEL=debug
+EOF
 
-cat > /run/udev/rules.d/50-testsuite.rules <<EOF
-ACTION=="remove", GOTO="lo_end"
+portablectl attach --now --runtime /usr/share/minimal_0.raw app0
 
-SUBSYSTEM=="net", KERNEL=="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/net/devices/lo"
+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
 
-ACTION!="change", GOTO="lo_end"
+portablectl reattach --now --runtime /usr/share/minimal_1.raw app0
 
-SUBSYSTEM=="net", KERNEL=="lo", ENV{ID_RENAMING}="1"
+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
 
-LABEL="lo_end"
-EOF
+portablectl list | grep -q -F "minimal_1"
+
+portablectl detach --now --runtime /usr/share/minimal_1.raw app0
+
+portablectl list | grep -q -F "No images."
+
+# portablectl also works with directory paths rather than images
+
+unsquashfs -dest /tmp/minimal_0 /usr/share/minimal_0.raw
+unsquashfs -dest /tmp/minimal_1 /usr/share/minimal_1.raw
+
+portablectl attach --copy=symlink --now --runtime /tmp/minimal_0 app0
+
+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
+
+portablectl list | grep -q -F "minimal_1"
+
+portablectl detach --now --enable --runtime /tmp/minimal_1 app0
+
+portablectl list | grep -q -F "No images."
+
+portablectl attach --now --runtime --extension /usr/share/app0.raw /usr/share/minimal_0.raw app0
+
+systemctl is-active app0.service
+
+portablectl reattach --now --runtime --extension /usr/share/app0.raw /usr/share/minimal_1.raw app0
+
+systemctl is-active app0.service
+
+portablectl detach --now --runtime --extension /usr/share/app0.raw /usr/share/minimal_1.raw app0
+
+portablectl attach --now --runtime --extension /usr/share/app1.raw /usr/share/minimal_0.raw app1
+
+systemctl is-active app1.service
+
+portablectl reattach --now --runtime --extension /usr/share/app1.raw /usr/share/minimal_1.raw app1
+
+systemctl is-active app1.service
+
+portablectl detach --now --runtime --extension /usr/share/app1.raw /usr/share/minimal_1.raw app1
+
+# portablectl also works with directory paths rather than images
+
+mkdir /tmp/rootdir /tmp/app1 /tmp/overlay
+mount /usr/share/app1.raw /tmp/app1
+mount /usr/share/minimal_0.raw /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
 
-udevadm control --log-priority=debug --reload --timeout=600
-udevadm trigger --action=add --settle /sys/devices/virtual/net/lo
-udevadm info /sys/devices/virtual/net/lo
-sleep 1
-STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
-[[ $STATE == "active" ]] || exit 1
-
-udevadm trigger --action=change --settle /sys/devices/virtual/net/lo
-udevadm info /sys/devices/virtual/net/lo
-sleep 1
-STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
-[[ $STATE == "inactive" ]] || exit 1
-
-udevadm trigger --action=move --settle /sys/devices/virtual/net/lo
-udevadm info /sys/devices/virtual/net/lo
-sleep 1
-STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
-[[ $STATE == "active" ]] || exit 1
-
-rm -f /run/udev/rules.d/50-testsuite.rules
-udevadm control --reload --timeout=600
-
-echo OK > /testok
+echo OK >/testok
 
 exit 0