#! /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 &&
# `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"