#!/usr/bin/env bash # █▀▀ █▀█ █▄░█ █▀▀ █ █▀▀ # █▄▄ █▄█ █░▀█ █▀░ █ █▄█ # --------------------------------------- # REQUIRED: go_server="ssh.ispsystem.net" # set here GO server address key_path="/home/stepan/.ssh/ispkeys/ISP_ecdsa" # set here fullpath to you private ssh_key key_username="s.zhukovskii" # set first half your name from corp email # UPGRADABLE OVER TIME image="mois3y/isp_support:0.0.2" # set image helpfull image for access to VM/DCI # OPTIONAL: hide_output=">> /dev/null" # uncomment this line to hide image pull and rm info # █▀▄▀█ ▄▀█ █ █▄░█ # █░▀░█ █▀█ █ █░▀█ # ---------------------------- # Check second arument (if empty set default 22 port) if ! [ -z $3 ]; then PORT=$3; else PORT=22; fi # Parse address address=$(echo $2 | egrep -o '[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9\.\-]+') # SSH full command: ssh_run="ssh -t -i $key_path $key_username@$go_server go $address -p$PORT" # Access functions: access_vmdci() { # bin command: docker_pull="/usr/bin/docker pull $image $hide_output" docker_rm="/usr/bin/docker image rm $image $hide_output" # delete image from client host docker_run="/usr/bin/docker run" # docker command params: conf_file="/opt/ispsystem/$platform/config.json" scripts_path="/root" mount_conf="--mount type=bind,source=$conf_file,target=/app/config.json,readonly" mount_host="--mount type=bind,source=$scripts_path,target=/app/host" # start container: container_params="$network $mount_conf $mount_host -e PLATFORM=$platform -e CLIENT_HOST=$address --rm $image" # ENTRYPOINT: echo "Сonnect to client server and get access to web UI please wait...." $ssh_run "$docker_pull && $docker_run $container_params && $docker_rm" echo "Сonnect to client server again with ssh session please wait...." $ssh_run } access_fivegen() { KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) # bin command: key_gen="/usr/local/mgr5/sbin/mgrctl -m $panel session.newkey key=$KEY" # ENTRYPOINT: echo "Сonnect to client server and get access to web UI please wait...." $ssh_run "$key_gen" echo "" echo "Your access link:" echo "" echo "=============================================================================" echo "https://$address:1500/$panel?func=auth&key=$KEY" echo "=============================================================================" echo "" echo "Сonnect to client server again with ssh session please wait...." echo "" $ssh_run } if [[ "$1" == "--vm" ]]; then platform="vm" network="--network=vm_vm_box_net" access_vmdci elif [[ "$1" == "--dci" ]]; then platform="dci" network="--network=dci_auth" access_vmdci elif [[ "$1" == "--bill" ]]; then panel="billmgr" access_fivegen elif [[ "$1" == "--ip" ]]; then panel="ipmgr" access_fivegen elif [[ "$1" == "--dns" ]]; then panel="dnsmgr" access_fivegen elif [[ "$1" == "--vm5" ]]; then panel="vmmgr" access_fivegen elif [[ "$1" == "--dci5" ]]; then panel="dcimgr" access_fivegen else cat <<- EOF ============================================ Usage : access.sh host port --panel Available Control panels: --vm --dci --bill --ip --dns --vm5 --dci5 ============================================= EOF fi