Index: /trunk/src/VBox/Additions/linux/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/linux/Makefile.kmk	(revision 44141)
+++ /trunk/src/VBox/Additions/linux/Makefile.kmk	(revision 44142)
@@ -380,4 +380,5 @@
 	$(VBOX_REL_LNX_HOST_DRV)do_dkms \
 	$(VBOX_REL_LNX_INST_SRC)routines.sh \
+    $(VBOX_REL_LNX_ADD_INST)module-autologon.sh=>installer/module-autologon \
 	$(VBOX_REL_LNX_ADD_INST)vboxadd.sh=>vboxadd \
 	$(VBOX_REL_LNX_ADD_INST)vboxadd-service.sh=>vboxadd-service \
Index: /trunk/src/VBox/Additions/linux/installer/module-autologon.sh
===================================================================
--- /trunk/src/VBox/Additions/linux/installer/module-autologon.sh	(revision 44142)
+++ /trunk/src/VBox/Additions/linux/installer/module-autologon.sh	(revision 44142)
@@ -0,0 +1,169 @@
+# 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;
+# you can redistribute it and/or modify it under the terms of the GNU
+# 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!
+
+MOD_AUTOLOGON_DEFAULT_LIGHTDM_CONFIG="/etc/lightdm/lightdm.conf"
+MOD_AUTOLOGON_DEFAULT_LIGHTDM_GREETER_DIR="/usr/share/xgreeters"
+
+mod_autologon_init()
+{
+    echo "Initializing auto-logon support ..."
+    return 0
+}
+
+mod_autologon_install_ex()
+{
+    info "Installing auto-logon support ..."
+
+    ## Parameters:
+    # Greeter directory. Defaults to /usr/share/xgreeters.
+    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
+    if test "$?" -ne "0"; then
+        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
+        if test "$distro_name" = "$distro_cur"; then
+            distro_found="true"
+            break
+        fi
+    done
+
+    if test -z "$distro_found"; then
+        if ! test "$force" = "force"; then
+            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.
+        echo | awk 'END { exit ( !('"$distro_ver >= 11.10"') ); }'
+        if test "$?" -ne "0"; then
+            if ! test "$force" = "force"; then
+                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.
+    which apt-get &>/dev/null
+    if test "$?" -ne "0"; then
+        info "Error: apt-get not found (path set?), skipping auto-logon installation"
+        return 1
+    fi
+    info "Checking and installing necessary dependencies ..."
+    apt-get -qqq -y install libfltk1.3 libfltk-images1.3 || return 1
+    apt-get -qqq -y install lightdm || return 1
+
+    # Check for LightDM config.
+    if ! test -f "$lightdm_config"; then
+        info "Error: LightDM config \"$lightdm_config\" not found (LightDM installed?), skipping auto-logon installation"
+        return 1
+    fi 
+
+    # Check for /usr/share/xgreeters.
+    if ! test -d "$greeter_dir"; then
+        if ! test "$force" = "force"; then
+            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"
+        mkdir -p -m 755 "$greeter_dir" || return 1
+    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.
+    if ! test -f "$lightdm_config.vbox-backup"; then
+        info "Backing up LightDM configuration file ..."
+        cp "$lightdm_config" "$lightdm_config.vbox-backup" || return 1
+        chmod 644 "$lightdm_config.vbox-backup" || return 1
+    fi
+    sed -i -e 's/^\s*greeter-session\s*=.*/greeter-session=vbox-greeter/g' "$lightdm_config" || return 1
+    chmod 644 "$lightdm_config" || return 1
+
+    info "Auto-logon installation successful"
+    return 0
+}
+
+mod_autologon_install()
+{
+    if [ -z "$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR" ]; then
+        MOD_AUTOLOGON_LIGHTDM_GREETER_DIR=$MOD_AUTOLOGON_DEFAULT_LIGHTDM_GREETER_DIR
+    fi
+    if [ -z "$MOD_AUTOLOGON_LIGHTDM_CONFIG" ]; then
+        MOD_AUTOLOGON_LIGHTDM_CONFIG=$MOD_AUTOLOGON_DEFAULT_LIGHTDM_CONFIG
+    fi
+
+    mod_autologon_install_ex "$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR" "$MOD_AUTOLOGON_LIGHTDM_CONFIG" "$MOD_AUTOLOGON_FORCE"
+    return $?
+}
+
+mod_autologon_pre_uninstall()
+{
+    echo "Preparing to uninstall auto-logon support ..."
+    return 0
+}
+
+mod_autologon_uninstall()
+{
+    if test -z "$MOD_AUTOLOGON_LIGHTDM_CONFIG"; then
+        return 0
+    fi
+    info "Un-installing auto-logon support ..."
+
+    # Switch back to original greeter.
+    if test -f "$MOD_AUTOLOGON_LIGHTDM_CONFIG.vbox-backup"; then
+        mv "$MOD_AUTOLOGON_LIGHTDM_CONFIG.vbox-backup" "$MOD_AUTOLOGON_LIGHTDM_CONFIG"
+        if test "$?" -ne "0"; then
+            info "Warning: Could not restore original LightDM config \"$MOD_AUTOLOGON_LIGHTDM_CONFIG\""
+        fi 
+    fi
+
+    # Remove greeter directory (if not empty).
+    rm "$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR" 2>/dev/null
+
+    info "Auto-logon uninstallation successful"
+    return 0
+}
+
+mod_autologon_config_save()
+{
+    echo "
+MOD_AUTOLOGON_LIGHTDM_CONFIG='$MOD_AUTOLOGON_LIGHTDM_CONFIG'
+MOD_AUTOLOGON_LIGHTDM_GREETER_DIR='$MOD_AUTOLOGON_LIGHTDM_GREETER_DIR'"
+}
+
Index: /trunk/src/VBox/Installer/linux/routines.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/routines.sh	(revision 44141)
+++ /trunk/src/VBox/Installer/linux/routines.sh	(revision 44142)
@@ -622,116 +622,2 @@
 }
 
