Skip to content

Instantly share code, notes, and snippets.

@sir-ragna
Created October 29, 2014 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sir-ragna/ece8db7248bc2e723cc6 to your computer and use it in GitHub Desktop.
Save sir-ragna/ece8db7248bc2e723cc6 to your computer and use it in GitHub Desktop.
Dropbox control script
#! /bin/bash
## Install dropbox
## `cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -`
## This basically creates a folder `~/.dropbox-dist`
## Initiate `~/.dropbox-dist/dropboxd` and it will ask you some questions the first
## time you run it.
pid=`pidof dropbox`
command=${1:-'start'} # $1 is the first arg
# if $1 is empty use 'start'
# This is how you define optional params
if [[ -n $pid ]]
then
if [[ $command == 'start' ]]
then
echo "Dropbox is already running(${pid})."
exit 1
elif [[ $command == 'stop' ]]
then
kill "${pid}"
echo ' * dropbox stopped'
exit 0
elif [[ $command == 'status' ]]
then
echo " * dropbox is running(${pid})"
else
echo "usage: $0 [start|stop|status]"
exit 1
fi
else
if [[ $command == 'start' ]]
then
~/.dropbox-dist/dropboxd&
exit 0
elif [[ $command == 'stop' ]]
then
echo "Dropbox is not running."
exit 1
elif [[ $command == 'status' ]]
then
echo " * dropbox is not running"
else
echo "usage: $0 [start|stop|status]"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment