mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-02 05:44:03 +02:00
Revert code and implement skip permissions
This commit is contained in:
@@ -1,38 +1,29 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/env bashio
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
PUID="$(bashio::config 'PUID' || echo 0)"
|
##################
|
||||||
PGID="$(bashio::config 'PGID' || echo 0)"
|
# SYMLINK CONFIG #
|
||||||
|
##################
|
||||||
|
|
||||||
bashio::log.info "Ensuring Plex library location and symlink ..."
|
if [ ! -d /share/plex ]; then
|
||||||
|
echo "Creating /share/plex"
|
||||||
# 1) Ensure base dir exists
|
mkdir -p /share/plex
|
||||||
install -d -m 0775 /share/plex || mkdir -p /share/plex
|
|
||||||
|
|
||||||
# 2) Migrate once if needed
|
|
||||||
if [ -d /config/Library ] && [ ! -L /config/Library ] && [ ! -e /share/plex/Library ]; then
|
|
||||||
bashio::log.info "Migrating /config/Library to /share/plex/Library"
|
|
||||||
mv /config/Library /share/plex/
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3) Ensure target exists
|
if [ ! -d /share/plex/Library ]; then
|
||||||
install -d -m 0775 /share/plex/Library || mkdir -p /share/plex/Library
|
echo "moving Library folder"
|
||||||
|
mv /config/Library /share/plex
|
||||||
# 4) Ensure symlink /config/Library -> /share/plex/Library
|
ln -s /share/plex/Library /config
|
||||||
if [ ! -L /config/Library ] || [ "$(readlink -f /config/Library || true)" != "/share/plex/Library" ]; then
|
echo "links done"
|
||||||
if [ -e /config/Library ] && [ ! -L /config/Library ]; then
|
else
|
||||||
mv /config/Library "/config/Library.bak-$(date +%s)"
|
rm -r /config/Library
|
||||||
else
|
ln -s /share/plex/Library /config
|
||||||
rm -f /config/Library || true
|
echo "Using existing config"
|
||||||
fi
|
|
||||||
ln -sfn /share/plex/Library /config/Library
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5) Fix ownership and permissions **recursively** so Plex can write its DB
|
PUID="$(bashio::config 'PUID')"
|
||||||
if [ "$PUID" != "0" ] || [ "$PGID" != "0" ]; then
|
PGID="$(bashio::config 'PGID')"
|
||||||
chown -R "$PUID:$PGID" /share/plex/Library
|
|
||||||
chmod -R u+rwX,g+rwX /share/plex/Library
|
|
||||||
chmod g+s /share/plex/Library
|
|
||||||
fi
|
|
||||||
|
|
||||||
bashio::log.info "Plex library directory and symlink are ready."
|
if ! bashio::config.true "skip_permissions_check" && [ "${PUID:-0}" != "0" ] && [ "${PGID:-0}" != "0" ]; then
|
||||||
|
chown -R "${PUID}:${PGID}" /share/plex
|
||||||
|
chmod -R 777 /share/plex
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user