Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #36 from moka-guys/docker_ngrok
Browse files Browse the repository at this point in the history
Docker ngrok (#36)
  • Loading branch information
rebeccahaines1 authored Jul 12, 2023
2 parents 8f60601 + e2351b9 commit 90b8b0f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workstation Housekeeping v1.10
# Workstation Housekeeping v1.11

Scripts to manage data on the NGS workstation

Expand Down Expand Up @@ -53,17 +53,23 @@ 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

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

---
25 changes: 18 additions & 7 deletions ngrok_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@

# 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
nohup ngrok tcp --region eu 22 &> /dev/null &
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)
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.
sleep 3
# Write the ngrok public url for SSH access to the syslog.
Expand Down

0 comments on commit 90b8b0f

Please sign in to comment.