-install_autologon() {
-    info "Installing auto-logon support ..."
-
-    ## Parameters:
-    # Greeter directory. Defaults to /usr/share/xgreeters.
-    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
-    if test "$?" -ne "0"; then
-        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
-        if test "$distro_name" = "$distro_cur"; then
-            distro_found="true"
-            break
-        fi
-    done
-
-    if test -z "$distro_found"; then
-        if ! test "$force" = "force"; then
-            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.
-        echo | awk 'END { exit ( !('"$distro_ver >= 11.10"') ); }'
-        if test "$?" -ne "0"; then
-            if ! test "$force" = "force"; then
-                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.
-    which apt-get &>/dev/null
-    if test "$?" -ne "0"; then
-        info "Error: apt-get not found (path set?), skipping auto-logon installation"
-        return 1
-    fi
-    info "Checking and installing necessary dependencies ..."
-    apt-get -qqq -y install libfltk1.3 libfltk-images1.3 || return 1
-    apt-get -qqq -y install lightdm || return 1
-
-    # Check for LightDM config.
-    if ! test -f "$lightdm_config"; then
-        info "Error: LightDM config \"$lightdm_config\" not found (LightDM installed?), skipping auto-logon installation"
-        return 1
-    fi 
-
-    # Check for /usr/share/xgreeters.
-    if ! test -d "$greeter_dir"; then
-        if ! test "$force" = "force"; then
-            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"
-        mkdir -p -m 755 "$greeter_dir" || return 1
-    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.
-    if ! test -f "$lightdm_config.vbox-backup"; then
-        info "Backing up LightDM configuration file ..."
-        cp "$lightdm_config" "$lightdm_config.vbox-backup" || return 1
-        chmod 644 "$lightdm_config.vbox-backup" || return 1
-    fi
-    sed -i -e 's/^\s*greeter-session\s*=/greeter-sessio**n=vbox-greeter/g' "$lightdm_config" || return 1
-    chmod 644 "$lightdm_config" || return 1
-
-    info "Auto-logon installation successful"
-    return 0
-}
-
-remove_autologon() {
-    if test -z "$LIGHTDM_CONFIG"; then
-        return 0
-    fi
-    info "Un-installing auto-logon support ..."
-
-    # Switch back to original greeter.
-    if test -f "$LIGHTDM_CONFIG.vbox-backup"; then
-        mv "$LIGHTDM_CONFIG.vbox-backup" "$LIGHTDM_CONFIG"
-        if test "$?" -ne "0"; then
-            info "Warning: Could not restore original LightDM config \"$LIGHTDM_CONFIG\""
-        fi 
-    fi
-
-    # Remove greeter directory (if not empty).
-    rm "$LIGHTDM_GREETER_DIR" 2>/dev/null
-
-    return 0
-}
-
Index: /trunk/src/VBox/Installer/linux/run-inst.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/run-inst.sh	(revision 44141)
+++ /trunk/src/VBox/Installer/linux/run-inst.sh	(revision 44142)
@@ -24,4 +24,6 @@
 PATH=$PATH:/bin:/sbin:/usr/sbin
 
+set -xv
+
 # Note: These variable names must *not* clash with variables in $CONFIG_DIR/$CONFIG!
 PACKAGE="_PACKAGE_"
@@ -43,7 +45,4 @@
 LOGFILE="/var/log/$PACKAGE.log"
 
