about summary refs log tree commit diff
path: root/dracut/display-manager-autologin.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dracut/display-manager-autologin.sh')
-rw-r--r--dracut/display-manager-autologin.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/dracut/display-manager-autologin.sh b/dracut/display-manager-autologin.sh
new file mode 100644
index 0000000..53a6a43
--- /dev/null
+++ b/dracut/display-manager-autologin.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+USERNAME=$(getarg live.user)
+[ -z "$USERNAME" ] && USERNAME=anon
+
+# Configure GDM autologin
+if [ -d ${NEWROOT}/etc/gdm ]; then
+    GDMCustomFile=${NEWROOT}/etc/gdm/custom.conf
+    AutologinParameters="AutomaticLoginEnable=true\nAutomaticLogin=$USERNAME"
+
+    # Prevent from updating if parameters already present (persistent usb key)
+    if ! `grep -qs 'AutomaticLoginEnable' $GDMCustomFile` ; then
+        if ! `grep -qs '\[daemon\]' $GDMCustomFile` ; then
+            echo '[daemon]' >> $GDMCustomFile
+        fi
+        sed -i "s/\[daemon\]/\[daemon\]\n$AutologinParameters/" $GDMCustomFile
+    fi
+fi
+
+# Configure lightdm autologin.
+if [ -r ${NEWROOT}/etc/lightdm.conf ]; then
+    sed -i -e "s|^\#\(default-user=\).*|\1$USERNAME|" \
+        ${NEWROOT}/etc/lightdm.conf
+    sed -i -e "s|^\#\(default-user-timeout=\).*|\10|" \
+        ${NEWROOT}/etc/lightdm.conf
+fi
+
+# Configure lxdm autologin.
+if [ -r ${NEWROOT}/etc/lxdm/lxdm.conf ]; then
+    sed -i -e "s|^\#\# \(autologin=\).*|\1$USERNAME|" \
+        ${NEWROOT}/etc/lxdm/lxdm.conf
+fi