forked from robske110/IDDataLogger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·48 lines (45 loc) · 1.72 KB
/
install.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
#!/bin/bash
#Install script for clean debian-based systems.
if [ "${EUID:-$(id -u)}" -eq 0 ]; then
echo "This install script is not to be run as root or with sudo."
echo "Please run it with sudo installed and from a normal user who is in sudoers!"
exit
fi
cd ~ || exit
wget -q -O - https://packages.sury.org/php/README.txt | bash -s -
sudo apt -y install php8.0 php8.0-pgsql php8.0-curl php8.0-gd php8.0-dom
sudo apt -y install postgresql
pg_pw=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
sudo su postgres -c "psql -c \"DO \\$\\$
BEGIN
IF EXISTS (SELECT FROM pg_roles WHERE rolname='iddatalogger') THEN
ALTER ROLE iddatalogger WITH PASSWORD '$pg_pw';
ELSE
CREATE USER iddatalogger WITH PASSWORD '$pg_pw';
END IF;
END \\$\\$;\"; createdb vwid"
sudo apt -y install git
git clone https://github.com/robske110/IDDataLogger.git --recursive
cd IDDataLogger || exit
./config-wizard.sh --host localhost --user iddatalogger --dbname vwid --password "$pg_pw" --driver pgsql --allow-insecure-http --quiet
sudo rm /var/www/html/index.html #remove default "It works!" page
sudo mkdir /var/www/html/vwid/
sudo cp -r ./public/. /var/www/html/vwid
sudo ln -s "$PWD/.env" /var/www/
echo "[Unit]
Description=ID DataLogger php backend
After=network.target
Requires=postgresql.service
[Service]
ExecStart=/home/$(whoami)/IDDataLogger/start.sh
WorkingDirectory=/home/$(whoami)/IDDataLogger
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=iddatalogger
User=$(whoami)
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/iddatalogger.service > /dev/null
sudo systemctl enable iddatalogger.service
echo "Installation complete! You can now enter cd IDDataLogger && ./start.sh to finish setting up."