Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
Forked from retyui/debug-github-actions.sh
Last active February 9, 2021 09:26
Show Gist options
  • Save andromedarabbit/4aa58f257d05014f5cf543ebfa7188db to your computer and use it in GitHub Desktop.
Save andromedarabbit/4aa58f257d05014f5cf543ebfa7188db to your computer and use it in GitHub Desktop.

Revisions

  1. andromedarabbit revised this gist Feb 9, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ if (! which sshd) ; then
    sudo apt-get update -y
    sudo apt-get install -y openssh-server
    sudo mkdir /run/sshd
    sudo /usr/sbin/sshd -D
    sudo /usr/sbin/sshd -d &
    fi

    if [[ -z "$NGROK_TOKEN" ]]; then
  2. andromedarabbit revised this gist Feb 9, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/bash -ex

    if (! which sshd) ; then
    sudo apt-get update -y
    sudo apt-get install -y openssh-server
    sudo mkdir /run/sshd
    sudo /usr/sbin/sshd -D
  3. andromedarabbit revised this gist Feb 9, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    if (! which sshd) ; then
    sudo apt-get install -y openssh-server
    sudo mkdir /run/sshd
    /usr/sbin/sshd -D
    sudo /usr/sbin/sshd -D
    fi

    if [[ -z "$NGROK_TOKEN" ]]; then
  4. andromedarabbit revised this gist Feb 9, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash -ex

    if which sshd ; then
    if (! which sshd) ; then
    sudo apt-get install -y openssh-server
    sudo mkdir /run/sshd
    /usr/sbin/sshd -D
  5. andromedarabbit revised this gist Feb 9, 2021. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,10 @@
    #!/bin/bash -ex

    if which sshd ; then
    sudo apt-get install -y openssh-server
    sudo mkdir /run/sshd
    /usr/sbin/sshd -D
    fi

    if [[ -z "$NGROK_TOKEN" ]]; then
    echo "Please set 'NGROK_TOKEN'"
  6. andromedarabbit revised this gist Feb 9, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ fi
    echo "### Install ngrok ###"

    wget -q https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
    unzip ngrok-stable-linux-386.zip
    unzip ngrok-stable-linux-amd64.zip
    chmod +x ./ngrok

    echo "### Update user: $USER password ###"
  7. andromedarabbit revised this gist Feb 9, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/bin/bash
    #!/bin/bash -ex


    if [[ -z "$NGROK_TOKEN" ]]; then
    @@ -13,7 +13,7 @@ fi

    echo "### Install ngrok ###"

    wget -q https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip
    wget -q https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
    unzip ngrok-stable-linux-386.zip
    chmod +x ./ngrok

  8. @retyui retyui created this gist Jun 5, 2020.
    41 changes: 41 additions & 0 deletions debug-github-actions.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #!/bin/bash


    if [[ -z "$NGROK_TOKEN" ]]; then
    echo "Please set 'NGROK_TOKEN'"
    exit 2
    fi

    if [[ -z "$USER_PASS" ]]; then
    echo "Please set 'USER_PASS' for user: $USER"
    exit 3
    fi

    echo "### Install ngrok ###"

    wget -q https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-386.zip
    unzip ngrok-stable-linux-386.zip
    chmod +x ./ngrok

    echo "### Update user: $USER password ###"
    echo -e "$USER_PASS\n$USER_PASS" | sudo passwd "$USER"

    echo "### Start ngrok proxy for 22 port ###"


    rm -f .ngrok.log
    ./ngrok authtoken "$NGROK_TOKEN"
    ./ngrok tcp 22 --log ".ngrok.log" &

    sleep 10
    HAS_ERRORS=$(grep "command failed" < .ngrok.log)

    if [[ -z "$HAS_ERRORS" ]]; then
    echo ""
    echo "=========================================="
    echo "To connect: $(grep -o -E "tcp://(.+)" < .ngrok.log | sed "s/tcp:\/\//ssh $USER@/" | sed "s/:/ -p /")"
    echo "=========================================="
    else
    echo "$HAS_ERRORS"
    exit 4
    fi