aboutsummaryrefslogtreecommitdiff
path: root/config
blob: 214184e2cc592035e0ae7dadeeff549a22555f38 (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
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
72
73
74
75
#!/bin/bash

export $(cat .env | xargs)

packages() {
	sudo apt-get install \
		nodejs npm \
		python3 python3-venv python3-pip \
		make \
		gcc \
		sqlite3 libsqlite3-dev \
		nginx
}

yarn_install() {
	sudo npm i -g typescript yarn # install typescript compilers and yarn package manager globally using npm
}

node_packages() {
	yarn
}

python_packages() {
	python3 -m venv venv # create virtual environment
	venv/bin/pip install -r requirements.txt # install the dependencies
}

submodules() {
	git submodule init
	git submodule update
}

database() {
	cd database
	sh init_db.sh
	make
	cd ..
}

voerbak() {
	cd voerbak
	make
	cd ..
}

customize_config() {
	sed "s#{{ connect4_dir }}#$CONNECT4_WEB_ROOT#g" -i ./api.systemd.conf
	sed "s/{{ connect4_user }}/$(whoami)/g" -i ./api.systemd.conf
	sed "s/user nobody/user $(whoami)/" -i ./nginx.conf
}

build() {
	customize_config
	npx next build
	npx next export
	mv out $CONNECT4_WEB_ROOT
}

all() {
	packages
	yarn_install
	node_packages
	python_packages
	submodules
	database
	voerbak
}

if [[ -z $1 ]]; then
	all
	exit
fi

$1