-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·83 lines (70 loc) · 2.03 KB
/
setup.sh
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
76
77
78
79
80
81
82
83
#!/bin/bash
usage(){
echo "sudo ./setup.sh -<h|d|f|n>"
echo "-h this help"
echo "-d restart docker-compose"
echo "-f force install (overwrites .env)"
echo "-n no install (even if .env doesn't exist yet)"
}
while getopts "hdfns" arg; do
case $arg in
d) DockerRestart=true;;
f) Force=true;;
n) NoInstall=true;;
h) Help=true;;
s) ServerInstall=true;;
esac
done
if [ "$Help" = "true" ]; then
usage
exit
fi
if [ ! -f .env ]||[ "$Force" = "true" ]&&[ ! "$NoInstall" = "true" ]; then
if [ "$EUID" -ne 0 ];
then echo "Please run as root"
exit
fi
echo "SECRET=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32})">.env
echo "POSTGRESSPWD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32})">>.env
cp .env populate/
curl -fsSL https://get.docker.com -o get-docker.sh
sh ./get-docker.sh
sudo apt install -y python3-pip libffi-dev
sudo pip3 install docker-compose
sudo usermod -aG docker $SUDO_USER
#TODO select right yaml
if [ $(dpkg --print-architecture) == amd64 ]; then
echo "usual procedure (not a pi)"
else
echo "assuming its a pi"
fi
fi
if [ "$ServerInstall" = "true" ]; then
if [ "$EUID" -ne 0 ];
then echo "Please run as root"
exit
fi
echo "installing node and running npm i"
su $SUDO_USER -c"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
export NVM_DIR=\"\$HOME/.nvm\"
[ -s \"\$NVM_DIR/nvm.sh\" ] && \. \"\$NVM_DIR/nvm.sh\"
echo \$HOME
nvm install node
if [ ! -d aspargis/node_modules ]; then
cd aspargis
npm install
cd ..
fi
if [ ! -d populate/node_modules ]; then
cd populate
npm install
cd ..
fi
"
fi
if [ "$DockerRestart" = "true" ]; then
echo "restarting docker-compose"
docker-compose down
docker-compose up -d
fi