mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 18:44:30 +00:00
0.9.7.14: Connector-Cache-Rechte normalisieren
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user