-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·46 lines (39 loc) · 955 Bytes
/
deploy.sh
File metadata and controls
executable file
·46 lines (39 loc) · 955 Bytes
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
#!/usr/bin/env bash
set -e
env_file="${1:-.env.example}"
if [ ! -f "$env_file" ]; then
echo "File $env_file not found!" >&2
exit 1
fi
# shellcheck disable=SC1090
source "$env_file"
cat <<EOF
_sudo() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
else
if [ -z "$SUDO_PASSWORD" ]; then
echo "❌ Errore: variabile SUDO_PASSWORD non definita" >&2
return 1
fi
echo "RUN: \$@"
echo "$SUDO_PASSWORD" | sudo -S "\$@"
fi
}
_update() {
[ ! -d "/opt/phpservermonitor" ] && _sudo git clone --branch main --single-branch https://github.com/javanile/phpservermonitor /opt/phpservermonitor
cd /opt/phpservermonitor
_sudo git pull --no-rebase
_sudo docker compose up -d --build --force-recreate --remove-orphans
}
_reset() {
if [ -d "/opt/phpservermonitor" ]; then
cd /opt/phpservermonitor
_sudo docker compose down --remove-orphans -v
cd /opt
_sudo rm -rf /opt/phpservermonitor
fi
}
_reset
_update
EOF