From 0ccc4cb4619d50af632cd4520848643df040cf78 Mon Sep 17 00:00:00 2001 From: Aled Jones Date: Mon, 10 Jul 2023 12:51:07 +0100 Subject: [PATCH 1/3] Update ngrok_start.sh --- ngrok_start.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ngrok_start.sh b/ngrok_start.sh index 8372572..10dd12b 100755 --- a/ngrok_start.sh +++ b/ngrok_start.sh @@ -5,6 +5,7 @@ # Get the process ID of ngrok if it is already running on the system EXISTING_PROCESS=$(pidof ngrok) +ngrok_instance=$1 if [ -z $EXISTING_PROCESS ] ;then # If ngrok is not running, start as a background process and print the url for SSH access @@ -12,7 +13,12 @@ if [ -z $EXISTING_PROCESS ] ;then # ngrok tcp --region eu 22 : Open an connection to ngrok server on port 22 # &> /dev/null : Discard stdout and stderr to empty output stream # & : Run as a background process - nohup ngrok tcp --region eu 22 &> /dev/null & + if [[ $ngrok_instance == "docker" ]]; then + ngrok_token=$(cat /usr/local/src/mokaguys/.ngrok) + nohup docker run --net=host -it -e NGROK_AUTHTOKEN=$ngrok_token ngrok/ngrok:latest tcp 22 --region eu &> /dev/null & + else + nohup ngrok tcp --region eu 22 &> /dev/null & + fi # Pause for a few seconds to allow the connection to complete. sleep 3 # Write the ngrok public url for SSH access to the syslog. From b17e0e1e357996776d5c53786fd0db416ab8ab3c Mon Sep 17 00:00:00 2001 From: Aled Jones Date: Wed, 12 Jul 2023 11:27:39 +0100 Subject: [PATCH 2/3] Update ngrok_start.sh --- ngrok_start.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ngrok_start.sh b/ngrok_start.sh index 10dd12b..54490fb 100755 --- a/ngrok_start.sh +++ b/ngrok_start.sh @@ -6,17 +6,22 @@ # Get the process ID of ngrok if it is already running on the system EXISTING_PROCESS=$(pidof ngrok) ngrok_instance=$1 - +# If ngrok is not running, start as a background process and print the url for SSH access if [ -z $EXISTING_PROCESS ] ;then - # If ngrok is not running, start as a background process and print the url for SSH access - # nohup [command] : Keep the process running the command even after you quit the session - # ngrok tcp --region eu 22 : Open an connection to ngrok server on port 22 - # &> /dev/null : Discard stdout and stderr to empty output stream - # & : Run as a background process if [[ $ngrok_instance == "docker" ]]; then + # cat the ngrok password into a variable so it can be passed as a environment argument to docker (-e) + # run docker container in detached mode (-d) + # name the instance + # set --net=host attaches the container to the host network, rather than the docker network - this means ports don't need to be remapped. + # and use ngrok/ngrok:latest tcp --region eu 22 : Open an connection to ngrok server on port 22 + # &> /dev/null : Discard stdout and stderr to empty output stream ngrok_token=$(cat /usr/local/src/mokaguys/.ngrok) - nohup docker run --net=host -it -e NGROK_AUTHTOKEN=$ngrok_token ngrok/ngrok:latest tcp 22 --region eu &> /dev/null & + docker run -d --name NGROK --net=host -it -e NGROK_AUTHTOKEN=$ngrok_token ngrok/ngrok:latest tcp 22 --region eu &> /dev/null else + # nohup [command] : Keep the process running the command even after you quit the session + # ngrok tcp --region eu 22 : Open an connection to ngrok server on port 22 + # &> /dev/null : Discard stdout and stderr to empty output stream + # & : Run as a background process nohup ngrok tcp --region eu 22 &> /dev/null & fi # Pause for a few seconds to allow the connection to complete. From e2351b9338e26c06d3671ba8283fd5514fcf5f1c Mon Sep 17 00:00:00 2001 From: Aled Jones Date: Wed, 12 Jul 2023 11:41:20 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0b713e2..f529369 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Workstation Housekeeping v1.10 +# Workstation Housekeeping v1.11 Scripts to manage data on the NGS workstation @@ -53,7 +53,7 @@ See wscleaner readme for more info ## ngrok_start.sh -Allow SSH access to the system by running ngrok as a background process. +Allow SSH access to the system by running ngrok as a background process. As of v1.11 supports dockerised ngrok instance. ### Installation @@ -61,9 +61,15 @@ See knowledge base article for ngrok installation. ### Usage -```bash -$ ngrok_start.sh -"tcp://30.tcp.eu.ngrok.io:5555" -``` +Non-dockerised ngrok: + +`sudo bash ngrok_start.sh` + +Dockerised ngrok: + +`sudo bash ngrok_start.sh docker` + +### output + +The script will output the ngrok connection details ----