Skip to content

Instantly share code, notes, and snippets.

@kevyworks
Created April 13, 2018 16:26
Show Gist options
  • Save kevyworks/f897580e05aca323f30692076c46cb27 to your computer and use it in GitHub Desktop.
Save kevyworks/f897580e05aca323f30692076c46cb27 to your computer and use it in GitHub Desktop.
Tunnel Script
#!/bin/bash
# usage: tunnel <PORT>
PORT=${1:-8000}
# https://github.com/localtunnel/localtunnel
# Insure localtunnel is installed globally. npm install -g localtunnel
if ! [ -x "$(command -v lt)" ]; then
echo "Installing localtunnel..."
npm install -g localtunnel
clear
fi
# ref: https://unix.stackexchange.com/questions/204480/run-multiple-commands-and-kill-them-as-one-in-bash
trap 'kill %1' SIGINT
php artisan serve --port=$PORT | tee ./storage/logs/sh_serve.log | sed -e 's/^/[Server] /' &
lt --port=$PORT | tee ./storage/logs/sh_lt.log | sed -e 's/^/[Tunnel] /'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment