Guide: How To Use Rclone To Mount Cloud Drives And Play Files


DZMM

Recommended Posts

An update: I can now add my cloud drive as a root folder to sonarr. However, when I go to import library sonarr breaks. It gets stuck refreshing the first 3 series. It loads the total number of episodes in each of those series and dies. All of my remaining series show 0 / 0 and when you open the total number of seasons has loaded but each season says no episodes.

 

At this point I believe this likely has to be a permissions issue, but I don't know where to go from here.

 

I have trace logs running - did a search for error and warn and nothing came up. Some screen shots:

image.png.b0cc39d13dcdafa65f7150750a47e191.pngimage.thumb.png.3b8776efe66fd1a495a1905cc431c61c.png

image.thumb.png.957b64ca982ae999c6b376a60c0c3580.png

Link to comment
16 minutes ago, privateer said:

An update: I can now add my cloud drive as a root folder to sonarr. However, when I go to import library sonarr breaks. It gets stuck refreshing the first 3 series. It loads the total number of episodes in each of those series and dies. All of my remaining series show 0 / 0 and when you open the total number of seasons has loaded but each season says no episodes.

 

At this point I believe this likely has to be a permissions issue, but I don't know where to go from here.

 

I have trace logs running - did a search for error and warn and nothing came up. Some screen shots:

 

 

Show a screenshot of your root map setting.

Link to comment
4 minutes ago, privateer said:

image.thumb.png.bda67d87b792db6b7342b4ccb04dcbab.png

image.thumb.png.22e2854d9342a13c783921d3e473e193.png

 

mount_unionfs is the mergerfs folder. Didn't bother to change folder name when the shift to mergerfs happened.

 

Ok that looks good. I saw some other paths in your docker template like /downloads, so I hope you don't use does but only point to /gdrive/xx.

Anyways you could do a ls -la in your tv shows folder from a  terminal. See what the permissions are and if they are causing problems.

Link to comment

Really appreciate the help @Kaizac! This has now had me down for day vs no problems for the last few years.

 

permissions from unraid console:

image.png.db39eb6ff2f306ff10fcf7f344483669.png

 

permissions from console inside the docker container:

image.png.e6f94aa0d24ec443067d3b02e87c2feb.png

 

Just out of curiosity I ran ls -la inside the containers for my 2 radarr images and my other, working sonarr image, and the permissions are the same.

Edited by privateer
Link to comment
41 minutes ago, privateer said:

Really appreciate the help @Kaizac! This has now had me down for day vs no problems for the last few years.

 

permissions from unraid console:

image.png.db39eb6ff2f306ff10fcf7f344483669.png

 

permissions from console inside the docker container:

image.png.e6f94aa0d24ec443067d3b02e87c2feb.png

 

Just out of curiosity I ran ls -la inside the containers for my 2 radarr images and my other, working sonarr image, and the permissions are the same.

Yeah so they are on the permissions of root and you need nobody/users (which is abc/abc in the docker). So I would first try the tv_shows folder. Go to your terminal and enter:

newperms /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows

 

Link to comment
2 hours ago, Kaizac said:

Yeah so they are on the permissions of root and you need nobody/users (which is abc/abc in the docker). So I would first try the tv_shows folder. Go to your terminal and enter:

newperms /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows

 

 

ran the command, which looks like it worked:

image.png.97545fd184836fe1714f673ae6afbbc6.png

 

still no dice though. stays frozen here:

image.png.091b724cf2ee238d3d4de0863b2983fb.png

 

I do notice that if I reboot it loads the next 3 (in terms of updating from 0 / 0 to 0 / [Correct Number]) but still doesn't import the files. Giving you that info in case it's helpful

Link to comment
15 minutes ago, privateer said:

 

ran the command, which looks like it worked:

image.png.97545fd184836fe1714f673ae6afbbc6.png

 

still no dice though. stays frozen here:

image.png.091b724cf2ee238d3d4de0863b2983fb.png

 

I do notice that if I reboot it loads the next 3 (in terms of updating from 0 / 0 to 0 / [Correct Number]) but still doesn't import the files. Giving you that info in case it's helpful

 

So just to be clear. You do a library import from /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows?

And what are you using for your mount script? Is it a merger with a local drive and the rclone mount? When you go into your sonarr docker console and you cd to /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows and then do an ls or lsd. Does it show all the series you expect?

 

Can you go to your tv_shows folder through windows explorer or the mac equivalent on your own computer and play the mkv files from there? I'm wondering if it's just an api ban now. If it plays fine then we can rule that out.

Link to comment
6 minutes ago, Kaizac said:

 

So just to be clear. You do a library import from /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows?

And what are you using for your mount script? Is it a merger with a local drive and the rclone mount? When you go into your sonarr docker console and you cd to /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows and then do an ls or lsd. Does it show all the series you expect?

 

Can you go to your tv_shows folder through windows explorer or the mac equivalent on your own computer and play the mkv files from there? I'm wondering if it's just an api ban now. If it plays fine then we can rule that out.

 

I had checked for API ban earlier but was pretty sure it wasn't the case. Here are the results:

 

Correct - library import is /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows. This is also listed as the root folder on sonarr.

 

Sonarr docker console returns the correct amount of folders and matches the ones I tried to import.

 

I'm able to play files from inside /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows on my own computer.

 

My guess was that it was either 1) TVDB API issues, 2) Sonarr DB issues 3) permissions issues 4) mount script issues. I was hitting a wall with progress though - once again thanks for helping out.

 

Mount script below:

#!/bin/bash

######################
#### Mount Script ####
######################
## Version 0.96.9.3 ##
######################

####### EDIT ONLY THESE SETTINGS #######

# INSTRUCTIONS
# 1. Change the name of the rclone remote and shares to match your setup
# 2. NOTE: enter RcloneRemoteName WITHOUT ':'
# 3. Optional: include custom command and bind mount settings
# 4. Optional: include extra folders in mergerfs mount

