]> git.phdru.name Git - ansible.git/commitdiff
Feat(debian/init-system): Init debian system with or w/o SystemD
authorOleg Broytman <phd@phdru.name>
Tue, 23 Dec 2025 13:26:54 +0000 (16:26 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 23 Dec 2025 13:26:54 +0000 (16:26 +0300)
playbooks/debian/init-system.sh

index 3a3ef1b7bbabdbe4184d81f89e25c7a82e29ad46..702c9f34e580a4ceedfe3e9bd184e7994bdaa826 100755 (executable)
@@ -1,14 +1,27 @@
 #! /bin/sh
 
-if [ -z "$1" ]; then
-   echo "Usage: $0 host [...params...]" >&2
+usage() {
+   echo "Usage: $0 -d|-D host [...params...]" >&2
    exit 1
+}
+
+if [ "$1" = '-d' ]; then
+    remove_systemd="$1"
+elif [ "$1" = '-D' ]; then
+    remove_systemd="$1"
+else
+    usage
+fi
+shift
+
+if [ -z "$1" ]; then
+    usage
 fi
 
 host="$1"
 shift
 
-ssh root@$host exec adduser phd
+ssh root@$host exec adduser phd  # Ignore error: may already be created
 # Passwordless access isn't configured yet; use `ssh` connection sharing.
 ssh phd@$host exit &&
 
@@ -17,5 +30,7 @@ cd "`dirname \"$0\"`" &&
 # `sudo` isn't configured yet too; use `su` and ask for root password.
 ansible-playbook ../init-system.yaml "$@" -e hosts="$host" \
    --become-method=su -K &&
-../run-roles debian/remove-systemd "$@" -e hosts="$host" &&
+if [ "$remove_systemd" = '-D' ]; then
+    ../run-roles debian/remove-systemd "$@" -e hosts="$host"
+fi &&
 exec ansible-playbook ../init-system2.yaml "$@" -e hosts="$host"