Debian Codegraph @

tools/make-sysext

raw
1 #!/bin/sh
2 #
3 # Copyright (C) 2024 Red Hat, Inc.
4 # SPDX-License-Identifier: LGPL-2.1-or-later
5
6
7 # Build and install tree as systemd-sysext.
8 # See ../HACKING.MD section "Working on your local machine: systemd-sysext"
9
10 set -eu
11
12 SYSEXT_NAME="cockpit-git"
13 SYSEXT_DIR="/run/extensions/$SYSEXT_NAME"
14
15 build() {
16 rm -rf tmp/sysext
17 if [ ! -e Makefile ]; then
18 ./autogen.sh --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-debug --disable-dependency-tracking
19 fi
20 make install DESTDIR=tmp/sysext
21 install -D -m 644 $PAMFILE tmp/sysext/usr/lib/pam.d/cockpit
22 install -d tmp/sysext/usr/lib/extension-release.d
23 printf "ID=$ID\nVERSION_ID=$VERSION_ID\n" > tmp/sysext/usr/lib/extension-release.d/"extension-release.$SYSEXT_NAME"
24 }
25
26 stop() {
27 if systemctl is-active --quiet cockpit.socket; then
28 systemctl stop cockpit.socket
29 fi
30 if systemctl is-enabled --quiet cockpit.socket; then
31 systemctl disable cockpit.socket
32 fi
33 if [ -d $SYSEXT_DIR ]; then
34 rm -rf "$SYSEXT_DIR"
35 fi
36 if systemd-sysext --no-legend status | grep -qw "$SYSEXT_NAME"; then
37 systemd-sysext refresh
38 fi
39 }
40
41 if [ "${1:-}" = root-stop ]; then
42 stop
43 exit 0
44 fi
45
46 if [ "${1:-}" = install ]; then
47 stop
48 mkdir -p "$(dirname $SYSEXT_DIR)"
49 cp -r tmp/sysext "$SYSEXT_DIR"
50 systemd-sysext refresh
51
52 echo
53 systemd-sysext status --no-pager
54
55 systemctl start cockpit.socket
56 exit 0
57 fi
58
59 . /etc/os-release
60
61 case "$ID" in
62 # rolling release, no $VERSION_ID
63 arch) PAMFILE=tools/arch/cockpit.pam; VERSION_ID=latest ;;
64 fedora|centos|rhel|bazzite) PAMFILE=tools/cockpit.pam ;;
65 debian|ubuntu) PAMFILE=tools/cockpit.debian.pam ;;
66 *) echo "Unsupported distribution: $ID"; exit 1 ;;
67 esac
68
69 # build mode
70
71 # call ourselves in install mode
72 if [ "${1:-}" = "stop" ]; then
73 arg="root-stop"
74 else
75 build
76 arg="install"
77 fi
78
79 if systemd-detect-virt --quiet --container; then
80 flatpak-spawn --host run0 "$0" "$arg"
81 else
82 run0 "$0" "$arg"
83 fi