summaryrefslogtreecommitdiff
path: root/buildscripts/build/build_server.sh
blob: 80e6e91f2c4000525341f8623032d0b43be06ee5 (plain)
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
#!/usr/bin/bash

export $(cat ~/.env | xargs)

chessh_source="https://github.com/Simponic/chessh"
chessh_path="$HOME/src/chessh"

# Grab deps
[ "$(which git)" != "" ] || sudo apt install -y git
if [ "$(which docker)" = "" ]
then
	curl -sSL https://get.docker.com | sh
fi

# Checkout source
if [ ! -d $chessh_path ]
then
	mkdir -p $chessh_path
	cd $chessh_path
	git init
	git remote add origin $chessh_source
	git pull origin
	git checkout main
	git config pull.rebase true
else
	cd $chessh_path
	git pull origin main
fi

# Build
cd $chessh_path
[ -d "$chessh_path/priv/keys" ] && cp ~/keys/* "$chessh_path/priv/keys/" || cp -r ~/keys "$chessh_path/priv"
sudo docker build . -t chessh/server

# Systemd service
cd $HOME
sudo mv chessh.service /etc/systemd/system/chessh.service
sudo systemctl daemon-reload
sudo systemctl enable chessh
sudo systemctl stop chessh
sudo systemctl start chessh