-INSTALLATION_LIGHTDM_CONFIG="/etc/lightdm/lightdm.conf"
-INSTALLATION_LIGHTDM_GREETER_DIR="/usr/share/xgreeters"
-
 . "./$ROUTINES"
 
@@ -57,5 +56,6 @@
 {
     info ""
-    info "Usage: $SELF install [<installation directory>] [--with-autologon] |"
+    info "Usage: $SELF install [<installation directory>]"
+    info "       [--enable <module>] |"
     info "       uninstall"
     info "       [--force] [--no-setup]"
@@ -153,6 +153,4 @@
     done
 
-    remove_autologon
-
     # Get rid of any remaining files
     for i in $DEFAULT_FILE_NAMES; do
@@ -201,60 +199,84 @@
 # Sensible default actions
 ACTION="install"
-WITH_AUTOLOGON=""
 DO_SETUP="true"
 NO_CLEANUP=""
 FORCE_UPGRADE=""
-while true
+
+while [ $# -ge 2 ];
 do
-    if [ "$2" = "" ]; then
-        break
+    ARG=$2
+    shift
+
+    if [ -z "$MY_END_OF_OPTIONS" ]; then
+        case "$ARG" in
+
+            install)
+                ACTION="install"
+                ;;
+
+            uninstall)
+                ACTION="uninstall"
+                ;;
+
+            ## @todo Add per-module options handling, e.g. --lightdm-greeter-dir
+             #       or --lightdm-config
+
+            --enable)
+                MODULE_CUR=$2
+                MODULE_CUR_PATH=$2
+                # Check if corresponding module in installer/module-$1 exists.
+                # Note: Module names may not contain spaces or other funny things.
+                if [ ! -f "./installer/module-${MODULE_CUR}" ]; then
+                    info "Error: Module \"${MODULE_CUR}\" does not exist."
+                    usage
+                fi
+                # Give the module the chance of doing initialization work / checks.
+                . "./installer/module-${MODULE_CUR}"
+                mod_${MODULE_CUR}_init
+                if test $? -ne 0; then
+                    echo 1>&2 "Module '${CUR_MODULE}' failed to initialize"
+                    if ! test "$FORCE_UPGRADE" = "force"; then
+                        return 1
+                    fi
+                    # Continue initialization.
+                fi
+                # Add module to the list of modules to handle later.
+                if test -z "${INSTALLATION_MODULES_LIST}"; then
+                    INSTALLATION_MODULES_LIST="${MODULE_CUR}"
+                else
+                    INSTALLATION_MODULES_LIST="${INSTALLATION_MODULES_LIST} ${MODULE_CUR}"
+                fi
+                shift
+                ;;
+
+            --force|force) # Keep "force" for backwards compatibility.
+                FORCE_UPGRADE="force"
+                ;;
+
+            --no-setup|no_setup) # Keep "no_setup" for backwards compatibility.
+                DO_SETUP=""
+                ;;
+
+            --no-cleanup|no_cleanup) # Keep "no_cleanup" for backwards compatibility.
+                # Do not do cleanup of old modules when removing them.  For
+                # testing purposes only.
+                DO_SETUP=""
+                NO_CLEANUP="no_cleanup"
+                ;;
+
+            --)
+                MY_END_OF_OPTIONS="1"
+                ;;
+
+            *)
+                if [ "`echo $1|cut -c1`" != "/" ]; then
+                    info "Please specify an absolute path"
+                    usage
+                fi
+                INSTALLATION_DIR="$1"
+                shift
+                ;;
+        esac
     fi
-    shift
-    case "$1" in
-        install)
-            ACTION="install"
-            ;;
-
-        uninstall)
-            ACTION="uninstall"
-            ;;
-
-        --lightdm-config)
-            INSTALLATION_LIGHTDM_CONFIG="$2"
-            shift
-            ;;
-
-        --lightdm-greeter-dir)
-            INSTALLATION_LIGHTDM_GREETER_DIR="$2"
-            shift
-            ;;
-
-        --with-autologon)
-            WITH_AUTOLOGON="true"
-            ;;
-
-        --force|force) # Keep "force" for backwards compatibility.
-            FORCE_UPGRADE="force"
-            ;;
-
-        --no-setup|no_setup) # Keep "no_setup" for backwards compatibility.
-            DO_SETUP=""
-            ;;
-
-        --no-cleanup|no_cleanup) # Keep "no_cleanup" for backwards compatibility.
-            # Do not do cleanup of old modules when removing them.  For
-            # testing purposes only.
-            DO_SETUP=""
-            NO_CLEANUP="no_cleanup"
-            ;;
-
-        *)
-            if [ "`echo $1|cut -c1`" != "/" ]; then
-                info "Please specify an absolute path"
-                usage
-            fi
-            INSTALLATION_DIR="$1"
-            ;;
-    esac
 done
 
