Skip to content

Instantly share code, notes, and snippets.

@cleygraf
Forked from datfaf/dropbox-setup.sh
Created May 16, 2012 07:24
Show Gist options
  • Save cleygraf/2708311 to your computer and use it in GitHub Desktop.
Save cleygraf/2708311 to your computer and use it in GitHub Desktop.
Dropbox setup on a headless Ubuntu Server (modilied for use with TurnKey LINUX)
#!/bin/sh
# Dropbox setup on a headless Ubuntu Server
# Script written by Jesse B. Hannah (http://jbhannah.net) <jesse@jbhannah.net>
#
# modified by chris@leygraf.de 2012-05-16
###
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###
#
# The user, his home folder and the default shell for this user
# Set shell to "/bin/false" in order to disallow login.
# If you like to use this user for logins don't forget to set a password!
#
USER="dropbox"
USER_HOME="/home/$USER"
USER_SHELL="/bin/bash"
# Run this script as root!
[ "$(id -u)" != "0" ] && exit 1
# Download and extract the Dropbox daemon itself into a system location
mkdir -p /usr/local/dropbox
wget -qO- http://www.dropbox.com/download/?plat=lnx.x86 | tar xz --strip 1 -C /usr/local/dropbox
useradd -m -d "$USER_HOME" -U -s "$USER_SHELL" "$USER"
chown "${USER}:${USER}" "$USER_HOME"
chmod 700 "$USER_HOME"
# For Ubuntu 9.10 and later, this is an upstart script for starting and stopping dropbox with
# `start dropbox` and `stop dropbox`. Users of earlier Ubuntu or non-upstart distros
cat <<EOF | sed -e "s,%,$,g" >/etc/init/dropbox.conf
# Dropbox upstart script
description "Dropbox"
author "Jesse B. Hannah <jesse@jbhannah.net>"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
env HOME=$USER_HOME
umask 0027
pre-start script
[ ! -e "$HOME/.dropbox/command_socket" ] || rm $HOME/.dropbox/command_socket
[ ! -e "$HOME/.dropbox/iface_socket" ] || rm $HOME/.dropbox/iface_socket
[ ! -e "$HOME/.dropbox/unlink.db" ] || rm $HOME/.dropbox/unlink.db
end script
script
export LANG=en_US.UTF-8
exec su -s /bin/sh -c /usr/local/dropbox/dropbox $USER
end script
EOF
#
# InTunrKey LINUX core the package "sudo" is missing.
# I prefer to add the newly created user to the group "sudo"
#
apt-get -y install sudo >> ./install.log 2>&1
usermod -a -G sudo "$USER"
su -s /bin/sh -c "umask 0027; /usr/local/dropbox/dropboxd" $USER
# Please execute to start dropbox
# sudo start dropbox
#
# Dropbox will use ~dropbox/Dropbox as base folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment