module-autologon.sh revision 346c5a85beb75755df96ed06b23c6613495cede0
# Oracle VM VirtualBox
# VirtualBox Linux Guest Additions installer - autologon module
#
# Copyright (C) 2012 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# @todo Document functions and their usage!
{
echo "Initializing auto-logon support ..."
return 0
}
{
info "Installing auto-logon support ..."
## Parameters:
greeter_dir="$1"
# LightDM config. Defaults to /etc/lightdm/lightdm.conf.
lightdm_config="$2"
# Whether to force installation if non-compatible distribution
# is detected.
force="$3"
# Check for Ubuntu and derivates. @todo Debian?
distros="Ubuntu UbuntuStudio Edubuntu Kubuntu Lubuntu Mythbuntu Xubuntu"
## @todo Map Linux Mint versions to Ubuntu ones.
## @todo Move the distro check to a routine / globals as soon as
## we have other distribution-dependent stuff.
which lsb_release &>/dev/null
info "Error: lsb_release not found (path set?), skipping auto-logon installation"
return 1
fi
distro_name=$(lsb_release -si)
distro_ver=$(lsb_release -sr)
for distro_cur in ${distros}; do
distro_found="true"
break
fi
done
info "Error: Unsupported distribution \"$distro_name\" found, skipping auto-logon installation"
return 1
fi
info "Warning: Unsupported distribution \"$distro_name\" found"
else
# Do we have Ubuntu 11.10 or greater?
# Use AWK for comparison since we run on plan sh.
info "Error: Version $distro_ver of \"$distro_name\" not supported, skipping auto-logon installation"
return 1
fi
info "Warning: Unsupported \"$distro_name\" version $distro_ver found"
fi
fi
# Install dependencies (lightdm and FLTK 1.3+) using apt-get.
info "Error: apt-get not found (path set?), skipping auto-logon installation"
return 1
fi
info "Checking and installing necessary dependencies ..."
# Check for LightDM config.
info "Error: LightDM config \"$lightdm_config\" not found (LightDM installed?), skipping auto-logon installation"
return 1
fi
info "Error: Directory \"$greeter_dir\" does not exist, skipping auto-logon installation"
return 1
fi
info "Warning: Directory \"$greeter_dir\" does not exist, creating it"
fi
# Link to required greeter files into $greeter_dir.
add_symlink "$INSTALLATION_DIR/share/VBoxGuestAdditions/vbox-greeter.desktop" "$greeter_dir/vbox-greeter.desktop"
# Backup and activate greeter config.
info "Backing up LightDM configuration file ..."
fi
sed -i -e 's/^\s*greeter-session\s*=.*/greeter-session=vbox-greeter/g' "$lightdm_config" || return 1
info "Auto-logon installation successful"
return 0
}
{
fi
fi
mod_autologon_install_ex "$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR" "$MOD_AUTOLOGON_LIGHTDM_CONFIG" "$MOD_AUTOLOGON_FORCE"
return $?
}
{
echo "Preparing to uninstall auto-logon support ..."
return 0
}
{
return 0
fi
info "Un-installing auto-logon support ..."
# Switch back to original greeter.
mv "$MOD_AUTOLOGON_LIGHTDM_CONFIG.vbox-backup" "$MOD_AUTOLOGON_LIGHTDM_CONFIG"
info "Warning: Could not restore original LightDM config \"$MOD_AUTOLOGON_LIGHTDM_CONFIG\""
fi
fi
# Remove greeter directory (if not empty).
info "Auto-logon uninstallation successful"
return 0
}
{
echo "
MOD_AUTOLOGON_LIGHTDM_CONFIG='$MOD_AUTOLOGON_LIGHTDM_CONFIG'
MOD_AUTOLOGON_LIGHTDM_GREETER_DIR='$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR'"
}