Dropbox命令行工具安装与开机自启动

系统要求
# 2.4 以上版本的C 库
# wget 命令
# Python 2.5
# web 浏览器

Dropbox命令行工具安装与使用的常用命令

cd ~ && wget -O – "http://www.dropbox.com/download?plat=lnx.x86" | tar xzf –
cd ~ && wget -O – "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf –
~/.dropbox-dist/dropboxd
killall dropbox

wget –no-check-certificate https://www.dropbox.com/download?dl=packages/dropbox.py
chmod 755 ~/dropbox.py
python dropbox.py start
python dropbox.py stop
python dropbox.py status

系统开机自启动脚本 /etc/init.d/dropbox

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

DAEMON=.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

自启动命令:

chmod +x /etc/init.d/dropbox
update-rc.d dropbox defaults

Debian系统可能还需要在脚本前加上:

### 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

本文来源及其它LINUX系统的使用方法参考: http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment#debianubuntu

Published by

@XiaoKyun

双鱼男,过分热心的好人。