customize_root_image.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/bin/bash
  2. ## post-install chroot customization script ##
  3. set -e -u
  4. source /root/customize_root_image-constants.inc
  5. LOG_CONFIG "timezone and locales"
  6. ln -sf /usr/share/zoneinfo/UTC /etc/localtime
  7. for locale in ${LOCALES} ; do sed -i "s/#${locale}/${locale}/" /etc/locale.gen ; done ;
  8. locale-gen
  9. LOG_CONFIG "sudo"
  10. chmod 750 /etc/sudoers.d
  11. chmod 440 /etc/sudoers.d/g_wheel
  12. LOG_CONFIG "pacman"
  13. [[ "${ISO_INIT}" == 'openrc' ]] && sed -i "$NONSYSTEMD_REGEX" /etc/pacman-online.conf
  14. [[ "${INSTALL_TYPE}" == 'Complete' ]] && cp /etc/pacman-offline.conf /etc/pacman.conf || \
  15. cp /etc/pacman-online.conf /etc/pacman.conf
  16. LOG_CONFIG "services"
  17. if [[ "${ISO_INIT}" == 'openrc' ]]
  18. then # delete files that are specific to other init systems
  19. rm ${OPENRC_DELETE_FILES}
  20. # enable services
  21. for service in ${OPENRC_SERVICES} ; do rc-update add ${service} default ; done ;
  22. # create the 'dbus' group and user if they do not exist
  23. if ! grep -q 'dbus' /etc/group ; then groupadd -g 81 dbus ; fi ;
  24. if ! grep -q 'dbus' /etc/passwd ; then useradd -r -s /sbin/nologin -u 81 -g 81 dbus ; fi ;
  25. elif [[ "${ISO_INIT}" == 'systemd' ]]
  26. then # delete files that are specific to other init systems
  27. rm ${SYSTEMD_DELETE_FILES}
  28. # enable services
  29. systemctl enable ${SYSTEMD_SERVICES}
  30. else echo "invalid \$ISO_INIT for services '${ISO_INIT}'"
  31. exit 1
  32. fi
  33. LOG_CONFIG "system defaults and root user"
  34. usermod -s ${DEFAULT_SHELL} root 2> /dev/null
  35. sed -i "s|PRETTY_NAME=.*|PRETTY_NAME=\"${OS_PRETTY_NAME}\"|" /usr/lib/os-release
  36. echo "VERSION=\"${OS_VERSION}\"" >> /usr/lib/os-release
  37. echo "VERSION_ID=\"${OS_VERSION_ID}\"" >> /usr/lib/os-release
  38. echo "VARIANT=\"${OS_VARIANT}\"" >> /usr/lib/os-release
  39. echo "VARIANT_ID=\"${OS_VARIANT_ID}\"" >> /usr/lib/os-release
  40. LOG_CONFIG "login session and live user"
  41. sed -i "s|_EDITION_TITLE_|${ISO_TITLE}|" /etc/motd
  42. sed -i "s|_NETWORK_MOTD_MSG_|${NETWORK_MOTD_MSG}|" /etc/motd
  43. sed -i "s|_ENABLE_TTS_BRLTTY_|${ENABLE_TTS_BRLTTY}|" /etc/skel/.bash_profile
  44. case "${ISO_WMDE}" in
  45. 'cli' ) # configure CLI login session
  46. cp ${ROOT_SKEL_FILES} /root/
  47. sed -i "s|_DESKTOP_SESSION_||" /root/.bash_profile
  48. ;;
  49. 'mini' ) # configure installer-only session
  50. cp ${ROOT_SKEL_FILES} /root/
  51. cp ${MINI_SKEL_FILES} /root/
  52. # sed -i "s|_DESKTOP_SESSION_|mini|" /root/.bash_profile
  53. sed -i "s|_DESKTOP_SESSION_||" /root/.bash_profile
  54. cat > /root/.gtkrc-2.0 << END
  55. gtk-theme-name="parabola-blackmate"
  56. gtk-icon-theme-name="Adwaita"
  57. gtk-font-name="Sans 10"
  58. gtk-cursor-theme-name="FlatbedCursors-Blue"
  59. gtk-cursor-theme-size=18
  60. END
  61. ;;
  62. * ) # configure GUI login session
  63. # configure live user
  64. [[ -n "$(id ${LIVE_USER} 2> /dev/null)" ]] && userdel -r ${LIVE_USER} 2> /dev/null
  65. useradd -m -p "" -g users -G "${LIVE_USER_GROUPS}" -s ${DEFAULT_SHELL} ${LIVE_USER}
  66. # configure auto-login
  67. case "${ISO_INIT}" in
  68. 'openrc' ) sed -i "s|--autologin root|--autologin ${LIVE_USER}|" /etc/conf.d/agetty.tty1 ;;
  69. 'systemd' ) sed -i "s|--autologin root|--autologin ${LIVE_USER}|" /etc/systemd/system/getty@tty1.service.d/autologin.conf ;;
  70. esac
  71. # configure desktop environment
  72. sed -i "s|/issue-tracker/|/isos/|" /home/${LIVE_USER}/Desktop/bug-tracker.desktop
  73. case "${ISO_WMDE}" in
  74. 'lxde' )
  75. rm -f /etc/xdg/autostart/octopi-notifier.desktop 2> /dev/null # FIXME: issue #1850
  76. for desktop_file in parabola-installer.desktop parabola-irc.desktop bug-tracker.desktop
  77. do sleep 2 ; touch /home/${LIVE_USER}/Desktop/${desktop_file} ; # sort
  78. done
  79. sed -i "s|_DESKTOP_SESSION_|LXDE|" /home/${LIVE_USER}/.bash_profile
  80. sed -i "s|_DESKTOP_SESSION_|LXDE|" /home/${LIVE_USER}/.dmrc
  81. ;;
  82. 'mate' )
  83. sed -i "s|_DESKTOP_SESSION_|mate|" /home/${LIVE_USER}/.bash_profile
  84. sed -i "s|_DESKTOP_SESSION_|mate|" /home/${LIVE_USER}/.dmrc
  85. ;;
  86. * )
  87. echo "unknown \$ISO_WMDE for _DESKTOP_SESSION_ '${ISO_WMDE}'"
  88. exit 1
  89. ;;
  90. esac
  91. # configure welcome news alert
  92. sed -i "s|_EDITION_TITLE_|${OS_PRETTY_NAME}| ; \
  93. s|,Don't show this again:0|| ; \
  94. s|620x460|620x520| " /usr/bin/autostart.sh
  95. ;;
  96. esac