-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy
executable file
·41 lines (33 loc) · 1.24 KB
/
deploy
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
#!/bin/sh
# This is how I deploy to Raspberry Pi 2 (server). You can also find my server
# configuration here: https://github.com/zefer/ansible/tree/master/roles/mothership
server_host=music
echo 'Building frontend'
(cd frontend && grunt build)
echo 'Compiling assets to go-bindata'
go-bindata -o frontend.go -prefix "frontend/dist/" frontend/dist/...
echo 'Compiling for Rasperry Pi'
# GOOS=linux GOARM=6 GOARCH=arm go build
# Pi 4
GOOS=linux GOARM=7 GOARCH=arm go build
echo 'Sending binary to music server'
scp mothership $server_host:/home/joe
echo 'Running commands on music server'
ssh $server_host -t '\
sudo systemctl stop mothership \
&& sleep 1 \
&& sudo mv /home/joe/mothership /usr/bin \
&& sudo setcap cap_net_bind_service=ep /usr/bin/mothership \
&& sudo systemctl start mothership \
&& sleep 1
'
# Register the deploy with Airbrake.
env=home
deployer=$(whoami)
revision=$(git rev-parse HEAD)
repo=https://github.com/zefer/mothership
project_id=$AIRBRAKE_PROJECT_ID
project_key=$AIRBRAKE_PROJECT_KEY
curl -iX POST -H "Content-Type: application/json" \
-d '{"environment":"'$env'","username":"'$deployer'","revision":"'$revision'","repository":"'$repo'"}' \
"https://airbrake.io/api/v4/projects/$project_id/deploys?key=$project_key"