summaryrefslogtreecommitdiffstats
path: root/data/systemd/anaconda-generator
diff options
context:
space:
mode:
Diffstat (limited to 'data/systemd/anaconda-generator')
-rwxr-xr-xdata/systemd/anaconda-generator34
1 files changed, 34 insertions, 0 deletions
diff --git a/data/systemd/anaconda-generator b/data/systemd/anaconda-generator
new file mode 100755
index 000000000..654557278
--- /dev/null
+++ b/data/systemd/anaconda-generator
@@ -0,0 +1,34 @@
+#!/bin/bash
+# anaconda-generator: generate services needed for anaconda operation
+
+# set up dirs
+systemd_dir=/lib/systemd/system
+target_dir=$systemd_dir/anaconda.target.wants
+mkdir -p $target_dir
+
+# create symlink anaconda.target.wants/SERVICE@TTY.service
+service_on_tty() {
+ local service="$1" tty="$2"
+ local service_instance="${service/@.service/@$tty.service}"
+ ln -sf $systemd_dir/$service $target_dir/$service_instance
+}
+
+# find the real tty for /dev/console
+tty="console"
+while [ -f /sys/class/tty/$tty/active ]; do
+ tty=$(< /sys/class/tty/$tty/active)
+ tty=${tty##* } # last item in the list
+done
+consoletty="$tty"
+
+# put anaconda on the real console
+service_on_tty anaconda@.service $consoletty
+
+# put a shell on tty2 and the first virtualization console we find
+for tty in tty2 hvc0 hvc1 xvc0 hvsi0 hvsi1 hvsi2; do
+ [ "$tty" = "$consoletty" ] && continue
+ if [ -d /sys/class/tty/$tty ]; then
+ service_on_tty anaconda-shell@.service $tty
+ [ "$tty" != "tty2" ] && break
+ fi
+done