# REQUIRED SETTINGS
RcloneRemoteName="gdrive_media_vfs" # Name of rclone remote mount WITHOUT ':'. NOTE: Choose your encrypted remote for sensitive data
RcloneMountShare="/mnt/user/mount_rclone" # where your rclone remote will be located without trailing slash  e.g. /mnt/user/mount_rclone
RcloneMountDirCacheTime="720h" # rclone dir cache time
LocalFilesShare="/mnt/user/rclone_upload" # location of the local files and MountFolders you want to upload without trailing slash to rclone e.g. /mnt/user/local. Enter 'ignore' to disable
RcloneCacheShare="/mnt/user/mount_rclone" # location of rclone cache files without trailing slash e.g. /mnt/user0/mount_rclone
RcloneCacheMaxSize="400G" # Maximum size of rclone cache
RcloneCacheMaxAge="336h" # Maximum age of cache files
MergerfsMountShare="/mnt/user/mount_unionfs" # location without trailing slash  e.g. /mnt/user/mount_mergerfs. Enter 'ignore' to disable
DockerStart="binhex-rtorrentvpn sonarr sonarr4k radarr radarr4k overseerr jackett tautulli Grafana Influxdb telegraf Varken autoscan" # list of dockers, separated by space, to start once mergerfs mount verified. Remember to disable AUTOSTART for dockers added in docker settings page
MountFolders=\{"4kmovies,movies,tv_shows,audiobooks"\} # comma separated list of folders to create within the mount

# Note: Again - remember to NOT use ':' in your remote name above

# OPTIONAL SETTINGS

# Add extra paths to mergerfs mount in addition to LocalFilesShare
LocalFilesShare2="ignore" # without trailing slash e.g. /mnt/user/other__remote_mount/or_other_local_folder.  Enter 'ignore' to disable
LocalFilesShare3="ignore"
LocalFilesShare4="ignore"

# Add extra commands or filters
Command1="--rc"
Command2=""
Command3=""
Command4=""
Command5=""
Command6=""
Command7=""
Command8=""

CreateBindMount="N" # Y/N. Choose whether to bind traffic to a particular network adapter
RCloneMountIP="192.168.1.252" # My unraid IP is 172.30.12.2 so I create another similar IP address
NetworkAdapter="eth0" # choose your network adapter. eth0 recommended
VirtualIPNumber="2" # creates eth0:x e.g. eth0:1.  I create a unique virtual IP addresses for each mount & upload so I can monitor and traffic shape for each of them

####### END SETTINGS #######

###############################################################################
#####   DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING   #######
###############################################################################

####### Preparing mount location variables #######
RcloneMountLocation="$RcloneMountShare/$RcloneRemoteName" # Location for rclone mount
LocalFilesLocation="$LocalFilesShare/$RcloneRemoteName" # Location for local files to be merged with rclone mount
MergerFSMountLocation="$MergerfsMountShare/$RcloneRemoteName" # Rclone data folder location

