Compare commits
2 commits
0a4b2a5fcc
...
81cca85faa
Author | SHA1 | Date | |
---|---|---|---|
|
81cca85faa | ||
|
2e7d928791 |
1 changed files with 40 additions and 37 deletions
|
@ -18,10 +18,10 @@ default_ssh_port="22"
|
|||
default_rsp_port="3389"
|
||||
default_vnc_port="5900"
|
||||
|
||||
Version="2.0.0"
|
||||
Version="2.0.1"
|
||||
|
||||
Help_message="
|
||||
$(basename $0) PROTOCOL [OPTION] [OPTION=VALUE]
|
||||
Usage="
|
||||
$(basename $0) [OPTION] [OPTION=VALUE] PROTOCOL
|
||||
|
||||
script which permit to launch a remote connection protocol.
|
||||
|
||||
|
@ -56,26 +56,15 @@ start_rsp() {
|
|||
port="${default_rsp_port}"
|
||||
fi
|
||||
hostname="${hostname}:${port}"
|
||||
echo "start rsp"
|
||||
echo "start rsp with user=${user} port=${port} hostname=${hostname}"
|
||||
xfreerdp /v:"${hostname}" /u:"${user}" /dynamic-resolution
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
"ssh")
|
||||
protocol="ssh"
|
||||
;;
|
||||
"rsp")
|
||||
protocol="rsp"
|
||||
;;
|
||||
*)
|
||||
echo "protocol $1 uknown" >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
# Parser
|
||||
# looking for double parametters.
|
||||
|
||||
for (( arg=2; arg<$#; arg++)); do
|
||||
for (( arg=1; arg<$#; arg++)); do
|
||||
value="$((arg+1))"
|
||||
if [ "${!arg}" == "-u" ]
|
||||
then
|
||||
|
@ -93,24 +82,36 @@ done
|
|||
# looking for all parametter alone
|
||||
|
||||
for i in "$@"; do
|
||||
if [ "${i%=*}" == "--user" ]
|
||||
then
|
||||
user="${i#*=}"
|
||||
elif [ "${i%=*}" == "--port" ]
|
||||
then
|
||||
port="${i#*=}"
|
||||
elif [ "${i#*=}" == "--hostname" ]
|
||||
then
|
||||
hostname="${i#*=}"
|
||||
elif [ "${i}" == "--version" ] || [ "${i}" == "-v" ]
|
||||
then
|
||||
case "$i" in
|
||||
"ssh")
|
||||
protocol="ssh"
|
||||
;;
|
||||
"rsp")
|
||||
protocol="rsp"
|
||||
;;
|
||||
"--version" | "-v")
|
||||
echo "$(basename $0) v.${Version}"
|
||||
exit 0
|
||||
elif [ "${i}" == "--help" ] || [ "${i}" == "-h" ]
|
||||
then
|
||||
echo "$Help_message"
|
||||
;;
|
||||
"--help" | "-h")
|
||||
echo "${Usage}"
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for i in "$@"; do
|
||||
case "${i%=*}" in
|
||||
"--user")
|
||||
user="${i#*=}"
|
||||
;;
|
||||
"--port")
|
||||
port="${i#*=}"
|
||||
;;
|
||||
"--hostname")
|
||||
hostname="${i#*=}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${user}" == "" ]
|
||||
|
@ -124,6 +125,7 @@ fi
|
|||
|
||||
|
||||
|
||||
# Last check, if protocol define, launch it, else, exit 0
|
||||
case "${protocol}" in
|
||||
"ssh")
|
||||
start_ssh
|
||||
|
@ -132,8 +134,9 @@ case "${protocol}" in
|
|||
start_rsp
|
||||
;;
|
||||
*)
|
||||
echo "CRITICAL protocol ${protocol} uknown" >&2
|
||||
exit 1
|
||||
echo "protocol ${protocol} uknown" >&2
|
||||
echo "${Usage}"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
Loading…
Reference in a new issue