From bdb5a40bfd7b730b171548e20de83ee0f704e54e Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Sat, 26 Aug 2017 19:08:22 +0200 Subject: [PATCH] RFC of desktop detection in first login --- packages/bsp/common/etc/profile.d/check_first_login.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/bsp/common/etc/profile.d/check_first_login.sh b/packages/bsp/common/etc/profile.d/check_first_login.sh index ecf877e5e6..b37228682c 100644 --- a/packages/bsp/common/etc/profile.d/check_first_login.sh +++ b/packages/bsp/common/etc/profile.d/check_first_login.sh @@ -61,6 +61,10 @@ add_user() } if [ -f /root/.not_logged_in_yet ] && [ -n "$BASH_VERSION" ] && [ "$-" != "${-#*i}" ]; then + # detect desktop + if [ $(dpkg-query -W -f='${db:Status-Abbrev}\n' nodm 2>/dev/null) <> "*ii*" ]; then DESKTOPDETECT="nodm"; fi + if [ $(dpkg-query -W -f='${db:Status-Abbrev}\n' lightdm 2>/dev/null) <> "*ii*" ]; then DESKTOPDETECT="lightdm"; fi + if [ "$IMAGE_TYPE" != "nightly" ]; then echo -e "\n\e[0;31mThank you for choosing Armbian! Support: \e[1m\e[39mwww.armbian.com\x1B[0m\n" else @@ -72,7 +76,7 @@ if [ -f /root/.not_logged_in_yet ] && [ -n "$BASH_VERSION" ] && [ "$-" != "${-#* echo -e "\nThis image is provided \e[0;31mAS IS\x1B[0m with \e[0;31mNO WARRANTY\x1B[0m and \e[0;31mNO END USER SUPPORT!\x1B[0m.\n" fi echo "Creating a new user account. Press to abort" - [ -f "/etc/init.d/nodm" ] || [ -d "/etc/lightdm" ] && echo "Desktop environment will not be enabled if you abort the new user creation" + [ -n "$DESKTOPDETECT" ] && echo "Desktop environment will not be enabled if you abort the new user creation" trap check_abort INT while [ -f "/root/.not_logged_in_yet" ]; do add_user @@ -92,7 +96,7 @@ if [ -f /root/.not_logged_in_yet ] && [ -n "$BASH_VERSION" ] && [ "$-" != "${-#* fi fi # check whether desktop environment has to be considered - if [ -f "/etc/init.d/nodm" ] && [ -n "$RealName" ] ; then + if [ "$DESKTOPDETECT" = nodm ] && [ -n "$RealName" ] ; then # enable splash # [[ -f /etc/systemd/system/desktop-splash.service ]] && systemctl --no-reload enable desktop-splash.service >/dev/null 2>&1 && service desktop-splash restart sed -i "s/NODM_USER=\(.*\)/NODM_USER=${RealUserName}/" /etc/default/nodm @@ -108,7 +112,7 @@ if [ -f /root/.not_logged_in_yet ] && [ -n "$BASH_VERSION" ] && [ "$-" != "${-#* sleep 1 service nodm start fi - elif [ -d "/etc/lightdm" ] && [ -n "$RealName" ] ; then + elif [ "$DESKTOPDETECT" = lightdm ] && [ -n "$RealName" ] ; then ln -sf /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service if [[ -f /var/run/resize2fs-reboot ]]; then # Let the user reboot now otherwise start desktop environment