display-manager-autologin.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 lightdm autologin.
  20. if [ -r ${NEWROOT}/etc/lightdm.conf ]; then
  21. sed -i -e "s|^\#\(default-user=\).*|\1$USERNAME|" \
  22. ${NEWROOT}/etc/lightdm.conf
  23. sed -i -e "s|^\#\(default-user-timeout=\).*|\10|" \
  24. ${NEWROOT}/etc/lightdm.conf
  25. fi
  26. # Configure lxdm autologin.
  27. if [ -r ${NEWROOT}/etc/lxdm/lxdm.conf ]; then
  28. sed -e "s,.*autologin.*=.*,autologin=$USERNAME," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  29. if [ -x ${NEWROOT}/usr/bin/enlightenment_start ]; then
  30. sed -e "s,.*session.*=.*,session=/usr/bin/enlightenment_start," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  31. elif [ -x ${NEWROOT}/usr/bin/startxfce4 ]; then
  32. sed -e "s,.*session.*=.*,session=/usr/bin/startxfce4," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  33. elif [ -x ${NEWROOT}/usr/bin/mate-session ]; then
  34. sed -e "s,.*session.*=.*,session=/usr/bin/mate-session," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  35. elif [ -x ${NEWROOT}/usr/bin/cinnamon-session ]; then
  36. sed -e "s,.*session.*=.*,session=/usr/bin/cinnamon-session," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  37. elif [ -x ${NEWROOT}/usr/bin/i3 ]; then
  38. sed -e "s,.*session.*=.*,session=/usr/bin/i3," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  39. elif [ -x ${NEWROOT}/usr/bin/startlxde ]; then
  40. sed -e "s,.*session.*=.*,session=/usr/bin/startlxde," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  41. elif [ -x ${NEWROOT}/usr/bin/startlxqt ]; then
  42. sed -e "s,.*session.*=.*,session=/usr/bin/startlxqt," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  43. elif [ -x ${NEWROOT}/usr/bin/startfluxbox ]; then
  44. sed -e "s,.*session.*=.*,session=/usr/bin/startfluxbox," -i ${NEWROOT}/etc/lxdm/lxdm.conf
  45. fi
  46. fi