-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
update-extras.sh
130 lines (121 loc) · 4.81 KB
/
update-extras.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
#################
# Update-Extras #
#################
# shellcheck disable=SC2034
VERSION="1.9"
# Variables
CONFIG_FILE="/etc/ultimate-updater/update.conf"
PIHOLE=$(awk -F'"' '/^PIHOLE=/ {print $2}' $CONFIG_FILE)
IOBROKER=$(awk -F'"' '/^IOBROKER=/ {print $2}' $CONFIG_FILE)
PTERODACTYL=$(awk -F'"' '/^PTERODACTYL=/ {print $2}' $CONFIG_FILE)
OCTOPRINT=$(awk -F'"' '/^OCTOPRINT=/ {print $2}' $CONFIG_FILE)
DOCKER_COMPOSE=$(awk -F'"' '/^DOCKER_COMPOSE=/ {print $2}' $CONFIG_FILE)
COMPOSE_PATH=$(awk -F'"' '/^COMPOSE_PATH=/ {print $2}' $CONFIG_FILE)
# PiHole
if [[ -f "/usr/local/bin/pihole" && $PIHOLE == true ]]; then
echo -e "\n*** Updating PiHole ***\n"
/usr/local/bin/pihole -up
fi
# ioBroker
if [[ -d "/opt/iobroker" && $IOBROKER == true ]]; then
echo -e "\n*** Updating ioBroker ***\n"
echo "*** Stop ioBroker ***" && iob stop && echo
echo "*** Update/Upgrade ioBroker ***" && iob update && iob upgrade -y && iob upgrade self -y && echo
echo "*** Start ioBroker ***" && iob start && echo
if [[ -d "/opt/iobroker/iobroker-data/radar2.admin" ]]; then
setcap cap_net_admin,cap_net_raw,cap_net_bind_service=+eip "$(eval readlink -f '$(which arp-scan)')"
setcap cap_net_admin,cap_net_raw,cap_net_bind_service=+eip "$(eval readlink -f '$(which node)')"
setcap cap_net_admin,cap_net_raw,cap_net_bind_service=+eip "$(eval readlink -f '$(which arp)')"
setcap cap_net_admin,cap_net_raw,cap_net_bind_service=+eip "$(eval readlink -f '$(which hcitool)')"
setcap cap_net_admin,cap_net_raw,cap_net_bind_service=+eip "$(eval readlink -f '$(which hciconfig)')"
setcap cap_net_admin,cap_net_raw,cap_net_bind_service=+eip "$(eval readlink -f '$(which l2ping)')"
fi
fi
# Pterodactyl
if [[ -d "/var/www/pterodactyl" && $PTERODACTYL == true ]]; then
echo -e "\n*** Updating Pterodactyl ***\n"
cd /var/www/pterodactyl || exit
php artisan down
curl -L https://github.com/pterodactyl/panel/releases/latest/download/panel.tar.gz | tar -xzv
chmod -R 755 storage/* bootstrap/cache
composer install --no-dev --optimize-autoloader
php artisan view:clear
php artisan config:clear
php artisan migrate --seed --force
os=$(hostnamectl | grep System)
if [[ $os =~ CentOS ]]; then
# If using NGINX on CentOS:
if id -u "nginx" >/dev/null 2>&1; then
chown -R nginx:nginx /var/www/pterodactyl/*
# If using Apache on CentOS
elif id -u "apache" >/dev/null 2>&1; then
chown -R apache:apache /var/www/pterodactyl/*
fi
else
# If using NGINX or Apache (not on CentOS):
chown -R www-data:www-data /var/www/pterodactyl/*
fi
php artisan queue:restart
php artisan up
#Upgrading Wings
systemctl stop wings
curl -L -o /usr/local/bin/wings "https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_$([[ "$(uname -m)" == "x86_64" ]] && echo "amd64" || echo "arm64")"
chmod u+x /usr/local/bin/wings
systemctl restart wings
fi
# Octoprint
if [[ -d "/root/OctoPrint" && $OCTOPRINT == true ]]; then
echo -e "\n*** Updating Octoprint ***\n"
# find octoprint
OPRINT=$(find /home -name "oprint")
"$OPRINT"/bin/pip install -U --ignore-installed octoprint
sudo service octoprint restart
fi
# Docker Compose detection
if [[ -f /usr/local/bin/docker-compose ]]; then DOCKER_COMPOSE_V1=true; fi
if docker compose version &>/dev/null; then DOCKER_COMPOSE_V2=true; fi
# Docker-Compose run
if [[ $DOCKER_COMPOSE == true && $DOCKER_COMPOSE_V1 == true || $DOCKER_COMPOSE_V2 == true ]]; then
# Cleaning
DOCKER_EXIT () {
echo -e "\n*** Cleaning ***"
docker container prune -f
docker system prune -a -f
docker image prune -f
docker system prune --volumes -f
}
COMPOSEFILES=("docker-compose.yaml" "docker-compose.yml" "compose.yaml" "compose.yml")
DIRLIST=()
for COMPOSEFILE in "${COMPOSEFILES[@]}"; do
while IFS= read -r line; do
DIRLIST+=("$line")
done < <(find "$COMPOSE_PATH" -name "$COMPOSEFILE" -exec dirname {} \; 2> >(grep -v 'Permission denied'))
done
# Docker-Compose v1
if [[ $DOCKER_COMPOSE_V1 == true && ${#DIRLIST[@]} -gt 0 ]]; then
echo -e "\n*** Updating Docker-Compose v1 (oldstable) ***\n"
for dir in "${DIRLIST[@]}"; do
echo "Updating $dir..."
pushd "$dir" > /dev/null || return
/usr/local/bin/docker-compose pull
/usr/local/bin/docker-compose up --force-recreate --build -d
/usr/local/bin/docker-compose restart
popd > /dev/null || return
done
echo "All projects have been updated."
DOCKER_EXIT
fi
# Docker-Compose v2
if [[ $DOCKER_COMPOSE_V2 == true && ${#DIRLIST[@]} -gt 0 ]]; then
echo -e "\n*** Updating Docker Compose ***"
for dir in "${DIRLIST[@]}"; do
echo "Updating $dir..."
pushd "$dir" > /dev/null || return
docker compose pull && docker compose up -d
popd > /dev/null || return
done
echo "All projects have been updated."
DOCKER_EXIT
fi
fi