[Title] InstallManager can support 'tsudo' command as ${TSUDO} for
authoryongsung1.kim <yongsung1.kim@samsung.com>
Tue, 9 Jul 2013 08:21:09 +0000 (17:21 +0900)
committeryongsung1.kim <yongsung1.kim@samsung.com>
Tue, 9 Jul 2013 08:21:09 +0000 (17:21 +0900)
install and remove script of package.
[Desc.]
[Issue] redmine #9685

Change-Id: I4f31a97ab4e88a9670c7b77823996b809cbc63b4

InstallManager_java/src/res/desktop_directory/tsudo.sh

index a876e24..564ef21 100755 (executable)
@@ -32,15 +32,36 @@ case $INSTALLMANAGER_UI in
                if [ "$INTERACTIVE" = "true" ] ; then
                        sudo $cmd
                else
-                       expect -c "spawn sudo ls" \
-                               -c "expect -re \"assword\"" \
-                               -c "send \"$SUPASS\n\"" \
-                               -c "interact"
+
+                       cat > tsudo_cmd << EOF
+#!/usr/bin/expect --
+set timeout 10
+spawn sh -c "sudo -S ${cmd};echo \$? > exit_status"
+expect {
+       "password for" {
+               send "${SUPASS}\r"
+               exp_continue
+       } eof {
+               return
+       }
+}
+interact
+EOF
+                       chmod +x ./tsudo_cmd
+                       ./tsudo_cmd
+                       EXIT_CODE=`cat exit_status`
+                       if [ "x${EXIT_CODE}" != "x0" ]; then
+                               rm exit_status
+                               exit 1;
+                       else
+                               rm exit_status
+                               exit 0;
+                       fi
                fi
                ;;
        *)
                echo "fail: $INSTALLMANAGER_UI $INTERACTIVE"
+               exit 1;
                ;;
 esac
 
-