Update UPDATE.sh

This commit is contained in:
Stefan Pejcic 2025-04-17 14:52:05 +02:00 committed by GitHub
parent 28bfa13b62
commit 67af05e683
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,16 +1,29 @@
#!/bin/bash
echo "Purging old openpanel/openpanel-ui images.."
all_images=$(docker --context default images --format "{{.Repository}} {{.ID}}" | grep "^openpanel/openpanel-ui" | awk '{print $2}')
used_images=$(docker --context default ps --format "{{.Image}}" | xargs -n1 docker inspect --format '{{.Id}}' 2>/dev/null | sort | uniq)
for img in $all_images; do
if echo "$used_images" | grep -q "$img"; then
echo "⏩ Skipping in-use image: $img"
else
echo "🗑️ Deleting unused image: $img"
docker rmi "$img"
fi
done
echo ""
echo "Downloading template for OpenResty"
wget -O /etc/openpanel/nginx/vhosts/1.1/docker_openresty_domain.conf https://github.com/stefanpejcic/openpanel-configuration/blob/main/nginx/vhosts/1.1/docker_openresty_domain.conf
mkdir -p /etc/openpanel/openresty/
wget -O /etc/openpanel/openresty/nginx.conf https://raw.githubusercontent.com/stefanpejcic/openpanel-configuration/refs/heads/main/openresty/nginx.conf
echo ""
echo "Updating template: /etc/openpanel/varnish/default.vcl"
wget -O /etc/openpanel/varnish/default.vcl https://github.com/stefanpejcic/openpanel-configuration/blob/main/varnish/default.vcl
echo ""
echo "Extending list of forbidden usernames: /etc/openpanel/openadmin/config/forbidden_usernames.txt "
wget -O /etc/openpanel/openadmin/config/forbidden_usernames.txt https://raw.githubusercontent.com/stefanpejcic/openpanel-configuration/refs/heads/main/openadmin/config/forbidden_usernames.txt
@ -19,7 +32,14 @@ for dir in /home/*; do
user=$(basename "$dir")
if [[ -f "$file" ]]; then
cp /etc/openpanel/varnish/default.vcl file="$dir/default.vcl"
echo ""
echo "---------------------------------------------------------------"
echo "user: $user"
cp /etc/openpanel/varnish/default.vcl $dir/default.vcl
echo "- Updated Varnish default.vcl template for user: $user"
if ! grep -q 'CRONJOBS' "$file"; then
@ -66,7 +86,7 @@ for dir in /home/*; do
if [[ -f "$file" ]]; then
cp $file $dir/122_docker-compose.yml
echo "Fixing permission issues in PHP containers.. You should restart services manually to re-apply changes."
echo "- Fixing permission issues in PHP containers.. You should restart services manually to re-apply changes."
sed -i 's/- APP_USER=${CONTEXT:-root}/- APP_USER=root/g' $file
sed -i 's/- APP_GROUP=${CONTEXT:-root}/- APP_GROUP=root/g' $file
@ -74,8 +94,8 @@ for dir in /home/*; do
# Check if 'openresty:' already exists
if grep -q "^ openresty:" "$file"; then
echo "✅ 'openresty' service already exists in $file."
exit 0
fi
else
# Define the openresty service block
read -r -d '' OPENRESTY_BLOCK <<'EOF'
@ -102,21 +122,23 @@ read -r -d '' OPENRESTY_BLOCK <<'EOF'
EOF
fi
INDENTED_BLOCK=$(echo "$OPENRESTY_BLOCK" | sed 's/^/ /')
NGINX_LINE=$(grep -n "^ nginx:" "$file" | cut -d: -f1)
if [ -z "$NGINX_LINE" ]; then
echo "❌ 'nginx:' service not found. Cannot determine insertion point."
exit 1
fi
else
# Insert the openresty block above the nginx line
awk -v insert_line="$NGINX_LINE" -v new_block="$INDENTED_BLOCK" '
NR == insert_line { print new_block }
{ print }
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
echo "✅ 'openresty' service added in file $file"
echo "- 'openresty' service added in file $file"
fi
fi
done
@ -126,69 +148,5 @@ done
echo "Purging old openpanel/openpanel-ui images.."
all_images=$(docker --context default images --format "{{.Repository}} {{.ID}}" | grep "^openpanel/openpanel-ui" | awk '{print $2}')
used_images=$(docker --context default ps --format "{{.Image}}" | xargs -n1 docker inspect --format '{{.Id}}' 2>/dev/null | sort | uniq)
for img in $all_images; do
if echo "$used_images" | grep -q "$img"; then
echo "⏩ Skipping in-use image: $img"
else
echo "🗑️ Deleting unused image: $img"
docker rmi "$img"
fi
done
: '
1. check if enterprise license and mailserver running
2. install
apt update && apt install msmtp msmtp-mta -y
chmod a+x /usr/bin/msmtp
3. for all existing users create `/etc/msmtprc`
```
# /etc/msmtprc
defaults
auth off
tls off
logfile /var/log/msmtp.log
account default
host PUBLIC_IPV4_HERE
port 25
from OPENPANEL_USERNAME@SERVER_HOSTNAME
```
4. update compsoe files:
Add
- /usr/bin/msmtp:/usr/bin/msmtp:ro
- ./msmtprc:/etc/msmtprc:ro
for each php service!
5. edit ini files:
replace
```
; sendmail_path =
```
with
```
sendmail_path = /usr/bin/msmtp -t
```
6. reload those php services!
'
echo ""
echo "DONE"