fix regexp in prev commit (abs path)
[ardour.git] / tools / linux_packaging / stage2.run
index d43e86edd4a272a8ddf37670d1a746197221c390..effc97b63690e4814f91625853c44b7571b00c6b 100755 (executable)
@@ -14,7 +14,15 @@ PGM_NAME="Ardour"
 PGM_VENDOR="Ardour"
 PGM_EXEC_FILE="ardour3"
 
 PGM_VENDOR="Ardour"
 PGM_EXEC_FILE="ardour3"
 
-INSTALL_DEST_BASE="/opt"
+THE_SHELL="/bin/sh"
+
+if test -z "$INSTALL_DEST_BASE"; then
+       INSTALL_DEST_BASE="/opt"
+       CALL_MKDIR=1
+else
+       CALL_MKDIR=
+fi
+
 USER_BIN_DIR="/usr/local/bin"
 
 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
 USER_BIN_DIR="/usr/local/bin"
 
 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
@@ -113,21 +121,6 @@ echo "Welcome to the ${PGM_NAME} installer"
 echo ""
 echo "${PGM_NAME} will be installed for user ${USER_NAME} in ${INSTALL_DEST_BASE}"
 echo ""
 echo ""
 echo "${PGM_NAME} will be installed for user ${USER_NAME} in ${INSTALL_DEST_BASE}"
 echo ""
-
-###############################
-# Check for install destination
-###############################
-
-if [ ! -d ${INSTALL_DEST_BASE} ];
-then
-       echo ""
-       echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
-       echo "Installation will not complete."
-       echo ""
-       read -p "Press ENTER to exit installer:" BLAH
-       exit 1
-fi
-
 #############################
 # Check for root privileges
 #############################
 #############################
 # Check for root privileges
 #############################
@@ -144,7 +137,7 @@ if [ "$(id -u)" != "0" ]; then
                echo "Please enter root password below"
                echo ""
 
                echo "Please enter root password below"
                echo ""
 
-               if ! su -c "./.stage2.run";
+               if ! su -s $THE_SHELL -c "./.stage2.run";
                then
                        echo ""
                        echo "!!! ERROR !!!"
                then
                        echo ""
                        echo "!!! ERROR !!!"
@@ -153,12 +146,14 @@ if [ "$(id -u)" != "0" ]; then
                        echo "running as root AND an attempt to use su failed."
                        echo ""
                        echo "Please correct this by installing and configuring sudo or running"
                        echo "running as root AND an attempt to use su failed."
                        echo ""
                        echo "Please correct this by installing and configuring sudo or running"
-                       echo "the installer as root (su -c)."
+                       echo "the installer as root (su -s $THE_SHELL -c)."
                        echo ""
                        read -p "Press ENTER to exit installer:" BLAH
                        exit 1
                fi
                exit
                        echo ""
                        read -p "Press ENTER to exit installer:" BLAH
                        exit 1
                fi
                exit
+       else
+               sudo -k # make sudo forget about cached credentials
        fi
 
        if ! sudo date;
        fi
 
        if ! sudo date;
@@ -168,7 +163,7 @@ if [ "$(id -u)" != "0" ]; then
                echo "Please enter root password below"
                echo ""
 
                echo "Please enter root password below"
                echo ""
 
-               if ! su -c "./.stage2.run";
+               if ! su -s $THE_SHELL -c "./.stage2.run";
                then
                        echo ""
                        echo "!!! ERROR !!!"
                then
                        echo ""
                        echo "!!! ERROR !!!"
@@ -177,7 +172,7 @@ if [ "$(id -u)" != "0" ]; then
                        echo "running as root AND an attempt to use both sudo and su failed."
                        echo ""
                        echo "Please correct this by installing and configuring sudo or running"
                        echo "running as root AND an attempt to use both sudo and su failed."
                        echo ""
                        echo "Please correct this by installing and configuring sudo or running"
-                       echo "the installer as root (su -c)."
+                       echo "the installer as root (su -s $THE_SHELL -c)."
                        echo ""
                        read -p "Press ENTER to exit installer:" BLAH
                        exit 1
                        echo ""
                        read -p "Press ENTER to exit installer:" BLAH
                        exit 1
@@ -190,9 +185,28 @@ if [ "$(id -u)" != "0" ]; then
        # su. Using sh -c in the normal case gets around that, but is a bit of a hack.
        NORM_USER="sh -c"
 else
        # su. Using sh -c in the normal case gets around that, but is a bit of a hack.
        NORM_USER="sh -c"
 else
-       NORM_USER="su -l $USER_NAME -c" 
+       NORM_USER="su -l $USER_NAME -s $THE_SHELL -c" 
+fi
+
+###############################
+# Check for install destination
+###############################
+
+if test -n "$CALL_MKDIR"; then
+       ${SUPER} mkdir -p "$INSTALL_DEST_BASE"
+fi
+
+if [ ! -d ${INSTALL_DEST_BASE} ];
+then
+       echo ""
+       echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
+       echo "Installation will not complete."
+       echo ""
+       read -p "Press ENTER to exit installer:" BLAH
+       exit 1
 fi
 
 fi
 
+
 ############################
 # Determine processor type
 ############################
 ############################
 # Determine processor type
 ############################