Plex initial upload

This commit is contained in:
Alexandre
2021-04-22 16:25:58 +02:00
parent 2ba0bf7814
commit 295101fe23
11 changed files with 426 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
#!/usr/bin/with-contenv bash
if [ ! -d /plex ]; then
echo "Creating /plex"
mkdir -p /plex
chown -R abc:abc /plex
fi
if [ ! -d /share/storage/tv ]; then
echo "Creating /share/storage/tv"
mkdir -p /share/storage/tv
chown -R abc:abc /share/storage/tv
fi
if [ ! -d /share/storage/movies ]; then
echo "Creating /share/storage/movies"
mkdir -p /share/storage/movies
chown -R abc:abc /share/storage/movies
fi
if [ ! -d /share/plex ]; then
echo "Creating /share/plex"
mkdir -p /share/plex
chown -R abc:abc /share/plex
fi
if [ ! -d /config/plex ]; then
echo "Creating /config/plex"
mkdir -p /config/plex
chown -R abc:abc /config/plex
fi
# links
if [ ! -d /plex/cache ]; then
echo "Creating link for /plex/cache"
mkdir -p /share/plex/cache
chown -R abc:abc /share/plex/cache
ln -s /share/plex/cache /plex/cache
fi
if [ ! -d /plex/config ]; then
echo "Creating link for /plex/config"
mkdir -p /config/plex
chown -R abc:abc /config/plex
ln -s /config/plex /plex/config
fi
if [ ! -d /plex/data ]; then
echo "Creating link for /plex/data"
mkdir -p /share/plex/data
chown -R abc:abc /share/plex/data
ln -s /share/plex/data /plex/data
fi
if [ ! -d /plex/logs ]; then
echo "Creating link for /plex/logs"
mkdir -p /share/plex/logs
chown -R abc:abc /share/plex/logs
ln -s /share/plex/logs /plex/logs
fi
if [ ! -d /plex/metadata ]; then
echo "Creating link for /plex/metadata"
mkdir -p /share/plex/metadata
chown -R abc:abc /share/plex/metadata
ln -s /share/plex/metadata /plex/metadata
fi
if [ ! -d /plex/plugins ]; then
echo "Creating link for /plex/plugins"
mkdir -p /share/plex/plugins
chown -R abc:abc /share/plex/plugins
ln -s /share/plex/plugins /plex/plugins
fi
if [ ! -d /plex/root ]; then
echo "Creating link for /plex/root"
mkdir -p /share/plex/root
chown -R abc:abc /share/plex/root
ln -s /share/plex/root /plex/root
fi

View File

@@ -0,0 +1,26 @@
#!/usr/bin/with-contenv bashio
######################
# MOUNT LOCAL SHARES #
######################
bashio::log.info 'Mounting external hdd...'
# Mount local Share if configured and if Protection Mode is active
if bashio::config.has_value 'localdisks'; then
MOREDISKS=$(bashio::config 'localdisks')
bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && \
for disk in $MOREDISKS
do
bashio::log.info "Mount ${disk}"
mkdir -p /share/$disk && \
if [ ! -d /share/$disk ]; then
echo "Creating /share/$disk"
mkdir -p /share/$disk
chown -R abc:abc /share/$disk
fi
mount /dev/$disk /share/$disk && \
bashio::log.info "Success!"
done || \
bashio::log.warning "Protection mode is ON. Unable to mount local drives!"
fi

View File

@@ -0,0 +1,33 @@
#!/usr/bin/with-contenv bashio
####################
# MOUNT SMB SHARES #
####################
if bashio::config.has_value 'networkdisks'; then
# Mount CIFS Share if configured and if Protection Mode is active
bashio::log.info 'Mounting smb share(s)...'
# Define variables
MOREDISKS=$(bashio::config 'networkdisks')
CIFS_USERNAME=$(bashio::config 'cifsusername')
CIFS_PASSWORD=$(bashio::config 'cifspassword')
# Allow SMB1
if bashio::config.true 'smbv1'; then
SMBVERS=",vers=1.0"
else
SMBVERS=",vers=2.1"
fi
# Mounting disks
for disk in ${MOREDISKS//,/ } # Separate comma separated values
do
disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name
diskname=${disk//\\//} #replace \ with /
diskname=${diskname##*/} # Get only last part of the name
mkdir -p /mnt/$diskname # Create dir
chown -R root:root /mnt/$diskname # Permissions
mount -t cifs -o username=$CIFS_USERNAME,password=$CIFS_PASSWORD$SMBVERS $disk /mnt/$diskname && \
bashio::log.info "... $disk successfully mounted to /mnt/$diskname" || bashio::log.error "Unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD" # Mount share
done || true
fi