mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 12:54:31 +00:00
Merge pull request #36 from Terranom674/fix/09714-cache-permissions
0.9.7.14: WebDAV-Cache-Rechte reparieren
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: Bratonien Tools
|
Plugin Name: Bratonien Tools
|
||||||
Version: 0.9.7.13
|
Version: 0.9.7.14
|
||||||
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
|
||||||
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
|
||||||
Author: Bratonien
|
Author: Bratonien
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
umask 0002
|
||||||
|
|
||||||
CONFIG_FILE="${PIWIGO_CONFIG:-}"
|
CONFIG_FILE="${PIWIGO_CONFIG:-}"
|
||||||
[[ -n "$CONFIG_FILE" && -r "$CONFIG_FILE" ]] || { echo "WebDAV-Konfiguration fehlt: ${CONFIG_FILE:-<leer>}" >&2; exit 1; }
|
[[ -n "$CONFIG_FILE" && -r "$CONFIG_FILE" ]] || { echo "WebDAV-Konfiguration fehlt: ${CONFIG_FILE:-<leer>}" >&2; exit 1; }
|
||||||
@@ -22,6 +23,38 @@ exec 9>"$LOCK_FILE"
|
|||||||
flock -n 9 || exit 0
|
flock -n 9 || exit 0
|
||||||
|
|
||||||
PREVIEW_CACHE="$PIWIGO_ROOT/_data/bratonien-tools/nc-webdav-preview/connection-$CONNECTION_ID"
|
PREVIEW_CACHE="$PIWIGO_ROOT/_data/bratonien-tools/nc-webdav-preview/connection-$CONNECTION_ID"
|
||||||
|
SOURCE_CACHE="$PIWIGO_ROOT/_data/bratonien-tools/nc-webdav-gallery/connection-$CONNECTION_ID"
|
||||||
|
DERIVATIVE_CACHE="$PIWIGO_ROOT/_data/i/_data/bratonien-tools/nc-webdav-gallery/connection-$CONNECTION_ID"
|
||||||
|
PIWIGO_DATA="$PIWIGO_ROOT/_data"
|
||||||
|
|
||||||
|
normalize_connector_cache_permissions() {
|
||||||
|
[[ -d "$PIWIGO_DATA" ]] || return 0
|
||||||
|
|
||||||
|
local data_uid data_gid current_uid path
|
||||||
|
data_uid="$(stat -c '%u' "$PIWIGO_DATA")"
|
||||||
|
data_gid="$(stat -c '%g' "$PIWIGO_DATA")"
|
||||||
|
current_uid="$(id -u)"
|
||||||
|
|
||||||
|
for path in "$SOURCE_CACHE" "$PREVIEW_CACHE" "$DERIVATIVE_CACHE"; do
|
||||||
|
[[ -e "$path" ]] || continue
|
||||||
|
|
||||||
|
if [[ "$current_uid" -eq 0 ]]; then
|
||||||
|
chown -R "$data_uid:$data_gid" -- "$path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! find "$path" -type d -exec chmod 2775 {} + 2>/dev/null; then
|
||||||
|
echo "Hinweis: Verzeichnisrechte konnten ohne Root-Rechte nicht vollständig repariert werden: $path" >&2
|
||||||
|
fi
|
||||||
|
if ! find "$path" -type f -exec chmod 0664 {} + 2>/dev/null; then
|
||||||
|
echo "Hinweis: Dateirechte konnten ohne Root-Rechte nicht vollständig repariert werden: $path" >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Altbestände aus früheren root/systemd-Läufen werden repariert, sobald dieser
|
||||||
|
# Lauf mit ausreichenden Rechten ausgeführt wird. Bei normalen Webserver-Läufen
|
||||||
|
# werden zumindest alle eigenen Dateien gruppenschreibbar gehalten.
|
||||||
|
normalize_connector_cache_permissions
|
||||||
|
|
||||||
php "$SCRIPT_DIR/lib/precache-webdav-previews.php" \
|
php "$SCRIPT_DIR/lib/precache-webdav-previews.php" \
|
||||||
--mapping="$WEBDAV_MAPPING_FILE" \
|
--mapping="$WEBDAV_MAPPING_FILE" \
|
||||||
@@ -33,3 +66,5 @@ php "$SCRIPT_DIR/lib/precache-webdav-previews.php" \
|
|||||||
php "$SCRIPT_DIR/lib/build-webdav-derivatives.php" \
|
php "$SCRIPT_DIR/lib/build-webdav-derivatives.php" \
|
||||||
--piwigo-root="$PIWIGO_ROOT" \
|
--piwigo-root="$PIWIGO_ROOT" \
|
||||||
--connection-id="$CONNECTION_ID"
|
--connection-id="$CONNECTION_ID"
|
||||||
|
|
||||||
|
normalize_connector_cache_permissions
|
||||||
|
|||||||
36
runtime/repair-webdav-cache-permissions.sh
Normal file
36
runtime/repair-webdav-cache-permissions.sh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
PIWIGO_ROOT="${1:-/var/www/piwigo}"
|
||||||
|
PIWIGO_ROOT="${PIWIGO_ROOT%/}"
|
||||||
|
DATA_DIR="$PIWIGO_ROOT/_data"
|
||||||
|
|
||||||
|
[[ -d "$DATA_DIR" ]] || { echo "Piwigo-_data wurde nicht gefunden: $DATA_DIR" >&2; exit 1; }
|
||||||
|
[[ "$(id -u)" -eq 0 ]] || { echo "Die Reparatur muss als root ausgeführt werden." >&2; exit 1; }
|
||||||
|
|
||||||
|
DATA_UID="$(stat -c '%u' "$DATA_DIR")"
|
||||||
|
DATA_GID="$(stat -c '%g' "$DATA_DIR")"
|
||||||
|
|
||||||
|
PATHS=(
|
||||||
|
"$DATA_DIR/bratonien-tools/nc-webdav-gallery"
|
||||||
|
"$DATA_DIR/bratonien-tools/nc-webdav-preview"
|
||||||
|
"$DATA_DIR/i/_data/bratonien-tools/nc-webdav-gallery"
|
||||||
|
"$DATA_DIR/i/bratonien-watermark"
|
||||||
|
)
|
||||||
|
|
||||||
|
found=0
|
||||||
|
for path in "${PATHS[@]}"; do
|
||||||
|
[[ -e "$path" ]] || continue
|
||||||
|
found=1
|
||||||
|
echo "Repariere: $path"
|
||||||
|
chown -R "$DATA_UID:$DATA_GID" -- "$path"
|
||||||
|
find "$path" -type d -exec chmod 2775 {} +
|
||||||
|
find "$path" -type f -exec chmod 0664 {} +
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$found" -eq 0 ]]; then
|
||||||
|
echo "Keine Bratonien-Cache-Verzeichnisse gefunden."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Bratonien-Cache-Rechte wurden an $DATA_DIR angeglichen (UID $DATA_UID, GID $DATA_GID)."
|
||||||
Reference in New Issue
Block a user