diff --git a/server/modules/autologin/etc/systemd/system/autologin.service b/server/modules/autologin/etc/systemd/system/autologin.service new file mode 100644 index 0000000000000000000000000000000000000000..415c4c79132a2f82cc4a896c7d604b67188895b9 --- /dev/null +++ b/server/modules/autologin/etc/systemd/system/autologin.service @@ -0,0 +1,12 @@ +[Unit] +Description=Runs the OpenSLX Autologin Tool +After=tmp.target +Before=kdm.service +Wants=tmp.target +DefaultDependencies=no +ConditionPathIsMountPoint=/ + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-autologin +RemainAfterExit=yes diff --git a/server/modules/autologin/etc/systemd/system/multi-user.target.wants/autologin.service b/server/modules/autologin/etc/systemd/system/multi-user.target.wants/autologin.service new file mode 100644 index 0000000000000000000000000000000000000000..415c4c79132a2f82cc4a896c7d604b67188895b9 --- /dev/null +++ b/server/modules/autologin/etc/systemd/system/multi-user.target.wants/autologin.service @@ -0,0 +1,12 @@ +[Unit] +Description=Runs the OpenSLX Autologin Tool +After=tmp.target +Before=kdm.service +Wants=tmp.target +DefaultDependencies=no +ConditionPathIsMountPoint=/ + +[Service] +Type=oneshot +ExecStart=/opt/openslx/scripts/systemd-autologin +RemainAfterExit=yes diff --git a/server/modules/autologin/opt/openslx/scripts/systemd-autologin b/server/modules/autologin/opt/openslx/scripts/systemd-autologin new file mode 100755 index 0000000000000000000000000000000000000000..78bf2cf50ff6afdcc6eddbce3914de6168ed45db --- /dev/null +++ b/server/modules/autologin/opt/openslx/scripts/systemd-autologin @@ -0,0 +1,29 @@ +#!/bin/bash +# simple script for setting autologin on or off on display manager +# works for kdm +# SLX_AUTOLOGIN_ACTIVE is the flag which indicates if the computer should autologin or not +# SLX_AUTOLOGIN_USER is the username to autologin +# SLX_AUTOLOGIN_PASS is the user's password to autologin +# SLX_AUTOLOGIN_DELAY is the delay to autologin + +# dialog aux functions +perror () { + echo "ERROR: $@" 1>&2 + dialog --title "ERROR" --stdout --msgbox "$@" 15 60 + exit 1 +} + +. /opt/openslx/config || perror "Could not source config." + +kdm_file="/etc/kde4/kdm/kdmrc" +echo "[autologin] Updating AutoLoginEnable to $SLX_AUTOLOGIN_ACTIVE in $kdm_file" +sed -e 's/AutoLoginEnable=.*$/AutoLoginEnable='$SLX_AUTOLOGIN_ACTIVE'/g' $kdm_file > $kdm_file".tmp" && mv $kdm_file".tmp" $kdm_file +echo "[autologin] Updating AutoLoginDelay to $SLX_AUTOLOGIN_DELAY in $kdm_file" +sed -e 's/AutoLoginDelay=.*$/AutoLoginDelay='$SLX_AUTOLOGIN_DELAY'/g' $kdm_file > $kdm_file".tmp" && mv $kdm_file".tmp" $kdm_file +if [ $(cat $kdm_file | grep "AutoLoginUser") ]; then + echo "[autologin] Updating AutoLoginUser to $SLX_AUTOLOGIN_USER in $kdm_file" + sed -e 's/AutoLoginUser=.*$/AutoLoginUser='$SLX_AUTOLOGIN_USER'/g' $kdm_file > $kdm_file".tmp" && mv $kdm_file".tmp" $kdm_file +else + echo "[autologin] Creating AutoLoginUser as $SLX_AUTOLOGIN_USER in $kdm_file" + sed -e 's/AutoLoginEnable=.*$/AutoLoginEnable='$SLX_AUTOLOGIN_ACTIVE'\nAutoLoginUser='$SLX_AUTOLOGIN_USER'/g' $kdm_file > $kdm_file".tmp" && mv $kdm_file".tmp" $kdm_file +fi