forked from Charcoal-SE/SmokeDetector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud-init
71 lines (52 loc) · 2.27 KB
/
cloud-init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
export YOUR_USERNAME=Undo
export GITHUB_USERNAME=SmokeDetector
export [email protected]
export GITHUB_PASSWORD=pass_here
export METASMOKE_KEY=gibberish_here
# Define these variables if you want SmokeDetector to be automatically launched
# export ChatExchangeU="[email protected]"
# export ChatExchangeP="password"
id -u ubuntu &>/dev/null || adduser --disabled-password --gecos "" ubuntu
mkdir -p /home/ubuntu/.ssh
sudo apt-get update
sudo apt-get install htop gcc python-dev python-setuptools --assume-yes
sudo easy_install pip
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f /home/ubuntu/.ssh/id_rsa -N ''
chown -R ubuntu /home/ubuntu/.ssh
eval "$(ssh-agent -s)"
ssh-add /home/ubuntu/.ssh/id_rsa
instance_id=$(curl http://169.254.169.254/latest/meta-data/instance-id)
instance_type="EC2"
if [[ $instance_id = "not found" ]]
then
instance_id=$(curl -s http://169.254.169.254/metadata/v1/hostname)
instance_type="DigitalOcean"
fi
curl -u $GITHUB_USERNAME:$GITHUB_PASSWORD https://api.github.com/user
curl -u $GITHUB_USERNAME:$GITHUB_PASSWORD -X POST --data "{\"title\": \"$YOUR_USERNAME's $instance_type ($instance_id)\", \"key\": \"$(cat /home/ubuntu/.ssh/id_rsa.pub)\" }" https://api.github.com/user/keys
ssh-keyscan github.com >> ~/.ssh/known_hosts
git clone [email protected]:Charcoal-SE/SmokeDetector.git /home/ubuntu/SmokeDetector
cd /home/ubuntu/SmokeDetector
git submodule init
git submodule update
pip install -r requirements.txt --upgrade
cat > /home/ubuntu/SmokeDetector/config <<- EOM
[Config]
location=$YOUR_USERNAME's $instance_type ($instance_id))
# Set the location for metasmoke here if you're running it. See https://github.com/Charcoal-SE/metasmoke.
metasmoke_host=https://metasmoke.erwaysoftware.com
metasmoke_ws_host=wss://metasmoke.erwaysoftware.com/cable
# Set metasmoke_key if Smokey isn't running on the same machine (localhost)
# that metasmoke is
metasmoke_key=$METASMOKE_KEY
# Set GitHub keys
github_username=$GITHUB_USERNAME
github_password=$GITHUB_PASSWORD
EOM
git config user.email "[email protected]"
git config user.name "SmokeDetector"
chown -R ubuntu /home/ubuntu/SmokeDetector
if [ ! -z "$ChatExchangeU" ] && [ ! -z "$ChatExchangeP" ]; then
su -m ubuntu -c 'cd /home/ubuntu/SmokeDetector; sh nocrash.sh > output.log' &
fi