]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-29.sh
Merge pull request #20303 from andir/sysconfig-example
[thirdparty/systemd.git] / test / units / testsuite-29.sh
1 #!/usr/bin/env bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 set -eux
5 set -o pipefail
6
7 export SYSTEMD_LOG_LEVEL=debug
8 mkdir -p /run/systemd/system/systemd-portabled.service.d/
9 cat <<EOF >/run/systemd/system/systemd-portabled.service.d/override.conf
10 [Service]
11 Environment=SYSTEMD_LOG_LEVEL=debug
12 EOF
13
14 portablectl attach --now --runtime /usr/share/minimal_0.raw app0
15
16 systemctl is-active app0.service
17 systemctl is-active app0-foo.service
18 set +o pipefail
19 set +e
20 systemctl is-active app0-bar.service && exit 1
21 set -e
22 set -o pipefail
23
24 portablectl reattach --now --runtime /usr/share/minimal_1.raw app0
25
26 systemctl is-active app0.service
27 systemctl is-active app0-bar.service
28 set +o pipefail
29 set +e
30 systemctl is-active app0-foo.service && exit 1
31 set -e
32 set -o pipefail
33
34 portablectl list | grep -q -F "minimal_1"
35
36 portablectl detach --now --runtime /usr/share/minimal_1.raw app0
37
38 portablectl list | grep -q -F "No images."
39
40 # portablectl also works with directory paths rather than images
41
42 unsquashfs -dest /tmp/minimal_0 /usr/share/minimal_0.raw
43 unsquashfs -dest /tmp/minimal_1 /usr/share/minimal_1.raw
44
45 portablectl attach --copy=symlink --now --runtime /tmp/minimal_0 app0
46
47 systemctl is-active app0.service
48 systemctl is-active app0-foo.service
49 set +o pipefail
50 set +e
51 systemctl is-active app0-bar.service && exit 1
52 set -e
53 set -o pipefail
54
55 portablectl reattach --now --enable --runtime /tmp/minimal_1 app0
56
57 systemctl is-active app0.service
58 systemctl is-active app0-bar.service
59 set +o pipefail
60 set +e
61 systemctl is-active app0-foo.service && exit 1
62 set -e
63 set -o pipefail
64
65 portablectl list | grep -q -F "minimal_1"
66
67 portablectl detach --now --enable --runtime /tmp/minimal_1 app0
68
69 portablectl list | grep -q -F "No images."
70
71 portablectl attach --now --runtime --extension /usr/share/app0.raw /usr/share/minimal_0.raw app0
72
73 systemctl is-active app0.service
74
75 portablectl reattach --now --runtime --extension /usr/share/app0.raw /usr/share/minimal_1.raw app0
76
77 systemctl is-active app0.service
78
79 portablectl detach --now --runtime --extension /usr/share/app0.raw /usr/share/minimal_1.raw app0
80
81 portablectl attach --now --runtime --extension /usr/share/app1.raw /usr/share/minimal_0.raw app1
82
83 systemctl is-active app1.service
84
85 portablectl reattach --now --runtime --extension /usr/share/app1.raw /usr/share/minimal_1.raw app1
86
87 systemctl is-active app1.service
88
89 portablectl detach --now --runtime --extension /usr/share/app1.raw /usr/share/minimal_1.raw app1
90
91 # portablectl also works with directory paths rather than images
92
93 mkdir /tmp/rootdir /tmp/app1 /tmp/overlay
94 mount /usr/share/app1.raw /tmp/app1
95 mount /usr/share/minimal_0.raw /tmp/rootdir
96 mount -t overlay overlay -o lowerdir=/tmp/app1:/tmp/rootdir /tmp/overlay
97
98 portablectl attach --copy=symlink --now --runtime /tmp/overlay app1
99
100 systemctl is-active app1.service
101
102 portablectl detach --now --runtime overlay app1
103
104 umount /tmp/overlay
105 umount /tmp/rootdir
106 umount /tmp/app1
107
108 echo OK >/testok
109
110 exit 0