From 18280dd6050d502fda63ecf525f516ff44579123 Mon Sep 17 00:00:00 2001 From: primardj Date: Thu, 7 Mar 2024 19:58:26 +0000 Subject: [PATCH] separate remote connection to vm-start --- remote_connection.sh | 144 ------------------------------------------- 1 file changed, 144 deletions(-) delete mode 100755 remote_connection.sh diff --git a/remote_connection.sh b/remote_connection.sh deleted file mode 100755 index 2c2bbe1..0000000 --- a/remote_connection.sh +++ /dev/null @@ -1,144 +0,0 @@ -#/bin/bash - -# -# little class about bash extension parametters. -# -# ${myvar#pattern} delete shortest occurence from the begining -# ${myvar##pattern} delete longuest occurence from begining -# ${myvar%pattern} delete shortest occurence from the end -# ${myvar%%pattern} delete longuest occurence from the end -# -# conclusion, use of # will delete the pattern at begining -# and % will delete the parameter at the end. - - -default_user="root" -default_hostname="localhost" -default_ssh_port="22" -default_rsp_port="3389" -default_vnc_port="5900" - -Version="2.0.1" - -Usage=" -$(basename $0) [OPTION] [OPTION=VALUE] PROTOCOL - -script which permit to launch a remote connection protocol. - -PROTOCOL available - ssh A command line protocol which can be used to connect with tcp - rsp The windows remote server protocol - -PROTOCOL #TODO - vnc Virtual Networking Computing, permit to have access to a graphical user interface. - -OPTION available - -v, --version print the version and exit - -h, --help print this help and exit - -u ,--user= Select the user, by default root - -p ,--port= Select the port, by default 10022 - -H , --hostname= Select the hostname to connect -" - - -start_ssh() { - if [ "${port}" == "" ] - then - port="${default_ssh_port}" - fi - echo "start ssh with user=${user} port=${port} hostname=${hostname}" - ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile=/dev/null" -p "${port}" "${user}@${hostname}" -} - -start_rsp() { - if [ "${port}" == "" ] - then - port="${default_rsp_port}" - fi - hostname="${hostname}:${port}" - echo "start rsp with user=${user} port=${port} hostname=${hostname}" - xfreerdp /v:"${hostname}" /u:"${user}" /dynamic-resolution -} - - -# Parser -# looking for double parametters. - -for (( arg=1; arg<$#; arg++)); do - value="$((arg+1))" - if [ "${!arg}" == "-u" ] - then - user="${!value}" - elif [ "${!arg}" == "-p" ] - then - port="${!value}" - elif [ "${!arg}" == "-H" ] - then - hostname="${!value}" - fi -done - - -# looking for all parametter alone - -for i in "$@"; do - case "$i" in - "ssh") - protocol="ssh" - ;; - "rsp") - protocol="rsp" - ;; - "--version" | "-v") - echo "$(basename $0) v.${Version}" - exit 0 - ;; - "--help" | "-h") - echo "${Usage}" - exit 0 - ;; - esac -done - -for i in "$@"; do - case "${i%=*}" in - "--user") - user="${i#*=}" - ;; - "--port") - port="${i#*=}" - ;; - "--hostname") - hostname="${i#*=}" - ;; - esac -done - -if [ "${user}" == "" ] -then - user="${default_user}" -fi -if [ "${hostname}" == "" ] -then - hostname="${default_hostname}" -fi - - - -# Last check, if protocol define, launch it, else, exit 0 -case "${protocol}" in - "ssh") - start_ssh - ;; - "rsp") - start_rsp - ;; - *) - echo "protocol ${protocol} uknown" >&2 - echo "${Usage}" - exit - ;; -esac - - -