mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-05 23:25:57 +02:00
Handle existing Jellyfin symlinks
This commit is contained in:
@@ -3,6 +3,28 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
LOCATION=$(bashio::config 'data_location')
|
LOCATION=$(bashio::config 'data_location')
|
||||||
|
PUID=$(bashio::config "PUID")
|
||||||
|
PGID=$(bashio::config "PGID")
|
||||||
|
|
||||||
|
create_link() {
|
||||||
|
local target_dir="$1"
|
||||||
|
local link_path="$2"
|
||||||
|
|
||||||
|
mkdir -p "$target_dir"
|
||||||
|
mkdir -p "$(dirname "$link_path")"
|
||||||
|
|
||||||
|
if [ -L "$link_path" ]; then
|
||||||
|
rm "$link_path"
|
||||||
|
elif [ -d "$link_path" ]; then
|
||||||
|
cp -a "$link_path/." "$target_dir/" || true
|
||||||
|
rm -r "$link_path"
|
||||||
|
elif [ -e "$link_path" ]; then
|
||||||
|
rm "$link_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -sfn "$target_dir" "$link_path"
|
||||||
|
chown -R "$PUID:$PGID" "$target_dir"
|
||||||
|
}
|
||||||
|
|
||||||
# Check if config is located in an acceptable location
|
# Check if config is located in an acceptable location
|
||||||
LOCATIONOK=""
|
LOCATIONOK=""
|
||||||
@@ -45,50 +67,25 @@ fi
|
|||||||
|
|
||||||
# links
|
# links
|
||||||
|
|
||||||
if [ ! -d /jellyfin/cache ]; then
|
echo "Creating link for /jellyfin/cache"
|
||||||
echo "Creating link for /jellyfin/cache"
|
create_link "$LOCATION/cache" /jellyfin/cache
|
||||||
mkdir -p "$LOCATION"/cache
|
|
||||||
chown -R "$PUID:$PGID" "$LOCATION"/cache
|
|
||||||
ln -s "$LOCATION"/cache /jellyfin/cache
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d /jellyfin/data ]; then
|
echo "Creating link for /jellyfin/data"
|
||||||
echo "Creating link for /jellyfin/data"
|
create_link "$LOCATION/data" /jellyfin/data
|
||||||
mkdir -p "$LOCATION"/data
|
|
||||||
chown -R "$PUID:$PGID" "$LOCATION"/data
|
|
||||||
ln -s "$LOCATION"/data /jellyfin/data
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d /jellyfin/log ]; then
|
echo "Creating link for /jellyfin/log"
|
||||||
echo "Creating link for /jellyfin/log"
|
create_link "$LOCATION/log" /jellyfin/log
|
||||||
mkdir -p "$LOCATION"/log
|
|
||||||
chown -R "$PUID:$PGID" "$LOCATION"/log
|
|
||||||
ln -s "$LOCATION"/log /jellyfin/log
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d /jellyfin/metadata ]; then
|
echo "Creating link for /jellyfin/metadata"
|
||||||
echo "Creating link for /jellyfin/metadata"
|
create_link "$LOCATION/metadata" /jellyfin/metadata
|
||||||
mkdir -p "$LOCATION"/metadata
|
|
||||||
chown -R "$PUID:$PGID" "$LOCATION"/metadata
|
|
||||||
ln -s "$LOCATION"/metadata /jellyfin/metadata
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d /jellyfin/plugins ]; then
|
echo "Creating link for /jellyfin/plugins"
|
||||||
echo "Creating link for /jellyfin/plugins"
|
create_link "$LOCATION/plugins" /jellyfin/plugins
|
||||||
mkdir -p "$LOCATION"/plugins
|
|
||||||
chown -R "$PUID:$PGID" "$LOCATION"/plugins
|
|
||||||
ln -s "$LOCATION"/plugins /jellyfin/plugins
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d /jellyfin/root ]; then
|
echo "Creating link for /jellyfin/root"
|
||||||
echo "Creating link for /jellyfin/root"
|
create_link "$LOCATION/root" /jellyfin/root
|
||||||
mkdir -p "$LOCATION"/root
|
|
||||||
chown -R "$PUID:$PGID" "$LOCATION"/root
|
|
||||||
ln -s "$LOCATION"/root /jellyfin/root
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Legacy mode
|
# Legacy mode
|
||||||
echo "Enable legacy mode"
|
echo "Enable legacy mode"
|
||||||
mkdir -p /config/addons_config
|
create_link "$LOCATION" /config/addons_config/jellyfin
|
||||||
ln -sf "$LOCATION" /config/addons_config/jellyfin
|
|
||||||
chown -R "$PUID:$PGID" "$LOCATION"
|
chown -R "$PUID:$PGID" "$LOCATION"
|
||||||
|
|||||||
Reference in New Issue
Block a user