Last active
November 17, 2015 08:11
-
-
Save daneov/31e54d7becedbfcc6089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
randpw(){ < /dev/urandom LC_CTYPE=C tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c8; echo "";} | |
sendPush(){ | |
token="$1" | |
curl --header "Access-Token: $token" \ | |
--header 'Content-Type: application/json' \ | |
--data-binary "{\"body\":\"$passwd\",\"title\":\"Cloud9 Authentication\",\"type\":\"note\"}" \ | |
--request POST \ | |
https://api.pushbullet.com/v2/pushes; | |
} | |
launchCloud9(){ | |
token="$1" | |
user="$(whoami)" | |
passwd="$(randpw)" | |
process_id="$(pidof node)" | |
if [ "$process_id" ]; then | |
echo "Service already running with pid $process_id, returning." >&2 | |
return | |
fi | |
`node ~/.cloud9/server.js -p 8080 -l 0.0.0.0 -a $user:$passwd -w . > /dev/null 2>&1 &` | |
if [ ! "$(pidof node)" ]; then | |
echo "Service failed to start, returning" >&2 | |
return | |
fi | |
echo "Successfully started cloud9 service!" | |
echo -e "\nUser should use $user:$passwd to authenticate with C9." | |
sendPush "$token" | |
} | |
launchCloud9 "<token>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment