install and remove script of package.
[Desc.]
[Issue] redmine #9685
Change-Id: I4f31a97ab4e88a9670c7b77823996b809cbc63b4
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
-