seafile-cli Autostart

Ich habe mir den seafile commandline client von hier auf meinem HTPC installiert, welcher immer starten sollen, wenn der HTPC starten. Dazu musste ich noch folgendes init.d Script anlegen, welches auf dem Skeleton-File /etc/init.d/skeleton basiert und nur leicht angepasst wurde.

Dabei muss der Inhalt hier angelegt werden:

sudo nano /etc/init.d/seaf-cli

Im folgenden ist der `Inhalt`, also das Script zu finden.
Mithilfe der Variablen USER laesst sich festlegen in welchem Userkontext der Seafile-Client gestartet wird.
Fuer diesen sollte es deshalb auch einen bereits konfigurierten Seafile-Client geben. Eine Anleitung fuer den Client ist hier zu finden

#! /bin/sh
# Provides:          seaf-cli 
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple start script for seafile cli
# Description:       Should be placed in /etc/init.d.

# Author: Sven Knuth <>

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the script
DESC="Seafile Commandline"


# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

	su -c "$DAEMON start" - $USER


	su -c "$DAEMON stop" - $USER

case "$1" in
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	su -c "$DAEMON status" - $USER > /dev/null 2>&1
	case "$?" in
		0) echo "$DAEMON already started"  ;;
		1) do_start
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	su -c "$DAEMON status" - $USER > /dev/null 2>&1
	case "$?" in
		1) echo "$DAEMON already stopped"  ;;
		0) do_stop ;;
	su -c "$DAEMON status" - $USER > /dev/null 2>&1
	case "$?" in
		1) echo "$DAEMON not started"  ;;
		0) su -c "$DAEMON status" - $USER

	echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
	exit 3


Dies muss nun nur noch ausfuehrbar gemacht werden.

sudo chmod +x /etc/init.d/seaf-cli

Ausserdem muss es einen Verweiss auf den Seafile-Client unter /usr/sbin/seaf-cli geben.

Damit es bei jedem Neustart ausgefuehrt wird und beim Shutdown ordentlich beendet, noch folgenden Befehl ausfuehren:

sudo update-rc.d seaf-cli defaults
5 Kommentare
  1. jip sagt:

    Thanks for the writeup :)

    I’ve tried your script but for me it doesn’t work. I’ve got a Lubuntu system and have installed the regular Seattle Linux client, which also comes with the seaf-cli binary. The binary is located at: /usr/bin/seaf-cli.

    I want to auto-start the cli client every time my machine boots up (so before the user logs on).

    The thing is, I’m also running Seafile server on the same machine. It does automatically start as per the Seafile instructions on I want to automatically sync a library to an externally connected USB drive (as a portable backup so to speak) with the Seafile client.

    Do you think it could be going wrong because I’m trying to run the client before the server is finished starting up? I’ve tried to add ’sleep 10′ before the su -c „$DAEMON start“ – $USER statement. Doesn’t help either. I’ve also changed the su -c „$DAEMON start“ – $USER statement to su -c „$DAEMON start“ – $USER >> /path/to/logfile.txt. In the log I can see that the client starts without errors… But after I login the ’seaf-cli status‘ statement gives me many errors, indicating that the client isn’t actually running.

    Any idea how I can fix this issue?

  2. Sven sagt:

    Okay I have two Ideas:

    I experienced that the seafile-cli isn’t as robust as the the default client for windows/linux and it is maybe a problem for the seaf-cli that the server is still not up as you already mentioned.

    Do you also start the seafile server by an init-script?
    If yes, take a look at this page how-to-managing-services-with-update-rc-d/. There is a section about Custom Priorities.
    It may help to set two different custom priorities for the init.d scripts e.g. update-rc.d seafile-server defaults 20 and update-rc.d seaf-cli defaults 90.

    When the seaf-cli gets started was the USB-Device already mounted?

  3. jip sagt:

    Thanks for replying! It seems to be solved and your script works flawlessly :)

    Like you suggested it seems the problem was with auto-mounting the external drive. I’ve set up auto mounting as follows.

    In the Lubuntu file manager I went to Edit -> Preferences -> Volume Management -> Check: Mount mountaable volumes automatically on program startup and Check: Mount removable media automatically when they are inserted.

    This didn’t work… But the output of seafile-cli suggested that seaf-cli started without problems.

    The right way to auto mount the volume was with fstab. So syncing now works even before the user logs in.

    Thanks again!

  4. jip sagt:

    Actually it turns out the problem was of a different nature!

    During configuration I set up the Seafile client to use the external drive as its default location for syncing new libraries. Looked like a convenient option to me for my use case. However, I wasn’t aware that the Seafile client also stores important data in the .seafile-data directory on this default path…. So when my external drive was not attached the seafile client was actually missing a lot of the necessary files to operate.

    I’ve changed the default path to an internal disk, copied over the existing data, and now the seafile client will start without problems when the external drive is not available.

Hinterlasse eine Antwort

Deine Email-Adresse wird niemals veröffentlicht. Pflichtfelder sind mit * gekennzeichnet.