module-autologon.sh revision 346c5a85beb75755df96ed06b23c6613495cede0
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# Oracle VM VirtualBox
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# VirtualBox Linux Guest Additions installer - autologon module
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# Copyright (C) 2012 Oracle Corporation
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# available from http://www.virtualbox.org. This file is free software;
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# you can redistribute it and/or modify it under the terms of the GNU
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# General Public License (GPL) as published by the Free Software
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
346c5a85beb75755df96ed06b23c6613495cede0vboxsync# @todo Document functions and their usage!
346c5a85beb75755df96ed06b23c6613495cede0vboxsyncMOD_AUTOLOGON_DEFAULT_LIGHTDM_CONFIG="/etc/lightdm/lightdm.conf"
346c5a85beb75755df96ed06b23c6613495cede0vboxsyncMOD_AUTOLOGON_DEFAULT_LIGHTDM_GREETER_DIR="/usr/share/xgreeters"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync # Greeter directory. Defaults to /usr/share/xgreeters.
346c5a85beb75755df96ed06b23c6613495cede0vboxsync # LightDM config. Defaults to /etc/lightdm/lightdm.conf.
346c5a85beb75755df96ed06b23c6613495cede0vboxsync # Whether to force installation if non-compatible distribution
346c5a85beb75755df96ed06b23c6613495cede0vboxsync distros="Ubuntu UbuntuStudio Edubuntu Kubuntu Lubuntu Mythbuntu Xubuntu"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync ## @todo Move the distro check to a routine / globals as soon as
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Error: lsb_release not found (path set?), skipping auto-logon installation"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Error: Unsupported distribution \"$distro_name\" found, skipping auto-logon installation"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Warning: Unsupported distribution \"$distro_name\" found"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync echo | awk 'END { exit ( !('"$distro_ver >= 11.10"') ); }'
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Error: Version $distro_ver of \"$distro_name\" not supported, skipping auto-logon installation"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Warning: Unsupported \"$distro_name\" version $distro_ver found"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync # Install dependencies (lightdm and FLTK 1.3+) using apt-get.
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Error: apt-get not found (path set?), skipping auto-logon installation"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Checking and installing necessary dependencies ..."
346c5a85beb75755df96ed06b23c6613495cede0vboxsync apt-get -qqq -y install libfltk1.3 libfltk-images1.3 || return 1
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Error: LightDM config \"$lightdm_config\" not found (LightDM installed?), skipping auto-logon installation"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Error: Directory \"$greeter_dir\" does not exist, skipping auto-logon installation"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Warning: Directory \"$greeter_dir\" does not exist, creating it"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync # Link to required greeter files into $greeter_dir.
346c5a85beb75755df96ed06b23c6613495cede0vboxsync add_symlink "$INSTALLATION_DIR/share/VBoxGuestAdditions/vbox-greeter.desktop" "$greeter_dir/vbox-greeter.desktop"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync cp "$lightdm_config" "$lightdm_config.vbox-backup" || return 1
346c5a85beb75755df96ed06b23c6613495cede0vboxsync chmod 644 "$lightdm_config.vbox-backup" || return 1
346c5a85beb75755df96ed06b23c6613495cede0vboxsync sed -i -e 's/^\s*greeter-session\s*=.*/greeter-session=vbox-greeter/g' "$lightdm_config" || return 1
346c5a85beb75755df96ed06b23c6613495cede0vboxsync if [ -z "$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR" ]; then
346c5a85beb75755df96ed06b23c6613495cede0vboxsync MOD_AUTOLOGON_LIGHTDM_GREETER_DIR=$MOD_AUTOLOGON_DEFAULT_LIGHTDM_GREETER_DIR
346c5a85beb75755df96ed06b23c6613495cede0vboxsync MOD_AUTOLOGON_LIGHTDM_CONFIG=$MOD_AUTOLOGON_DEFAULT_LIGHTDM_CONFIG
346c5a85beb75755df96ed06b23c6613495cede0vboxsync mod_autologon_install_ex "$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR" "$MOD_AUTOLOGON_LIGHTDM_CONFIG" "$MOD_AUTOLOGON_FORCE"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync echo "Preparing to uninstall auto-logon support ..."
346c5a85beb75755df96ed06b23c6613495cede0vboxsync if test -f "$MOD_AUTOLOGON_LIGHTDM_CONFIG.vbox-backup"; then
346c5a85beb75755df96ed06b23c6613495cede0vboxsync mv "$MOD_AUTOLOGON_LIGHTDM_CONFIG.vbox-backup" "$MOD_AUTOLOGON_LIGHTDM_CONFIG"
346c5a85beb75755df96ed06b23c6613495cede0vboxsync info "Warning: Could not restore original LightDM config \"$MOD_AUTOLOGON_LIGHTDM_CONFIG\""
346c5a85beb75755df96ed06b23c6613495cede0vboxsync rm "$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR" 2>/dev/null
346c5a85beb75755df96ed06b23c6613495cede0vboxsyncMOD_AUTOLOGON_LIGHTDM_CONFIG='$MOD_AUTOLOGON_LIGHTDM_CONFIG'
346c5a85beb75755df96ed06b23c6613495cede0vboxsyncMOD_AUTOLOGON_LIGHTDM_GREETER_DIR='$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR'"