Skip to content

Instantly share code, notes, and snippets.

@daneov
Last active November 17, 2015 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daneov/31e54d7becedbfcc6089 to your computer and use it in GitHub Desktop.
Save daneov/31e54d7becedbfcc6089 to your computer and use it in GitHub Desktop.
#!/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