####### create directories for rclone mount and mergerfs mounts #######
mkdir -p /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName # for script files
mkdir -p $RcloneCacheShare/cache/$RcloneRemoteName # for cache files
if [[  $LocalFilesShare == 'ignore' ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Not creating local folders as requested."
	LocalFilesLocation="/tmp/$RcloneRemoteName"
	eval mkdir -p $LocalFilesLocation
else
	echo "$(date "+%d.%m.%Y %T") INFO: Creating local folders."
	eval mkdir -p $LocalFilesLocation/"$MountFolders"
fi
mkdir -p $RcloneMountLocation

if [[  $MergerfsMountShare == 'ignore' ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Not creating MergerFS folders as requested."
else
	echo "$(date "+%d.%m.%Y %T") INFO: Creating MergerFS folders."
	mkdir -p $MergerFSMountLocation
fi


#######  Check if script is already running  #######
echo "$(date "+%d.%m.%Y %T") INFO: *** Starting mount of remote ${RcloneRemoteName}"
echo "$(date "+%d.%m.%Y %T") INFO: Checking if this script is already running."
if [[ -f "/mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running" ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Exiting script as already running."
	exit
else
	echo "$(date "+%d.%m.%Y %T") INFO: Script not running - proceeding."
	touch /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
fi

####### Checking have connectivity #######

echo "$(date "+%d.%m.%Y %T") INFO: *** Checking if online"
ping -q -c2 google.com > /dev/null # -q quiet, -c number of pings to perform
if [ $? -eq 0 ]; then # ping returns exit status 0 if successful
	echo "$(date "+%d.%m.%Y %T") PASSED: *** Internet online"
else
	echo "$(date "+%d.%m.%Y %T") FAIL: *** No connectivity.  Will try again on next run"
	rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
	exit
fi

#######  Create Rclone Mount  #######

# Check If Rclone Mount Already Created
if [[ -f "$RcloneMountLocation/mountcheck" ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Success ${RcloneRemoteName} remote is already mounted."
else
	echo "$(date "+%d.%m.%Y %T") INFO: Mount not running. Will now mount ${RcloneRemoteName} remote."
# Creating mountcheck file in case it doesn't already exist
	echo "$(date "+%d.%m.%Y %T") INFO: Recreating mountcheck file for ${RcloneRemoteName} remote."
	touch mountcheck
	rclone copy mountcheck $RcloneRemoteName: -vv --no-traverse
# Check bind option
	if [[  $CreateBindMount == 'Y' ]]; then
		echo "$(date "+%d.%m.%Y %T") INFO: *** Checking if IP address ${RCloneMountIP} already created for remote ${RcloneRemoteName}"
		ping -q -c2 $RCloneMountIP > /dev/null # -q quiet, -c number of pings to perform
		if [ $? -eq 0 ]; then # ping returns exit status 0 if successful
			echo "$(date "+%d.%m.%Y %T") INFO: *** IP address ${RCloneMountIP} already created for remote ${RcloneRemoteName}"
		else
			echo "$(date "+%d.%m.%Y %T") INFO: *** Creating IP address ${RCloneMountIP} for remote ${RcloneRemoteName}"
			ip addr add $RCloneMountIP/24 dev $NetworkAdapter label $NetworkAdapter:$VirtualIPNumber
		fi
		echo "$(date "+%d.%m.%Y %T") INFO: *** Created bind mount ${RCloneMountIP} for remote ${RcloneRemoteName}"
	else
		RCloneMountIP=""
		echo "$(date "+%d.%m.%Y %T") INFO: *** Creating mount for remote ${RcloneRemoteName}"
	fi
# create rclone mount
	rclone mount \
	$Command1 $Command2 $Command3 $Command4 $Command5 $Command6 $Command7 $Command8 \
	--allow-other \
	--umask 000 \
	--dir-cache-time $RcloneMountDirCacheTime \
	--attr-timeout $RcloneMountDirCacheTime \
	--log-level INFO \
	--poll-interval 10s \
	--cache-dir=$RcloneCacheShare/cache/$RcloneRemoteName \
	--drive-pacer-min-sleep 10ms \
	--drive-pacer-burst 1000 \
	--vfs-cache-mode full \
	--vfs-cache-max-size $RcloneCacheMaxSize \
	--vfs-cache-max-age $RcloneCacheMaxAge \
	--vfs-read-ahead 1G \
	--bind=$RCloneMountIP \
	$RcloneRemoteName: $RcloneMountLocation &

# Check if Mount Successful
	echo "$(date "+%d.%m.%Y %T") INFO: sleeping for 5 seconds"
# slight pause to give mount time to finalise
	sleep 5
	echo "$(date "+%d.%m.%Y %T") INFO: continuing..."
	if [[ -f "$RcloneMountLocation/mountcheck" ]]; then
		echo "$(date "+%d.%m.%Y %T") INFO: Successful mount of ${RcloneRemoteName} mount."
	else
		echo "$(date "+%d.%m.%Y %T") CRITICAL: ${RcloneRemoteName} mount failed - please check for problems.  Stopping dockers"
		docker stop $DockerStart
		rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
		exit
	fi
fi

####### Start MergerFS Mount #######

if [[  $MergerfsMountShare == 'ignore' ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Not creating mergerfs mount as requested."
else
	if [[ -f "$MergerFSMountLocation/mountcheck" ]]; then
		echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ${RcloneRemoteName} mergerfs mount in place."
	else
# check if mergerfs already installed
		if [[ -f "/bin/mergerfs" ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Mergerfs already installed, proceeding to create mergerfs mount"
		else
# Build mergerfs binary
			echo "$(date "+%d.%m.%Y %T") INFO: Mergerfs not installed - installing now."
			mkdir -p /mnt/user/appdata/other/rclone/mergerfs
			docker run -v /mnt/user/appdata/other/rclone/mergerfs:/build --rm trapexit/mergerfs-static-build
			mv /mnt/user/appdata/other/rclone/mergerfs/mergerfs /bin
# check if mergerfs install successful
			echo "$(date "+%d.%m.%Y %T") INFO: *sleeping for 5 seconds"
			sleep 5
			if [[ -f "/bin/mergerfs" ]]; then
				echo "$(date "+%d.%m.%Y %T") INFO: Mergerfs installed successfully, proceeding to create mergerfs mount."
			else
				echo "$(date "+%d.%m.%Y %T") ERROR: Mergerfs not installed successfully.  Please check for errors.  Exiting."
				rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
				exit
			fi
		fi
# Create mergerfs mount
		echo "$(date "+%d.%m.%Y %T") INFO: Creating ${RcloneRemoteName} mergerfs mount."
# Extra Mergerfs folders
		if [[  $LocalFilesShare2 != 'ignore' ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Adding ${LocalFilesShare2} to ${RcloneRemoteName} mergerfs mount."
			LocalFilesShare2=":$LocalFilesShare2"
		else
			LocalFilesShare2=""
		fi
		if [[  $LocalFilesShare3 != 'ignore' ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Adding ${LocalFilesShare3} to ${RcloneRemoteName} mergerfs mount."
			LocalFilesShare3=":$LocalFilesShare3"
		else
			LocalFilesShare3=""
		fi
		if [[  $LocalFilesShare4 != 'ignore' ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Adding ${LocalFilesShare4} to ${RcloneRemoteName} mergerfs mount."
			LocalFilesShare4=":$LocalFilesShare4"
		else
			LocalFilesShare4=""
		fi
# make sure mergerfs mount point is empty
		mv $MergerFSMountLocation $LocalFilesLocation
		mkdir -p $MergerFSMountLocation
# mergerfs mount command
		mergerfs $LocalFilesLocation:$RcloneMountLocation$LocalFilesShare2$LocalFilesShare3$LocalFilesShare4 $MergerFSMountLocation -o rw,async_read=false,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,cache.files=partial,dropcacheonclose=true
# check if mergerfs mount successful
		echo "$(date "+%d.%m.%Y %T") INFO: Checking if ${RcloneRemoteName} mergerfs mount created."
		if [[ -f "$MergerFSMountLocation/mountcheck" ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ${RcloneRemoteName} mergerfs mount created."
		else
			echo "$(date "+%d.%m.%Y %T") CRITICAL: ${RcloneRemoteName} mergerfs mount failed.  Stopping dockers."
			docker stop $DockerStart
			rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
			exit
		fi
	fi
fi

####### Starting Dockers That Need Mergerfs Mount To Work Properly #######

# only start dockers once
if [[ -f "/mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/dockers_started" ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: dockers already started."
else
# Check CA Appdata plugin not backing up or restoring
	if [ -f "/tmp/ca.backup2/tempFiles/backupInProgress" ] || [ -f "/tmp/ca.backup2/tempFiles/restoreInProgress" ] ; then
		echo "$(date "+%d.%m.%Y %T") INFO: Appdata Backup plugin running - not starting dockers."
	else
		touch /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/dockers_started
		echo "$(date "+%d.%m.%Y %T") INFO: Starting dockers."
		docker start $DockerStart
	fi
fi

rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
echo "$(date "+%d.%m.%Y %T") INFO: Script complete"

exit

 

Link to comment
16 minutes ago, privateer said:

 

I had checked for API ban earlier but was pretty sure it wasn't the case. Here are the results:

 

Correct - library import is /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows. This is also listed as the root folder on sonarr.

 

Sonarr docker console returns the correct amount of folders and matches the ones I tried to import.

 

I'm able to play files from inside /gdrive/mount_unionfs/gdrive_media_vfs/tv_shows on my own computer.

 

My guess was that it was either 1) TVDB API issues, 2) Sonarr DB issues 3) permissions issues 4) mount script issues. I was hitting a wall with progress though - once again thanks for helping out.

 

Mount script below:

#!/bin/bash

######################
#### Mount Script ####
######################
## Version 0.96.9.3 ##
######################

####### EDIT ONLY THESE SETTINGS #######

# INSTRUCTIONS
# 1. Change the name of the rclone remote and shares to match your setup
# 2. NOTE: enter RcloneRemoteName WITHOUT ':'
# 3. Optional: include custom command and bind mount settings
# 4. Optional: include extra folders in mergerfs mount

# REQUIRED SETTINGS
RcloneRemoteName="gdrive_media_vfs" # Name of rclone remote mount WITHOUT ':'. NOTE: Choose your encrypted remote for sensitive data
RcloneMountShare="/mnt/user/mount_rclone" # where your rclone remote will be located without trailing slash  e.g. /mnt/user/mount_rclone
RcloneMountDirCacheTime="720h" # rclone dir cache time
LocalFilesShare="/mnt/user/rclone_upload" # location of the local files and MountFolders you want to upload without trailing slash to rclone e.g. /mnt/user/local. Enter 'ignore' to disable
RcloneCacheShare="/mnt/user/mount_rclone" # location of rclone cache files without trailing slash e.g. /mnt/user0/mount_rclone
RcloneCacheMaxSize="400G" # Maximum size of rclone cache
RcloneCacheMaxAge="336h" # Maximum age of cache files
MergerfsMountShare="/mnt/user/mount_unionfs" # location without trailing slash  e.g. /mnt/user/mount_mergerfs. Enter 'ignore' to disable
DockerStart="binhex-rtorrentvpn sonarr sonarr4k radarr radarr4k overseerr jackett tautulli Grafana Influxdb telegraf Varken autoscan" # list of dockers, separated by space, to start once mergerfs mount verified. Remember to disable AUTOSTART for dockers added in docker settings page
MountFolders=\{"4kmovies,movies,tv_shows,audiobooks"\} # comma separated list of folders to create within the mount

# Note: Again - remember to NOT use ':' in your remote name above

# OPTIONAL SETTINGS

# Add extra paths to mergerfs mount in addition to LocalFilesShare
LocalFilesShare2="ignore" # without trailing slash e.g. /mnt/user/other__remote_mount/or_other_local_folder.  Enter 'ignore' to disable
LocalFilesShare3="ignore"
LocalFilesShare4="ignore"

# Add extra commands or filters
Command1="--rc"
Command2=""
Command3=""
Command4=""
Command5=""
Command6=""
Command7=""
Command8=""

CreateBindMount="N" # Y/N. Choose whether to bind traffic to a particular network adapter
RCloneMountIP="192.168.1.252" # My unraid IP is 172.30.12.2 so I create another similar IP address
NetworkAdapter="eth0" # choose your network adapter. eth0 recommended
VirtualIPNumber="2" # creates eth0:x e.g. eth0:1.  I create a unique virtual IP addresses for each mount & upload so I can monitor and traffic shape for each of them

####### END SETTINGS #######

###############################################################################
#####   DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING   #######
###############################################################################

####### Preparing mount location variables #######
RcloneMountLocation="$RcloneMountShare/$RcloneRemoteName" # Location for rclone mount
LocalFilesLocation="$LocalFilesShare/$RcloneRemoteName" # Location for local files to be merged with rclone mount
MergerFSMountLocation="$MergerfsMountShare/$RcloneRemoteName" # Rclone data folder location

####### create directories for rclone mount and mergerfs mounts #######
mkdir -p /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName # for script files
mkdir -p $RcloneCacheShare/cache/$RcloneRemoteName # for cache files
if [[  $LocalFilesShare == 'ignore' ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Not creating local folders as requested."
	LocalFilesLocation="/tmp/$RcloneRemoteName"
	eval mkdir -p $LocalFilesLocation
else
	echo "$(date "+%d.%m.%Y %T") INFO: Creating local folders."
	eval mkdir -p $LocalFilesLocation/"$MountFolders"
fi
mkdir -p $RcloneMountLocation

if [[  $MergerfsMountShare == 'ignore' ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Not creating MergerFS folders as requested."
else
	echo "$(date "+%d.%m.%Y %T") INFO: Creating MergerFS folders."
	mkdir -p $MergerFSMountLocation
fi


#######  Check if script is already running  #######
echo "$(date "+%d.%m.%Y %T") INFO: *** Starting mount of remote ${RcloneRemoteName}"
echo "$(date "+%d.%m.%Y %T") INFO: Checking if this script is already running."
if [[ -f "/mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running" ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Exiting script as already running."
	exit
else
	echo "$(date "+%d.%m.%Y %T") INFO: Script not running - proceeding."
	touch /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
fi

####### Checking have connectivity #######

echo "$(date "+%d.%m.%Y %T") INFO: *** Checking if online"
ping -q -c2 google.com > /dev/null # -q quiet, -c number of pings to perform
if [ $? -eq 0 ]; then # ping returns exit status 0 if successful
	echo "$(date "+%d.%m.%Y %T") PASSED: *** Internet online"
else
	echo "$(date "+%d.%m.%Y %T") FAIL: *** No connectivity.  Will try again on next run"
	rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
	exit
fi

#######  Create Rclone Mount  #######

# Check If Rclone Mount Already Created
if [[ -f "$RcloneMountLocation/mountcheck" ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Success ${RcloneRemoteName} remote is already mounted."
else
	echo "$(date "+%d.%m.%Y %T") INFO: Mount not running. Will now mount ${RcloneRemoteName} remote."
# Creating mountcheck file in case it doesn't already exist
	echo "$(date "+%d.%m.%Y %T") INFO: Recreating mountcheck file for ${RcloneRemoteName} remote."
	touch mountcheck
	rclone copy mountcheck $RcloneRemoteName: -vv --no-traverse
# Check bind option
	if [[  $CreateBindMount == 'Y' ]]; then
		echo "$(date "+%d.%m.%Y %T") INFO: *** Checking if IP address ${RCloneMountIP} already created for remote ${RcloneRemoteName}"
		ping -q -c2 $RCloneMountIP > /dev/null # -q quiet, -c number of pings to perform
		if [ $? -eq 0 ]; then # ping returns exit status 0 if successful
			echo "$(date "+%d.%m.%Y %T") INFO: *** IP address ${RCloneMountIP} already created for remote ${RcloneRemoteName}"
		else
			echo "$(date "+%d.%m.%Y %T") INFO: *** Creating IP address ${RCloneMountIP} for remote ${RcloneRemoteName}"
			ip addr add $RCloneMountIP/24 dev $NetworkAdapter label $NetworkAdapter:$VirtualIPNumber
		fi
		echo "$(date "+%d.%m.%Y %T") INFO: *** Created bind mount ${RCloneMountIP} for remote ${RcloneRemoteName}"
	else
		RCloneMountIP=""
		echo "$(date "+%d.%m.%Y %T") INFO: *** Creating mount for remote ${RcloneRemoteName}"
	fi
# create rclone mount
	rclone mount \
	$Command1 $Command2 $Command3 $Command4 $Command5 $Command6 $Command7 $Command8 \
	--allow-other \
	--umask 000 \
	--dir-cache-time $RcloneMountDirCacheTime \
	--attr-timeout $RcloneMountDirCacheTime \
	--log-level INFO \
	--poll-interval 10s \
	--cache-dir=$RcloneCacheShare/cache/$RcloneRemoteName \
	--drive-pacer-min-sleep 10ms \
	--drive-pacer-burst 1000 \
	--vfs-cache-mode full \
	--vfs-cache-max-size $RcloneCacheMaxSize \
	--vfs-cache-max-age $RcloneCacheMaxAge \
	--vfs-read-ahead 1G \
	--bind=$RCloneMountIP \
	$RcloneRemoteName: $RcloneMountLocation &

# Check if Mount Successful
	echo "$(date "+%d.%m.%Y %T") INFO: sleeping for 5 seconds"
# slight pause to give mount time to finalise
	sleep 5
	echo "$(date "+%d.%m.%Y %T") INFO: continuing..."
	if [[ -f "$RcloneMountLocation/mountcheck" ]]; then
		echo "$(date "+%d.%m.%Y %T") INFO: Successful mount of ${RcloneRemoteName} mount."
	else
		echo "$(date "+%d.%m.%Y %T") CRITICAL: ${RcloneRemoteName} mount failed - please check for problems.  Stopping dockers"
		docker stop $DockerStart
		rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
		exit
	fi
fi

####### Start MergerFS Mount #######

if [[  $MergerfsMountShare == 'ignore' ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: Not creating mergerfs mount as requested."
else
	if [[ -f "$MergerFSMountLocation/mountcheck" ]]; then
		echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ${RcloneRemoteName} mergerfs mount in place."
	else
# check if mergerfs already installed
		if [[ -f "/bin/mergerfs" ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Mergerfs already installed, proceeding to create mergerfs mount"
		else
# Build mergerfs binary
			echo "$(date "+%d.%m.%Y %T") INFO: Mergerfs not installed - installing now."
			mkdir -p /mnt/user/appdata/other/rclone/mergerfs
			docker run -v /mnt/user/appdata/other/rclone/mergerfs:/build --rm trapexit/mergerfs-static-build
			mv /mnt/user/appdata/other/rclone/mergerfs/mergerfs /bin
# check if mergerfs install successful
			echo "$(date "+%d.%m.%Y %T") INFO: *sleeping for 5 seconds"
			sleep 5
			if [[ -f "/bin/mergerfs" ]]; then
				echo "$(date "+%d.%m.%Y %T") INFO: Mergerfs installed successfully, proceeding to create mergerfs mount."
			else
				echo "$(date "+%d.%m.%Y %T") ERROR: Mergerfs not installed successfully.  Please check for errors.  Exiting."
				rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
				exit
			fi
		fi
# Create mergerfs mount
		echo "$(date "+%d.%m.%Y %T") INFO: Creating ${RcloneRemoteName} mergerfs mount."
# Extra Mergerfs folders
		if [[  $LocalFilesShare2 != 'ignore' ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Adding ${LocalFilesShare2} to ${RcloneRemoteName} mergerfs mount."
			LocalFilesShare2=":$LocalFilesShare2"
		else
			LocalFilesShare2=""
		fi
		if [[  $LocalFilesShare3 != 'ignore' ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Adding ${LocalFilesShare3} to ${RcloneRemoteName} mergerfs mount."
			LocalFilesShare3=":$LocalFilesShare3"
		else
			LocalFilesShare3=""
		fi
		if [[  $LocalFilesShare4 != 'ignore' ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Adding ${LocalFilesShare4} to ${RcloneRemoteName} mergerfs mount."
			LocalFilesShare4=":$LocalFilesShare4"
		else
			LocalFilesShare4=""
		fi
# make sure mergerfs mount point is empty
		mv $MergerFSMountLocation $LocalFilesLocation
		mkdir -p $MergerFSMountLocation
# mergerfs mount command
		mergerfs $LocalFilesLocation:$RcloneMountLocation$LocalFilesShare2$LocalFilesShare3$LocalFilesShare4 $MergerFSMountLocation -o rw,async_read=false,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,cache.files=partial,dropcacheonclose=true
# check if mergerfs mount successful
		echo "$(date "+%d.%m.%Y %T") INFO: Checking if ${RcloneRemoteName} mergerfs mount created."
		if [[ -f "$MergerFSMountLocation/mountcheck" ]]; then
			echo "$(date "+%d.%m.%Y %T") INFO: Check successful, ${RcloneRemoteName} mergerfs mount created."
		else
			echo "$(date "+%d.%m.%Y %T") CRITICAL: ${RcloneRemoteName} mergerfs mount failed.  Stopping dockers."
			docker stop $DockerStart
			rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
			exit
		fi
	fi
fi

####### Starting Dockers That Need Mergerfs Mount To Work Properly #######

# only start dockers once
if [[ -f "/mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/dockers_started" ]]; then
	echo "$(date "+%d.%m.%Y %T") INFO: dockers already started."
else
# Check CA Appdata plugin not backing up or restoring
	if [ -f "/tmp/ca.backup2/tempFiles/backupInProgress" ] || [ -f "/tmp/ca.backup2/tempFiles/restoreInProgress" ] ; then
		echo "$(date "+%d.%m.%Y %T") INFO: Appdata Backup plugin running - not starting dockers."
	else
		touch /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/dockers_started
		echo "$(date "+%d.%m.%Y %T") INFO: Starting dockers."
		docker start $DockerStart
	fi
fi

rm /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName/mount_running
echo "$(date "+%d.%m.%Y %T") INFO: Script complete"

exit

 

 

I can only think of 2 possible solutions right now.

 

First I would remove the /downloads and /tv paths in your docker template. You don't need them as everything goes through /gdrive. And also delete the UMASK variable in the docker template.

I wonder then what permissions you have in media management within Sonarr. I have set permissions on, chmod 777, chown empty.

After you changed that, trying doing the library import again. If that doesn't work just try adding a new show (without auto search) and manually search for an episode and download it. See if it can import the file and process it. If it can, the permissions should be good.

 

When all of that doesn't show any anomalies I would try going to the latest branch in your docker template. See if it works there. Maybe it is an issue of Sonarr and then we can't fix it. But when you have your library imported you can always change back to develop again.

Link to comment
2 hours ago, Kaizac said:

 

I can only think of 2 possible solutions right now.

 

First I would remove the /downloads and /tv paths in your docker template. You don't need them as everything goes through /gdrive. And also delete the UMASK variable in the docker template.

I wonder then what permissions you have in media management within Sonarr. I have set permissions on, chmod 777, chown empty.

After you changed that, trying doing the library import again. If that doesn't work just try adding a new show (without auto search) and manually search for an episode and download it. See if it can import the file and process it. If it can, the permissions should be good.

 

When all of that doesn't show any anomalies I would try going to the latest branch in your docker template. See if it works there. Maybe it is an issue of Sonarr and then we can't fix it. But when you have your library imported you can always change back to develop again.

 

This still seems like a permissions issue to me and I think it's with the mounting script/mergerfs because I feel like we're continuing to eliminate other options.

 

1) Nuked the docker and appdata. Redownloaded sonarr, stripped out UMASK, /tv, /downloads, and added /gdrive. Permissions had reset themselves on /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows so I re-ran newperms /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows. Permissions set on, chmod Folder 777. Tried to import library and it had the same result as shown above.

 

2) Nuked the docker and appdata. Redownloaded sonarr, stripped out UMASK and /tv, but left /downloads and added /gdrive. Permissions had reset themselves on /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows so I re-ran newperms /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows. Permissions set on, chmod Folder 777. Added new show, downloaded episode (goes to local), successfully uploaded. It is imported into Sonarr successfully.

 

I couldn't get it to play on my computer though - every time I tried to open the file through the explorer, the window froze and crashed/had to be killed.

 

As an aside, it also appears that everytime the mounting script is run, it resets the permissions I modified with the newperms command.

 

EDIT: When the mount command runs for the first time, this is the log after mergerfs installs:

 

build/.src/policy_epall.o build/.src/policy_lus.o build/Script Starting Apr 06, 2023 14:10.01

Full logs for this script are available at /tmp/user.scripts/tmpScripts/rclone_mount_new/log.txt

06.04.2023 14:10:01 INFO: Creating local folders.
06.04.2023 14:10:01 INFO: Creating MergerFS folders.
06.04.2023 14:10:01 INFO: *** Starting mount of remote gdrive_media_vfs
06.04.2023 14:10:01 INFO: Checking if this script is already running.
06.04.2023 14:10:01 INFO: Exiting script as already running.
Script Finished Apr 06, 2023 14:10.01

Full logs for this script are available at /tmp/user.scripts/tmpScripts/rclone_mount_new/log.txt

mergerfs version: 2.35.1
'build/mergerfs' -> '/build/mergerfs'
06.04.2023 14:10:02 INFO: *sleeping for 5 seconds
06.04.2023 14:10:07 INFO: Mergerfs installed successfully, proceeding to create mergerfs mount.
06.04.2023 14:10:07 INFO: Creating gdrive_media_vfs mergerfs mount.
06.04.2023 14:10:07 INFO: Checking if gdrive_media_vfs mergerfs mount created.
06.04.2023 14:10:07 INFO: Check successful, gdrive_media_vfs mergerfs mount created.
06.04.2023 14:10:07 INFO: Starting dockers.
binhex-rtorrentvpn
sonarr
sonarr4k
radarr
radarr4k
overseerr
jackett

 

Just want to make sure you don't see anything here...
tautulli
Grafana
Influxdb
telegraf
Varken
autoscan
06.04.2023 14:10:18 INFO: Script complete

 

 

Edited by privateer
Link to comment
18 minutes ago, privateer said:

 

This still seems like a permissions issue to me and I think it's with the mounting script/mergerfs because I feel like we're continuing to eliminate other options.

 

1) Nuked the docker and appdata. Redownloaded sonarr, stripped out UMASK, /tv, /downloads, and added /gdrive. Permissions had reset themselves on /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows so I re-ran newperms /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows. Permissions set on, chmod Folder 777. Tried to import library and it had the same result as shown above.

 

2) Nuked the docker and appdata. Redownloaded sonarr, stripped out UMASK and /tv, but left /downloads and added /gdrive. Permissions had reset themselves on /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows so I re-ran newperms /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows. Permissions set on, chmod Folder 777. Added new show, downloaded episode (goes to local), successfully uploaded. It is imported into Sonarr successfully.

 

I couldn't get it to play on my computer though - every time I tried to open the file through the explorer, the window froze and crashed/had to be killed.

 

As an aside, it also appears that everytime the mounting script is run, it resets the permissions I modified with the newperms command.

 

EDIT: When the mount command runs for the first time, this is the log after mergerfs installs:

 

build/.src/policy_epall.o build/.src/policy_lus.o build/Script Starting Apr 06, 2023 14:10.01

Full logs for this script are available at /tmp/user.scripts/tmpScripts/rclone_mount_new/log.txt

06.04.2023 14:10:01 INFO: Creating local folders.
06.04.2023 14:10:01 INFO: Creating MergerFS folders.
06.04.2023 14:10:01 INFO: *** Starting mount of remote gdrive_media_vfs
06.04.2023 14:10:01 INFO: Checking if this script is already running.
06.04.2023 14:10:01 INFO: Exiting script as already running.
Script Finished Apr 06, 2023 14:10.01

Full logs for this script are available at /tmp/user.scripts/tmpScripts/rclone_mount_new/log.txt

mergerfs version: 2.35.1
'build/mergerfs' -> '/build/mergerfs'
06.04.2023 14:10:02 INFO: *sleeping for 5 seconds
06.04.2023 14:10:07 INFO: Mergerfs installed successfully, proceeding to create mergerfs mount.
06.04.2023 14:10:07 INFO: Creating gdrive_media_vfs mergerfs mount.
06.04.2023 14:10:07 INFO: Checking if gdrive_media_vfs mergerfs mount created.
06.04.2023 14:10:07 INFO: Check successful, gdrive_media_vfs mergerfs mount created.
06.04.2023 14:10:07 INFO: Starting dockers.
binhex-rtorrentvpn
sonarr
sonarr4k
radarr
radarr4k
overseerr
jackett

 

Just want to make sure you don't see anything here...
tautulli
Grafana
Influxdb
telegraf
Varken
autoscan
06.04.2023 14:10:18 INFO: Script complete

 

 

Nothing out of the ordinary in your docker list. The fact the permissions keep resetting is strange. You could just run the mount script once and see what happens.

 

Anyways I run my own mount script but I have --umask 002 and --uid 99 and --gid 100.

Might not be the solution for you, but worth a try. I never have the wrong folder permissions.

 

This is my full mount command:

rclone mount --allow-other --umask 002 --buffer-size 256M --dir-cache-time 9999h --drive-chunk-size 512M --attr-timeout 1s --poll-interval 1m --drive-pacer-min-sleep 10ms --drive-pacer-burst 500 --log-level INFO --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit off --vfs-cache-mode writes --uid 99 --gid 100 tdrive_crypt: /mnt/user/mount_rclone/Tdrive &

 

And the merger command:

mergerfs /mnt/user/LocalMedia/Tdrive:/mnt/user/mount_rclone/Tdrive /mnt/user/mount_unionfs/Tdrive -o rw,async_read=false,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,cache.files=partial,dropcacheonclose=true

 

Link to comment
6 hours ago, Kaizac said:

Nothing out of the ordinary in your docker list. The fact the permissions keep resetting is strange. You could just run the mount script once and see what happens.

 

Anyways I run my own mount script but I have --umask 002 and --uid 99 and --gid 100.

Might not be the solution for you, but worth a try. I never have the wrong folder permissions.

 

This is my full mount command:

rclone mount --allow-other --umask 002 --buffer-size 256M --dir-cache-time 9999h --drive-chunk-size 512M --attr-timeout 1s --poll-interval 1m --drive-pacer-min-sleep 10ms --drive-pacer-burst 500 --log-level INFO --vfs-read-chunk-size 128M --vfs-read-chunk-size-limit off --vfs-cache-mode writes --uid 99 --gid 100 tdrive_crypt: /mnt/user/mount_rclone/Tdrive &

 

And the merger command:

mergerfs /mnt/user/LocalMedia/Tdrive:/mnt/user/mount_rclone/Tdrive /mnt/user/mount_unionfs/Tdrive -o rw,async_read=false,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,cache.files=partial,dropcacheonclose=true

 

 

What OS version are you on?

 

and what sonarr version

Edited by privateer
Link to comment
6 hours ago, Kaizac said:

Unraid version is stable latest: 6.11.5

 

Sonarr is latest develop from linuxserver

 

So I'm on the same unraid OS and have been testing both on linuxserver develop and stable. So that seems stable between our deployments.

 

One other thing - for a long time now (years?) the first time my mount script runs it fails and the second time it works. Not sure what to make of that but I'm trying to put everything out there.

 

Should I have 99:100 permissions for all the folders below tv_shows? What should file permissions be for individual files sonarr needs to access?

Link to comment
21 minutes ago, privateer said:

 

So I'm on the same unraid OS and have been testing both on linuxserver develop and stable. So that seems stable between our deployments.

 

One other thing - for a long time now (years?) the first time my mount script runs it fails and the second time it works. Not sure what to make of that but I'm trying to put everything out there.

 

Should I have 99:100 permissions for all the folders below tv_shows? What should file permissions be for individual files sonarr needs to access?

It should all be 99/100.


I just created a new sonarr instance even with umask in the docker template and did an library import. It just imported them quickly and populated the episodes. So Sonarr is working at least.

 

Regarding your mount script failing the first time, it could be a check file which it sees and thus won't continue in the script. It's hard for me to tell when I can't see how your system and folders look when you haven't mounted yet.

I would try to reboot the server without the mounting (just no rclone scripts and disable all dockers autostart). And then use the commands I posted about for the mount and merger (adjust them to your folder names) and then see if it gets populated properly and if so, start up Sonarr and see what happens.

 

In Sonarr settings, did you disable the analyze setting by the way?

Link to comment
1 hour ago, Kaizac said:

It should all be 99/100.


I just created a new sonarr instance even with umask in the docker template and did an library import. It just imported them quickly and populated the episodes. So Sonarr is working at least.

 

Regarding your mount script failing the first time, it could be a check file which it sees and thus won't continue in the script. It's hard for me to tell when I can't see how your system and folders look when you haven't mounted yet.

I would try to reboot the server without the mounting (just no rclone scripts and disable all dockers autostart). And then use the commands I posted about for the mount and merger (adjust them to your folder names) and then see if it gets populated properly and if so, start up Sonarr and see what happens.

 

In Sonarr settings, did you disable the analyze setting by the way?

 

The analyze files is checked.

 

How are you installing mergerfs? Mine runs through the script as noted above. In order to run mergerfs like you have I can run the partial set of commands in the script but I want to make sure we're doing things 1:1 since this is so problematic.

 

EDIT: additional permissions question. File path is /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows/. Should /mount_unionfs read 99/100 and /gdrive_media_vfs read 99/100 etc all the way down to the individual file?

Edited by privateer
Link to comment
46 minutes ago, privateer said:

 

The analyze files is checked.

 

How are you installing mergerfs? Mine runs through the script as noted above. In order to run mergerfs like you have I can run the partial set of commands in the script but I want to make sure we're doing things 1:1 since this is so problematic.

 

EDIT: additional permissions question. File path is /mnt/user/mount_unionfs/gdrive_media_vfs/tv_shows/. Should /mount_unionfs read 99/100 and /gdrive_media_vfs read 99/100 etc all the way down to the individual file?

Yes I have it all on 99/100 down to the file.

 

Can you try the library import without analyze video checked on? This causes a lot of CPU strain and also api hits, because it reads the file which is like it's streaming your files.

Link to comment
6 hours ago, Kaizac said:

Yes I have it all on 99/100 down to the file.

 

Can you try the library import without analyze video checked on? This causes a lot of CPU strain and also api hits, because it reads the file which is like it's streaming your files.

 

I'm still working through some permutations but wanted to add a bit more info. When I try to stop the Sonarr container after it has the importing issues above, I get an execution error and I can't stop the container. Using OpenFiles I can see that mono is what's using sonarr and keeping it from closing. Here's the listing in case it's helpful.

 

image.thumb.png.a28d092a481c3115c0148ceeed792d24.png

Link to comment

@Kaizac FIXED!!!!

 

Solution was permissions were FUBAR majorly, and I finally moved enough of the file structure to 99:100 which solved it. Thank you so much for working through this with me.

 

Weirdly, I still have had an error a few times with sonarr container not stopping because of mono as shown above.

Link to comment
9 hours ago, privateer said:

@Kaizac FIXED!!!!

 

Solution was permissions were FUBAR majorly, and I finally moved enough of the file structure to 99:100 which solved it. Thank you so much for working through this with me.

 

Weirdly, I still have had an error a few times with sonarr container not stopping because of mono as shown above.

Glad to hear!

 

Did the permissions persist now through mounting again?

 

I still want to advise to not use the analzye video options in sonarr/radarr. It doesn't give you anything you should need and it takes time and api hits. I don't see any advantage for that.

 

Mono is what Sonarr is built upon/dependent off, so it could be that it was running jobs or maybe the docker already had errors/crashes and then you often get the error in my experience. Now that it's running well, does stopping it still give you this error?

I would advise to add UMASK again to your docker template again in case you removed it. That way you stick closed to the templates of the docker repo (linuxserver in this case).

 

Regarding your mount script not working the first time. It is because it sees the file "mount_running" in /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName. This is a checker to prevent it from running multiple times simultaneously. So apparantly this file doesn't get deleted when your script finishes. Maybe your unmount script doesn't remove the file? Or are you running the script twice during starting of your system/array? Maybe 1 on startup of array and another one on a cron job?

 

I would check your rclone scripts and the checker files they use and the way they are scheduled. Something must be conflicting there.

Link to comment
On 4/8/2023 at 6:20 AM, Kaizac said:

Glad to hear!

 

Did the permissions persist now through mounting again?

 

I still want to advise to not use the analzye video options in sonarr/radarr. It doesn't give you anything you should need and it takes time and api hits. I don't see any advantage for that.

 

Mono is what Sonarr is built upon/dependent off, so it could be that it was running jobs or maybe the docker already had errors/crashes and then you often get the error in my experience. Now that it's running well, does stopping it still give you this error?

I would advise to add UMASK again to your docker template again in case you removed it. That way you stick closed to the templates of the docker repo (linuxserver in this case).

 

Regarding your mount script not working the first time. It is because it sees the file "mount_running" in /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName. This is a checker to prevent it from running multiple times simultaneously. So apparantly this file doesn't get deleted when your script finishes. Maybe your unmount script doesn't remove the file? Or are you running the script twice during starting of your system/array? Maybe 1 on startup of array and another one on a cron job?

 

I would check your rclone scripts and the checker files they use and the way they are scheduled. Something must be conflicting there.

 

Permissions are now persistent. UMASK was on the container when I had it running. I've left analyse unchecked and left the permissions unchecked (default).

 

I'll work on the getting the script to hit the first time, but it's lower priority as it works.

Link to comment

I have seen many chages in the base script that comes by default in user scripts.

What is the best version right now?

 

I just want to sync a folder where CCTV videos are store to ondrive. Maybe something like this could be better?

#!/bin/bash

# Path to monitor (Ruta que deseas monitorear)
monitored_path="/user/Storage/CCTV/recordings"

# Configuring the destination path in rclone (Configurar la ruta de destino en rclone)
destination_path="destination_name_in_rclone:"

# Wait until a file is created (Esperar hasta que se cree un archivo)
inotifywait -m -r --exclude '.*/*/*/*/*/*' -e create --format "%w%f" "$monitored_path" | while read file_path; do
    # Check if the event generated corresponds to a file creation (Verificar si el evento generado corresponde a la creación de un archivo)
    if [[ -f "$file_path" ]]; then
        # Print a message indicating that a new file was created and synchronize with the destination (Imprimir un mensaje indicando que se ha creado un nuevo archivo y sincronizar con la ruta de destino)
        echo "A new file has been created: $file_path. Synchronizing with $destination_path ..."
        rclone sync "$monitored_path" "$destination_path" --update
    fi
done

 

Link to comment

If someone is interested this is an improved version

 

#!/bin/bash

# Define variables for frequently changing values
MONITORED_PATH="/mnt/user/Storage/CCTV"
DESTINATION_PATH="/Backup/CCTV"
SYNC_OPTION="--update"
rclonelog="/mnt/user/Storage/CCTV/rclonelog/rclonelog_$(date +%Y-%m-%d_%H-%M-%S).txt"
LOG_PATTERN="Transferred:|Checks:|Deleted:|Elapsed time:|warning:|error:"

# Delete logs older than 30 days
find /mnt/user/Storage/CCTV -name "rclonelog_*.txt" -type f -mtime +30 -delete

# Wait until a file is created
inotifywait -m -r --exclude "$rclonelog" -e create --format "%w%f" "$MONITORED_PATH" | while read file_path; do
    # Check if the event generated corresponds to a file creation
    if [[ -f "$file_path" ]]; then
        # Print a message indicating that a new file was created and synchronize with the destination
        echo "A new file has been created: $file_path. Synchronizing with $DESTINATION_PATH ..."
        /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "CCTV sync" -d "A new file has been created $file_path" -i "normal"

        
        # Synchronize with the destination using rclone
        rclone sync "$MONITORED_PATH" onedriveguillermo:"$DESTINATION_PATH" $SYNC_OPTION --log-file="$rclonelog" --log-level INFO

        echo "Synchronization completed"
        /usr/local/emhttp/webGui/scripts/notify -e "Unraid Server Notice" -s "CCTV sync" -d "Synchronization completed\n$(grep -E "$LOG_PATTERN" "$rclonelog")"
    fi
done

 

Link to comment
On 4/8/2023 at 6:20 AM, Kaizac said:

Glad to hear!

 

Did the permissions persist now through mounting again?

 

I still want to advise to not use the analzye video options in sonarr/radarr. It doesn't give you anything you should need and it takes time and api hits. I don't see any advantage for that.

 

Mono is what Sonarr is built upon/dependent off, so it could be that it was running jobs or maybe the docker already had errors/crashes and then you often get the error in my experience. Now that it's running well, does stopping it still give you this error?

I would advise to add UMASK again to your docker template again in case you removed it. That way you stick closed to the templates of the docker repo (linuxserver in this case).

 

Regarding your mount script not working the first time. It is because it sees the file "mount_running" in /mnt/user/appdata/other/rclone/remotes/$RcloneRemoteName. This is a checker to prevent it from running multiple times simultaneously. So apparantly this file doesn't get deleted when your script finishes. Maybe your unmount script doesn't remove the file? Or are you running the script twice during starting of your system/array? Maybe 1 on startup of array and another one on a cron job?

 

I would check your rclone scripts and the checker files they use and the way they are scheduled. Something must be conflicting there.

 

Do you do anything with the "Rescan Series Folder After Refresh" option in Sonarr? I've moved mine to after manual refresh, but I'm not sure if I needed to do that.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.