Add commandline arguments to console.sh

This commit is contained in:
Jan 2020-04-03 22:31:28 +02:00 committed by Markus Hauschild
parent 764c4e8d19
commit 450932fe40

View File

@ -1,18 +1,66 @@
#!/bin/bash #!/bin/bash
echo -n 'Host: ' display_help() {
read drachost echo "Usage: $0 [-i host] [-u user] [-p password]"
echo -n 'User: '
read dracuser
echo -n 'Password: '
read -s dracpass
echo echo
echo "Environment Variables:"
echo " IDRAC_ADDRESS"
echo " IDRAC_USER"
echo " IDRAC_PASSWORD"
echo " SOCKS_PROXY"
}
while [ $# -gt 0 ]; do
case "$1" in
-h)
display_help
exit 0
;;
-i)
shift
IDRAC_ADDRESS="$1"
;;
-u)
shift
IDRAC_USER="$1"
;;
-p)
shift
IDRAC_PASSWORD="$1"
;;
*)
display_help >&2
exit 2
;;
esac
shift
done
while [ -z "$IDRAC_ADDRESS" ]; do
echo -n 'Host: '
if ! read IDRAC_ADDRESS; then
exit 1
fi
done
while [ -z "$IDRAC_USER" ]; do
echo -n 'User: '
if ! read IDRAC_USER; then
exit 1
fi
done
while [ -z "$IDRAC_PASSWORD" ]; do
echo -n 'Password: '
if ! read -s IDRAC_PASSWORD; then
exit 1
fi
echo
done
if [ -z "${SOCKS_PROXY}" ] if [ -z "${SOCKS_PROXY}" ]
then then
java -cp avctKVM.jar -Djava.library.path=./lib com.avocent.idrac.kvm.Main ip=$drachost vmprivilege=true kmport=5900 vport=5900 user=$dracuser passwd=$dracpass apcp=1 version=2 java -cp avctKVM.jar -Djava.library.path=./lib com.avocent.idrac.kvm.Main ip="$IDRAC_ADDRESS" vmprivilege=true kmport=5900 vport=5900 user="$IDRAC_USER" passwd="$IDRAC_PASSWORD" apcp=1 version=2
else else
java -cp avctKVM.jar -Djava.library.path=./lib -DsocksProxyHost=$SOCKS_PROXY com.avocent.idrac.kvm.Main ip=$drachost vmprivilege=true kmport=5900 vport=5900 user=$dracuser passwd=$dracpass apcp=1 version=2 java -cp avctKVM.jar -Djava.library.path=./lib -DsocksProxyHost=$SOCKS_PROXY com.avocent.idrac.kvm.Main ip="$IDRAC_ADDRESS" vmprivilege=true kmport=5900 vport=5900 user="$IDRAC_USER" passwd="$IDRAC_PASSWORD" apcp=1 version=2
fi fi