blob: afbab6e081ba36a4ddf73041743ec7a308494a60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# -*- bash -*-
#
# BATS helpers for systemd-related functionality
#
# podman initializes this if unset, but systemctl doesn't
if [ -z "$XDG_RUNTIME_DIR" ]; then
if is_rootless; then
export XDG_RUNTIME_DIR=/run/user/$(id -u)
fi
fi
# For tests which write systemd unit files
UNIT_DIR="/run/systemd/system"
_DASHUSER=
if is_rootless; then
UNIT_DIR="${XDG_RUNTIME_DIR}/systemd/user"
# Why isn't systemd smart enough to figure this out on its own?
_DASHUSER="--user"
fi
mkdir -p $UNIT_DIR
systemctl() {
command systemctl $_DASHUSER "$@"
}
journalctl() {
command journalctl $_DASHUSER "$@"
}
systemd-run() {
command systemd-run $_DASHUSER "$@";
}
install_kube_template() {
# If running from a podman source directory, build and use the source
# version of the play-kube-@ unit file
unit_name="podman-kube@.service"
unit_file="contrib/systemd/system/${unit_name}"
if [[ -e ${unit_file}.in ]]; then
echo "# [Building & using $unit_name from source]" >&3
# Force regenerating unit file (existing one may have /usr/bin path)
rm -f $unit_file
BINDIR=$(dirname $PODMAN) make $unit_file
cp $unit_file $UNIT_DIR/$unit_name
fi
}
|