display-manager-autologin.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
  3. # ex: ts=8 sw=4 sts=4 et filetype=sh
  4. type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
  5. USERNAME=$(getarg live.user)
  6. [ -z "$USERNAME" ] && USERNAME=anon
  7. # Configure GDM autologin
  8. if [ -d ${NEWROOT}/etc/gdm ]; then
  9. GDMCustomFile=${NEWROOT}/etc/gdm/custom.conf
  10. AutologinParameters="AutomaticLoginEnable=true\nAutomaticLogin=$USERNAME"
  11. # Prevent from updating if parameters already present (persistent usb key)
  12. if ! `grep -qs 'AutomaticLoginEnable' $GDMCustomFile` ; then
  13. if ! `grep -qs '\[daemon\]' $GDMCustomFile` ; then
  14. echo '[daemon]' >> $GDMCustomFile
  15. fi
  16. sed -i "s/\[daemon\]/\[daemon\]\n$AutologinParameters/" $GDMCustomFile
  17. fi
  18. fi
  19. # Configure sddm autologin for the kde iso.
  20. if [ -x ${NEWROOT}/usr/bin/sddm ]; then
  21. cat > ${NEWROOT}/etc/sddm.conf <<_EOF
  22. [Autologin]
  23. User=${USERNAME}
  24. Session=plasma.desktop
  25. _EOF
  26. fi
  27. # Configure lightdm autologin.
  28. if [ -r "${NEWROOT}/etc/lightdm/lightdm.conf" ]; then
  29. sed -i -e "s|^\#\(autologin-user=\).*|\1$USERNAME|" \
  30. "${NEWROOT}/etc/lightdm/lightdm.conf"
  31. sed -i -e "s|^\#\(autologin-user-timeout=\).*|\10|" \
  32. "${NEWROOT}/etc/lightdm/lightdm.conf"
  33. sed -i -e "s|^\#\(autologin-session=\).*|\1$(cat "${NEWROOT}/etc/lightdm/.session")|" \
  34. "${NEWROOT}/etc/lightdm/lightdm.conf"
  35. sed -i -e "s|^\#\(user-session=\).*|\1$(cat "${NEWROOT}/etc/lightdm/.session")|" \
  36. "${NEWROOT}/etc/lightdm/lightdm.conf"
  37. fi
  38. # Configure lxdm autologin.
  39. if [ -r ${NEWROOT}/etc/lxdm/lxdm.conf ]; then
  40. sed -e "s,.*autologin.*=.*,autologin=$USERNAME," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  41. if [ -x ${NEWROOT}/usr/bin/enlightenment_start ]; then
  42. sed -e "s,.*session.*=.*,session=/usr/bin/enlightenment_start," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  43. elif [ -x ${NEWROOT}/usr/bin/startxfce4 ]; then
  44. sed -e "s,.*session.*=.*,session=/usr/bin/startxfce4," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  45. elif [ -x ${NEWROOT}/usr/bin/mate-session ]; then
  46. sed -e "s,.*session.*=.*,session=/usr/bin/mate-session," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  47. elif [ -x ${NEWROOT}/usr/bin/cinnamon-session ]; then
  48. sed -e "s,.*session.*=.*,session=/usr/bin/cinnamon-session," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  49. elif [ -x ${NEWROOT}/usr/bin/i3 ]; then
  50. sed -e "s,.*session.*=.*,session=/usr/bin/i3," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  51. elif [ -x ${NEWROOT}/usr/bin/startlxde ]; then
  52. sed -e "s,.*session.*=.*,session=/usr/bin/startlxde," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  53. elif [ -x ${NEWROOT}/usr/bin/startlxqt ]; then
  54. sed -e "s,.*session.*=.*,session=/usr/bin/startlxqt," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  55. elif [ -x ${NEWROOT}/usr/bin/startfluxbox ]; then
  56. sed -e "s,.*session.*=.*,session=/usr/bin/startfluxbox," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  57. fi
  58. fi