-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-legacy.sh
executable file
·68 lines (63 loc) · 1.86 KB
/
install-legacy.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
#!/bin/bash
installdir="/usr/local/utdon"
service="utdon"
# NodeJS is needed
which node >/dev/null 2>&1
if [ "$?" == "1" ]; then
echo "You have to install nodejs package (==LTS-20)"
exit 1
fi
# Build application
npm install && npm run build
cd client && npm install && npm run build && cd ..
rm -r node_modules && npm install --omit=dev
sudo mkdir -p $installdir/public $installdir/data
sudo cp -R dist/* $installdir/.
sudo cp ./openapi.yaml $installdir/.
sudo cp -R client/dist/* $installdir/public/.
sudo cp -R node_modules $installdir/.
rm -r node_modules dist client/node_modules client/dist
# Service installation
echo "################"
echo ""
echo "UTDON has been built and installed in the directory '$installdir'"
echo ""
echo "- Create user/group: $service/$service"
echo ""
echo "- Then 'chown $service:$service $installdir/data"
echo ""
echo "- Generate two secrets"
USER_ENCRYPT_SECRET="$(openssl rand -base64 32)"
echo "USER_ENCRYPT_SECRET=$USER_ENCRYPT_SECRET"
DATABASE_ENCRYPT_SECRET="$(openssl rand -base64 32)"
echo "DATABASE_ENCRYPT_SECRET=$DATABASE_ENCRYPT_SECRET"
echo ""
echo "*** Keep both secrets safe.... ***"
echo ""
echo "- Create service in /etc/systemd/system/$service.service"
echo ""
cat <<EOF
[Unit]
Description=UTDON - Application for tracking obsolete FOSS applications
After=networking.service
[Service]
WorkingDirectory=$installdir
ExecStart=node main.js
User=$service
Group=$service
Environment="USER_ENCRYPT_SECRET=$USER_ENCRYPT_SECRET"
Environment="DATABASE_ENCRYPT_SECRET=$DATABASE_ENCRYPT_SECRET"
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=$service
Restart=always
[Install]
WantedBy=multi-user.target
EOF
echo ""
echo ""
# you have to daemon-reload for systemd to recognize the new unit
echo "First, reload systemd: 'systemctl daemon-reload', then"
echo "Start service: 'systemctl start $service'"
echo ""
echo "################"