(超级)用户处理服务时遇到的问题

(超级)用户处理服务时遇到的问题

无头 Ubuntu 服务器 14.04。我已经安装了 dropbox(如此处所述http://ubuntuserverguide.com/2012/06/how-to-install-and-configure-dropbox-on-ubuntu-server-12-04.html)并将脚本添加到 init.d 中,使其在启动时启动。我最初遇到了一些问题,直到我发现我必须在文件中添加 ### BEGIN INIT INFO [...] ### END INIT INFO 内容。无论如何...

所以现在它在启动时开始:

myuser@unas14:~$ service dropbox status
dropboxd for USER myuser: running (pid 14108)

但 Dropbox 文件夹中的文件仍未同步。我尝试以 root 身份运行服务命令:

myuser@unas14:~$ sudo service dropbox status
[sudo] password for myuser:
dropboxd for USER myuser: not running.

然后运行官方 python 脚本(从这里https://www.dropbox.com/download?dl=packages/dropbox.py

myuser@unas14:~$ ./dropbox.py status
Dropbox isn't running!
myuser@unas14:~$ ./dropbox.py start
Starting Dropbox...Dropbox isn't running!
Done!
myuser@unas14:~$ ./dropbox.py status
Starting...
myuser@unas14:~$ sudo service dropbox status
dropboxd for USER myuser: running (pid 14272)

所以看来 Dropbox 正在为我以外的其他用户运行,但仍然说它正在为我的用户运行?我真的很困惑。当我手动启动 Dropbox 时,一切正常。当然,直到下次重新启动时我必须再次手动启动它。

欢迎任何反馈。提前致谢。 :)

回复 John Smith:(因为我无法在注释中使用代码格式)

myuser@unas14:~$ ps -ef|grep dropbox
myuser      1896  1837  0 12:25 pts/0    00:00:00 grep --color=auto dropbox
myuser@unas14:~$ ./dropbox.py start
Starting Dropbox...Dropbox isn't running!
Done!
myuser@unas14:~$ ps -ef|grep dropbox
myuser      2246     1 82 12:49 ?        00:00:04 /home/myuser/.dropbox-dist/dropbox-lnx.x86-2.10.52/dropbox
myuser      2276  1837  0 12:49 pts/0    00:00:00 grep --color=auto dropbox

这是我的初始化脚本:

#! /bin/sh
#
# init script for the dynamic DNS service update utility: dropbox

### BEGIN INIT INFO
# Provides:          dropbox
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: sync dropbox files
### END INIT INFO

#  dropbox service
# Replace with linux users you want to run Dropbox clients for
DROPBOX_USERS="myuser"

DAEMON=/home/myuser/.dropbox-dist/dropbox
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

相关内容