2020-03-04 09:35:06 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-10-17 16:13:06 +00:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
2019-04-01 14:51:55 +00: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 17:39:41 +00:00
|
|
|
set -eux
|
2019-04-01 14:51:55 +00:00
|
|
|
set -o pipefail
|
|
|
|
|
2023-05-16 16:50:43 +00:00
|
|
|
# Test unit configuration/state/cache/log/runtime data cleanup
|
|
|
|
|
2023-04-29 00:10:11 +00:00
|
|
|
cat >/run/systemd/system/test-service.service <<EOF
|
2019-04-01 14:51:55 +00:00
|
|
|
[Service]
|
2023-03-31 16:42:38 +00:00
|
|
|
ConfigurationDirectory=test-service
|
|
|
|
RuntimeDirectory=test-service
|
|
|
|
StateDirectory=test-service
|
|
|
|
CacheDirectory=test-service
|
|
|
|
LogsDirectory=test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
RuntimeDirectoryPreserve=yes
|
|
|
|
ExecStart=/bin/sleep infinity
|
|
|
|
Type=exec
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-service
|
|
|
|
test ! -e /run/test-service
|
|
|
|
test ! -e /var/lib/test-service
|
|
|
|
test ! -e /var/cache/test-service
|
|
|
|
test ! -e /var/log/test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl start test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test -d /etc/test-service
|
|
|
|
test -d /run/test-service
|
|
|
|
test -d /var/lib/test-service
|
|
|
|
test -d /var/cache/test-service
|
|
|
|
test -d /var/log/test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-04-05 13:50:42 +00:00
|
|
|
(! systemctl clean test-service)
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl stop test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test -d /etc/test-service
|
|
|
|
test -d /run/test-service
|
|
|
|
test -d /var/lib/test-service
|
|
|
|
test -d /var/cache/test-service
|
|
|
|
test -d /var/log/test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service --what=configuration
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-service
|
|
|
|
test -d /run/test-service
|
|
|
|
test -d /var/lib/test-service
|
|
|
|
test -d /var/cache/test-service
|
|
|
|
test -d /var/log/test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-service
|
|
|
|
test ! -e /run/test-service
|
|
|
|
test -d /var/lib/test-service
|
|
|
|
test ! -e /var/cache/test-service
|
|
|
|
test -d /var/log/test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service --what=logs
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-service
|
|
|
|
test ! -e /run/test-service
|
|
|
|
test -d /var/lib/test-service
|
|
|
|
test ! -e /var/cache/test-service
|
|
|
|
test ! -e /var/log/test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service --what=all
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-service
|
|
|
|
test ! -e /run/test-service
|
|
|
|
test ! -e /var/lib/test-service
|
|
|
|
test ! -e /var/cache/test-service
|
|
|
|
test ! -e /var/log/test-service
|
2019-04-01 14:51:55 +00:00
|
|
|
|
2023-04-29 00:10:11 +00:00
|
|
|
cat >/run/systemd/system/test-service.service <<EOF
|
2019-08-25 07:27:33 +00:00
|
|
|
[Service]
|
|
|
|
DynamicUser=yes
|
2023-03-31 16:42:38 +00:00
|
|
|
ConfigurationDirectory=test-service
|
|
|
|
RuntimeDirectory=test-service
|
|
|
|
StateDirectory=test-service
|
|
|
|
CacheDirectory=test-service
|
|
|
|
LogsDirectory=test-service
|
2019-08-25 07:27:33 +00:00
|
|
|
RuntimeDirectoryPreserve=yes
|
|
|
|
ExecStart=/bin/sleep infinity
|
|
|
|
Type=exec
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-service
|
|
|
|
test ! -e /run/test-service
|
|
|
|
test ! -e /var/lib/test-service
|
|
|
|
test ! -e /var/cache/test-service
|
|
|
|
test ! -e /var/log/test-service
|
|
|
|
|
|
|
|
systemctl restart test-service
|
|
|
|
|
|
|
|
test -d /etc/test-service
|
|
|
|
test -d /run/private/test-service
|
|
|
|
test -d /var/lib/private/test-service
|
|
|
|
test -d /var/cache/private/test-service
|
|
|
|
test -d /var/log/private/test-service
|
|
|
|
test -L /run/test-service
|
|
|
|
test -L /var/lib/test-service
|
|
|
|
test -L /var/cache/test-service
|
|
|
|
test -L /var/log/test-service
|
|
|
|
|
2023-04-05 13:50:42 +00:00
|
|
|
(! systemctl clean test-service)
|
2023-03-31 16:42:38 +00:00
|
|
|
|
|
|
|
systemctl stop test-service
|
|
|
|
|
|
|
|
test -d /etc/test-service
|
|
|
|
test -d /run/private/test-service
|
|
|
|
test -d /var/lib/private/test-service
|
|
|
|
test -d /var/cache/private/test-service
|
|
|
|
test -d /var/log/private/test-service
|
|
|
|
test -L /run/test-service
|
|
|
|
test -L /var/lib/test-service
|
|
|
|
test -L /var/cache/test-service
|
|
|
|
test -L /var/log/test-service
|
|
|
|
|
|
|
|
systemctl clean test-service --what=configuration
|
|
|
|
|
|
|
|
test ! -d /etc/test-service
|
|
|
|
test -d /run/private/test-service
|
|
|
|
test -d /var/lib/private/test-service
|
|
|
|
test -d /var/cache/private/test-service
|
|
|
|
test -d /var/log/private/test-service
|
|
|
|
test -L /run/test-service
|
|
|
|
test -L /var/lib/test-service
|
|
|
|
test -L /var/cache/test-service
|
|
|
|
test -L /var/log/test-service
|
|
|
|
|
|
|
|
systemctl clean test-service
|
|
|
|
|
|
|
|
test ! -d /etc/test-service
|
|
|
|
test ! -d /run/private/test-service
|
|
|
|
test -d /var/lib/private/test-service
|
|
|
|
test ! -d /var/cache/private/test-service
|
|
|
|
test -d /var/log/private/test-service
|
|
|
|
test ! -L /run/test-service
|
|
|
|
test -L /var/lib/test-service
|
|
|
|
test ! -L /var/cache/test-service
|
|
|
|
test -L /var/log/test-service
|
|
|
|
|
|
|
|
systemctl clean test-service --what=logs
|
|
|
|
|
|
|
|
test ! -d /etc/test-service
|
|
|
|
test ! -d /run/private/test-service
|
|
|
|
test -d /var/lib/private/test-service
|
|
|
|
test ! -d /var/cache/private/test-service
|
|
|
|
test ! -d /var/log/private/test-service
|
|
|
|
test ! -L /run/test-service
|
|
|
|
test -L /var/lib/test-service
|
|
|
|
test ! -L /var/cache/test-service
|
|
|
|
test ! -L /var/log/test-service
|
|
|
|
|
|
|
|
systemctl clean test-service --what=all
|
|
|
|
|
|
|
|
test ! -d /etc/test-service
|
|
|
|
test ! -d /run/private/test-service
|
|
|
|
test ! -d /var/lib/private/test-service
|
|
|
|
test ! -d /var/cache/private/test-service
|
|
|
|
test ! -d /var/log/private/test-service
|
|
|
|
test ! -L /run/test-service
|
|
|
|
test ! -L /var/lib/test-service
|
|
|
|
test ! -L /var/cache/test-service
|
|
|
|
test ! -L /var/log/test-service
|
2019-08-25 07:27:33 +00:00
|
|
|
|
2023-04-29 00:10:11 +00:00
|
|
|
cat >/run/systemd/system/tmp-hoge.mount <<EOF
|
2019-08-31 07:30:12 +00:00
|
|
|
[Mount]
|
|
|
|
What=tmpfs
|
|
|
|
Type=tmpfs
|
|
|
|
ConfigurationDirectory=hoge
|
|
|
|
RuntimeDirectory=hoge
|
|
|
|
StateDirectory=hoge
|
|
|
|
CacheDirectory=hoge
|
|
|
|
LogsDirectory=hoge
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -e /etc/hoge
|
|
|
|
test ! -e /run/hoge
|
|
|
|
test ! -e /var/lib/hoge
|
|
|
|
test ! -e /var/cache/hoge
|
|
|
|
test ! -e /var/log/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
|
|
|
|
systemctl start tmp-hoge.mount
|
|
|
|
|
|
|
|
test -d /etc/hoge
|
|
|
|
test -d /run/hoge
|
|
|
|
test -d /var/lib/hoge
|
|
|
|
test -d /var/cache/hoge
|
|
|
|
test -d /var/log/hoge
|
|
|
|
|
2023-04-05 13:50:42 +00:00
|
|
|
(! systemctl clean tmp-hoge.mount)
|
2019-08-31 07:30:12 +00:00
|
|
|
|
|
|
|
test -d /etc/hoge
|
|
|
|
test -d /run/hoge
|
|
|
|
test -d /var/lib/hoge
|
|
|
|
test -d /var/cache/hoge
|
|
|
|
test -d /var/log/hoge
|
|
|
|
|
|
|
|
systemctl stop tmp-hoge.mount
|
|
|
|
|
|
|
|
test -d /etc/hoge
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -d /run/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
test -d /var/lib/hoge
|
|
|
|
test -d /var/cache/hoge
|
|
|
|
test -d /var/log/hoge
|
|
|
|
|
|
|
|
systemctl clean tmp-hoge.mount --what=configuration
|
|
|
|
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -d /etc/hoge
|
|
|
|
test ! -d /run/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
test -d /var/lib/hoge
|
|
|
|
test -d /var/cache/hoge
|
|
|
|
test -d /var/log/hoge
|
|
|
|
|
|
|
|
systemctl clean tmp-hoge.mount
|
|
|
|
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -d /etc/hoge
|
|
|
|
test ! -d /run/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
test -d /var/lib/hoge
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -d /var/cache/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
test -d /var/log/hoge
|
|
|
|
|
|
|
|
systemctl clean tmp-hoge.mount --what=logs
|
|
|
|
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -d /etc/hoge
|
|
|
|
test ! -d /run/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
test -d /var/lib/hoge
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -d /var/cache/hoge
|
|
|
|
test ! -d /var/log/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
|
|
|
|
systemctl clean tmp-hoge.mount --what=all
|
|
|
|
|
2021-04-07 21:24:25 +00:00
|
|
|
test ! -d /etc/hoge
|
|
|
|
test ! -d /run/hoge
|
|
|
|
test ! -d /var/lib/hoge
|
|
|
|
test ! -d /var/cache/hoge
|
|
|
|
test ! -d /var/log/hoge
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-04-29 00:10:11 +00:00
|
|
|
cat >/run/systemd/system/test-service.socket <<EOF
|
2019-08-31 07:30:12 +00:00
|
|
|
[Socket]
|
2023-03-31 16:42:38 +00:00
|
|
|
ListenSequentialPacket=/run/test-service.socket
|
2019-08-31 07:30:12 +00:00
|
|
|
RemoveOnStop=yes
|
|
|
|
ExecStartPre=true
|
2023-03-31 16:42:38 +00:00
|
|
|
ConfigurationDirectory=test-socket
|
|
|
|
RuntimeDirectory=test-socket
|
|
|
|
StateDirectory=test-socket
|
|
|
|
CacheDirectory=test-socket
|
|
|
|
LogsDirectory=test-socket
|
2019-08-31 07:30:12 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-socket
|
|
|
|
test ! -e /run/test-socket
|
|
|
|
test ! -e /var/lib/test-socket
|
|
|
|
test ! -e /var/cache/test-socket
|
|
|
|
test ! -e /var/log/test-socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl start test-service.socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test -d /etc/test-socket
|
|
|
|
test -d /run/test-socket
|
|
|
|
test -d /var/lib/test-socket
|
|
|
|
test -d /var/cache/test-socket
|
|
|
|
test -d /var/log/test-socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-04-05 13:50:42 +00:00
|
|
|
(! systemctl clean test-service.socket)
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl stop test-service.socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test -d /etc/test-socket
|
|
|
|
test ! -d /run/test-socket
|
|
|
|
test -d /var/lib/test-socket
|
|
|
|
test -d /var/cache/test-socket
|
|
|
|
test -d /var/log/test-socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service.socket --what=configuration
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-socket
|
|
|
|
test ! -d /run/test-socket
|
|
|
|
test -d /var/lib/test-socket
|
|
|
|
test -d /var/cache/test-socket
|
|
|
|
test -d /var/log/test-socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service.socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-socket
|
|
|
|
test ! -e /run/test-socket
|
|
|
|
test -d /var/lib/test-socket
|
|
|
|
test ! -e /var/cache/test-socket
|
|
|
|
test -d /var/log/test-socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service.socket --what=logs
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-socket
|
|
|
|
test ! -e /run/test-socket
|
|
|
|
test -d /var/lib/test-socket
|
|
|
|
test ! -e /var/cache/test-socket
|
|
|
|
test ! -e /var/log/test-socket
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
systemctl clean test-service.socket --what=all
|
2019-08-31 07:30:12 +00:00
|
|
|
|
2023-03-31 16:42:38 +00:00
|
|
|
test ! -e /etc/test-socket
|
|
|
|
test ! -e /run/test-socket
|
|
|
|
test ! -e /var/lib/test-socket
|
|
|
|
test ! -e /var/cache/test-socket
|
|
|
|
test ! -e /var/log/test-socket
|