@@ -274,4 +296,20 @@
 rmdir "$CONFIG_DIR" 2>/dev/null
 test "$ACTION" = "install" || exit 0
+
+# Set installer modules directory
+INSTALLATION_MODULES_DIR="$INSTALLATION_DIR/installer/"
+
+# install and load installer modules
+info "Copying additional installer modules ..."
+mkdir -p -m 755 "$INSTALLATION_MODULES_DIR"
+for CUR_FILE in installer/*; do
+    install -p -m 755 "$CUR_FILE" "$INSTALLATION_MODULES_DIR"
+    if [ $? -ne 0 ]; then
+        info "Error: Failed to copy installer module \"$CUR_FILE\""
+        if ! test "$FORCE_UPGRADE" = "force"; then
+            exit 1
+        fi        
+    fi
+done
 
 # install the new version
@@ -303,4 +341,21 @@
 link_into_fs "src" "/usr/src"
 
+info "Installing additional modules ..."
+for CUR_MODULE in $(find "$INSTALLATION_MODULES_DIR")
+    do
+        echo "$CUR_MODULE" >> "$CONFIG_DIR/$CONFIG_FILES"
+    done
+
+for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
+do
+    mod_${CUR_MODULE}_install
+    if [ $? -ne 0 ]; then
+        info "Error: Failed to install module \"$CUR_MODULE\""
+        if ! test "$FORCE_UPGRADE" = "force"; then
+            exit 1
+        fi        
+    fi
+done
+
 # Remember our installation configuration before we call any init scripts
 cat > "$CONFIG_DIR/$CONFIG" << EOF
@@ -308,4 +363,7 @@
 # Package installation directory
 INSTALL_DIR='$INSTALLATION_DIR'
+# Additional installation modules
+INSTALL_MODULES_DIR='$INSTALLATION_MODULES_DIR'
+INSTALL_MODULES_LIST='$INSTALLATION_MODULES_LIST'
 # Package uninstaller.  If you repackage this software, please make sure
 # that this prints a message and returns an error so that the default
@@ -319,8 +377,13 @@
 BUILD_TYPE='$BUILD_TYPE'
 USERNAME='$USERNAME'
-# LightDM greeter configuration
-LIGHTDM_CONFIG='$INSTALLATION_LIGHTDM_CONFIG'
-LIGHTDM_GREETER_DIR='$INSTALLATION_LIGHTDM_GREETER_DIR'
 EOF
+
+# Give the modules the chance to write their stuff
+# to the installation config as well.
+info "Saving modules configuration ..."
+for CUR_MODULE in ${INSTALLATION_MODULES_LIST}
+do
+    echo "$(mod_${CUR_MODULE}_config_save)" >> "$CONFIG_DIR/$CONFIG"
+done
 
 # Install, set up and start init scripts
@@ -372,4 +435,42 @@
     fi
 done
+
+# Load all modules
+# Important: This needs to be done before loading the configuration
+#            value below to not override values which are set to a default
+#            value in the modules itself.
+for CUR_MODULE in \$(find "$INSTALLATION_MODULES_DIR" -name "module-*")
+    do
+        . "\$CUR_MODULE"
+    done
+
+# Load configuration values
+test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
+
+# Call uninstallation initialization of all modules
+for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
+    do
+        if test -z "\$CUR_MODULE"; then
+            continue
+        fi
+        mod_\${CUR_MODULE}_pre_uninstall
+        if [ $? -ne 0 ]; then
+            echo 1>&2 "Module \"\$CUR_MODULE\" failed to initialize uninstallation"
+            # Continue initialization.
+        fi
+    done
+
+# Call uninstallation of all modules
+for CUR_MODULE in "$INSTALLATION_MODULES_LIST"
+    do
+        if test -z "\$CUR_MODULE"; then
+            continue
+        fi
+        mod_\${CUR_MODULE}_uninstall
+        if [ $? -ne 0 ]; then
+            echo 1>&2 "Module \"\$CUR_MODULE\" failed to uninstall"
+            # Continue uninstallation.
+        fi
+    done
 
 # And remove all files and empty installation directories
@@ -387,10 +488,4 @@
     done
 
-# Load configuration values
-test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
-
-# Remove auto-logon support
-remove_autologon
-
 # Remove configuration files
 rm "$CONFIG_DIR/$CONFIG_FILES" 2>/dev/null
@@ -404,8 +499,2 @@
   echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG_FILES"
 
-# Install auto-logon support.
-if test -n "$WITH_AUTOLOGON"; then
-    ## @todo Make parameters configurable thru command line.
-    install_autologon "$INSTALLATION_LIGHTDM_GREETER_DIR" "$INSTALLATION_LIGHTDM_CONFIG" "$FORCE_UPGRADE"
-fi
-
