Mount seadrive on boot on a headless linux server

I am planning to integrate my plex and seafile server by using the drive client on the plex server to map its user shared libraries to a local directory. I tried doing this before with the WebDAV extension but performance was awful, and the Drive client prooved to be a good candidate so far. The idea is that if I want to make media on my seafile account (from any user really) available to the plex server, I would just need to share it with the same account that the drive client on the plex server is linked to.

As I said, so far so good, performance is great and I had no issues setting up a simple virtual folder using this guide following the instructions for “Running SeaDrive without GUI” now that’s where the docs stop unfortunately, I’d like to mount this virtual folder on boot using fstab or something that will run before Plex starts scanningn directories. I could make a simple init file and hope for the best, but I think there are people here with a far vaster knowledge than me on these things, that can probably help me out ;). Thanks for reading.

https://manual.seafile.com/extension/fuse.html

afaik that’s only for local access. Please explain yourself.

You want to access your media, from the server, and you want plex list the content?

Those are two separed servers, joined by the power of the intranet :raised_hands:

Plex not to list files with fuse, authorization problem, after I am not an engineer, maybe I’m wrong, I have a second server that j useful for plex and that I synchronize with the client seafile. Server2012 <> Debian8

That’s one option, but I want to avoid offloading content directly to the plex server (it already has a few tb of media). The drive client option seems to be the more reasonable to me.

It sounds like you have the client installed and just need to get it to start on boot. I haven’t tried it, but I don’t see anything in https://www.seafile.com/en/help/drive_client_linux/ about starting the daemon on boot. I don’t think the fstab will work since this isn’t a regular file system handled in the kernel, but instead is handled by a userland program connected to the kernel with fuse.

You probably just need to make a simple init script in /etc/init.d, and link to it from /etc/rc3.d on your plex machine.

Something like this (I can’t really test this right now, so there might be typos or other problems). I made this by modifying the one for the seafile server here https://manual.seafile.com/deploy/start_seafile_at_system_bootup.html):

#!/bin/bash
### BEGIN INIT INFO
# Provides:          seadrive
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: SeaDrive Client
# Description:       Start SeaDrive client
### END INIT INFO

# Change the value of these variable to match your setup
user=haiwen
user_home=/home/haiwen
config_file=${user_home}/seadrive.conf
seadrive_data=${user_home}/.seadrive/data
log_file=${user_home}/.seadrive/logs/seadrive.log
mountpoint=${user_home}/SeaDrive


case "$1" in
        start)
		sudo -u $user /usr/bin/seadrive \
		-c $config_file \
		-d $seadrive_data \
		-l $log_file \
		$mountpoint
        ;;
        restart)
		$0 stop
		$0 start
        ;;
        stop)
		#This might be dangerous  
		sudo -u $user killall seadrive
        ;;
        *)
                echo "Usage: /etc/init.d/$0 {start|stop|restart}"
                exit 1
        ;;
esac

I hope this helps you.

1 Like

Thanks for the response!

I’ve written a small python script to wrap the seadrive binary as suggested here. It keept showing question marks on the mounted directory when listing it with ls so I abandoned that idea.

I ended up using a modified version of your scipt:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          seadrive
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: SeaDrive Client
# Description:       Start SeaDrive client
### END INIT INFO

# Change the value of these variable to match your setup
user="plex"
user_home="/home/plex"
config_file="${user_home}/seadrive.conf"
seadrive_data="${user_home}/.seadrive/data"
log_file="${user_home}/.seadrive/logs/seadrive.log"
mountpoint="${user_home}/seadrive"


case "$1" in
		start)
				sudo -u "$user" bash -c "/usr/bin/seadrive -f \
				-c $(printf "%q" "$config_file") \
				-d $(printf "%q" "$seadrive_data") \
				-l $(printf "%q" "$log_file") \
				$(printf "%q" "$mountpoint") &"
		;;
		restart)
				"$0" stop
				"$0" start
		;;
		stop)
				sudo -u "$user bash" -c "fusermount -u $(printf "%q" "$mountpoint")"
		;;
		*)
				echo "Usage: /etc/init.d/$0 {start|stop|restart}"
				exit 1
		;;
esac

Great. I’m glad it is working for you. And thank you for posting the fixed up init script. I have no doubt it will help someone else trying to do the same sort of thing.