Skip to content

Instantly share code, notes, and snippets.

@pikpikcu
Last active April 21, 2024 09:19
Show Gist options
  • Save pikpikcu/b58197008e48fde2e148daf24381addb to your computer and use it in GitHub Desktop.
Save pikpikcu/b58197008e48fde2e148daf24381addb to your computer and use it in GitHub Desktop.

Revisions

  1. pikpikcu revised this gist Apr 21, 2024. 1 changed file with 15 additions and 16 deletions.
    31 changes: 15 additions & 16 deletions vps-gc.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,11 @@
    function goto {
    #!/bin/bash

    wget -O ng.sh https://github.com/kmille36/Docker-Ubuntu-Desktop-NoMachine/raw/main/ngrok.sh > /dev/null 2>&1
    chmod +x ng.sh
    ./ng.sh

    function goto
    {
    label=$1
    cd
    cmd=$(sed -n "/^:[[:blank:]][[:blank:]]*${label}/{:a;n;p;ba};" $0 |
    @@ -7,24 +14,15 @@ function goto {
    exit
    }

    # Function to prompt for username and password
    function prompt_credentials {
    echo "Create Username/Password"
    read -p "Enter username: " USER
    read -s -p "Enter password: " PASSWORD
    }

    : ngrok
    clear
    wget -O ng.sh https://github.com/kmille36/Docker-Ubuntu-Desktop-NoMachine/raw/main/ngrok.sh > /dev/null
    chmod +x ng.sh
    ./ng.sh
    echo "Go to: https://dashboard.ngrok.com/get-started/your-authtoken"
    read -p "Paste Ngrok Authtoken: " CRP
    ./ngrok config add-authtoken $CRP
    clear
    echo "Repo: https://github.com/kmille36/Docker-Ubuntu-Desktop-NoMachine"
    echo "======================="
    echo "Choose ngrok region (for better connection)."
    echo "choose ngrok region (for better connection)."
    echo "======================="
    echo "us - United States (Ohio)"
    echo "eu - Europe (Frankfurt)"
    @@ -33,15 +31,16 @@ echo "au - Australia (Sydney)"
    echo "sa - South America (Sao Paulo)"
    echo "jp - Japan (Tokyo)"
    echo "in - India (Mumbai)"
    read -p "Choose ngrok region: " CRP
    read -p "choose ngrok region: " CRP
    ./ngrok tcp --region $CRP 4000 &>/dev/null &
    sleep 1
    if curl --silent --show-error http://127.0.0.1:4040/api/tunnels > /dev/null 2>&1; then echo OK; else echo "Ngrok Error! Please try again!" && sleep 1 && goto ngrok; fi

    # Prompt for username and password
    prompt_credentials
    read -p "Enter username: " USER
    read -s -p "Enter password: " PASSWORD
    echo

    docker run --rm -d --network host --privileged --name nomachine-mate -e PASSWORD=123456 -e USER=user --cap-add=SYS_PTRACE --shm-size=1g thuonghai2711/nomachine-ubuntu-desktop:mate
    docker run --rm -d --network host --privileged --name nomachine-mate -e PASSWORD=$PASSWORD -e USER=$USER --cap-add=SYS_PTRACE --shm-size=1g thuonghai2711/nomachine-ubuntu-desktop:mate
    clear
    echo "NoMachine: https://www.nomachine.com/download"
    echo Done! NoMachine Information:
  2. pikpikcu revised this gist Apr 21, 2024. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions vps-gc.sh
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,9 @@ function prompt_credentials {

    : ngrok
    clear
    wget -O ng.sh https://github.com/kmille36/Docker-Ubuntu-Desktop-NoMachine/raw/main/ngrok.sh > /dev/null
    chmod +x ng.sh
    ./ng.sh
    echo "Go to: https://dashboard.ngrok.com/get-started/your-authtoken"
    read -p "Paste Ngrok Authtoken: " CRP
    ./ngrok config add-authtoken $CRP
  3. pikpikcu revised this gist Apr 21, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions vps-gc.sh
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@ function goto {

    # Function to prompt for username and password
    function prompt_credentials {
    echo "Create Username/Password"
    read -p "Enter username: " USER
    read -s -p "Enter password: " PASSWORD
    }
  4. pikpikcu created this gist Apr 21, 2024.
    49 changes: 49 additions & 0 deletions vps-gc.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    function goto {
    label=$1
    cd
    cmd=$(sed -n "/^:[[:blank:]][[:blank:]]*${label}/{:a;n;p;ba};" $0 |
    grep -v ':$')
    eval "$cmd"
    exit
    }

    # Function to prompt for username and password
    function prompt_credentials {
    read -p "Enter username: " USER
    read -s -p "Enter password: " PASSWORD
    }

    : ngrok
    clear
    echo "Go to: https://dashboard.ngrok.com/get-started/your-authtoken"
    read -p "Paste Ngrok Authtoken: " CRP
    ./ngrok config add-authtoken $CRP
    clear
    echo "======================="
    echo "Choose ngrok region (for better connection)."
    echo "======================="
    echo "us - United States (Ohio)"
    echo "eu - Europe (Frankfurt)"
    echo "ap - Asia/Pacific (Singapore)"
    echo "au - Australia (Sydney)"
    echo "sa - South America (Sao Paulo)"
    echo "jp - Japan (Tokyo)"
    echo "in - India (Mumbai)"
    read -p "Choose ngrok region: " CRP
    ./ngrok tcp --region $CRP 4000 &>/dev/null &
    sleep 1
    if curl --silent --show-error http://127.0.0.1:4040/api/tunnels > /dev/null 2>&1; then echo OK; else echo "Ngrok Error! Please try again!" && sleep 1 && goto ngrok; fi

    # Prompt for username and password
    prompt_credentials

    docker run --rm -d --network host --privileged --name nomachine-mate -e PASSWORD=123456 -e USER=user --cap-add=SYS_PTRACE --shm-size=1g thuonghai2711/nomachine-ubuntu-desktop:mate
    clear
    echo "NoMachine: https://www.nomachine.com/download"
    echo Done! NoMachine Information:
    echo IP Address:
    curl --silent --show-error http://127.0.0.1:4040/api/tunnels | sed -nE 's/.*public_url":"tcp:..([^"]*).*/\1/p'
    echo User: $USER
    echo Passwd: $PASSWORD
    echo "VM can't connect? Restart Cloud Shell then Re-run script."
    seq 1 99999999 | while read i; do echo -en "\r Running . $i s /99999999 s";sleep 0.1;echo -en "\r Running .. $i s /99999999 s";sleep 0.1;echo -en "\r Running ... $i s /99999999 s";sleep 0.1;echo -en "\r Running .... $i s /99999999 s";sleep 0.1;echo -en "\r Running ..... $i s /99999999 s";sleep 0.1;echo -en "\r Running . $i s /99999999 s";sleep 0.1;echo -en "\r Running .... $i s /99999999 s";sleep 0.1;echo -en "\r Running ... $i s /99999999 s";sleep 0.1;echo -en "\r Running .. $i s /99999999 s";sleep 0.1;echo -en "\r Running . $i s /99999999 s";sleep 0.1; done