Dropbox在无头机器中

时间:2016-08-03 01:00:11

标签: linux daemon

我正在尝试设置Dropbox以无头模式运行。我将守护进程下载到〜/ .dropbox-dist / dropboxd,并且可以使用我的机器进行身份验证。这是init.d脚本:

#!/bin/sh
#dropbox service
DROPBOX_USERS="user1 user2"

DAEMON=.dropbox-dist/dropboxd

start() {
   echo "Starting dropbox..."
   for dbuser in $DROPBOX_USERS; do
       HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
       if [ -x $HOMEDIR/$DAEMON ]; then
           HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
       fi
   done
}

stop() {
   echo "Stopping dropbox..."
   for dbuser in $DROPBOX_USERS; do
       HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
       if [ -x $HOMEDIR/$DAEMON ]; then
           start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
       fi
   done
}

status() {
   for dbuser in $DROPBOX_USERS; do
       dbpid=`pgrep -u $dbuser dropbox`
       if [ -z $dbpid ] ; then
           echo "dropboxd for USER $dbuser: not running."
       else
           echo "dropboxd for USER $dbuser: running (pid $dbpid)"
       fi
   done
}

case "$1" in

   start)
       start
       ;;
   stop)
       stop
       ;;
   restart|reload|force-reload)
       stop
       start
       ;;
   status)
       status
       ;;
   *)
       echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
       exit 1

esac

exit 0

当我运行dropbox.py状态时,它返回Dropbox没有响应。当我做sudo服务dropbox stop时,它显示:

No /home/me/.dropbox-dist/dropboxd found running; none killed.

如何解决此错误?

1 个答案:

答案 0 :(得分:1)

你可以试试这个版本

#!/bin/sh
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: dropbox service
### END INIT INFO

#dropbox service
USER="root"
HOME=/root
DROPBOX=/root/bin/dropbox.py

start() {
   $DROPBOX start
}

stop() {
   $DROPBOX stop
}

status() {
   $DROPBOX status
}

case "$1" in

   start)
       start
       ;;
   stop)
       stop
       ;;
   restart)
       stop
       start
       ;;
   status)
       status
       ;;
   *)
       echo "Usage: /etc/init.d/dropbox {start|stop|restart|status}"
       exit 1

esac

exit 0