Created
September 24, 2012 16:30
-
-
Save djs52/3776868 to your computer and use it in GitHub Desktop.
Init script (/etc/init.d/spideroak) and default (/etc/default/spideroak) for SpiderOak from https://launchpad.net/~tonio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# defaults file for spideroak daemon headless mode | |
# SpiderOak does not currently support handling the initial setup of | |
# an account, or setup of a new device within an account entirely from | |
# the command line. This is because the new user setup process requires | |
# the user to answer a CAPTCHA and some other validation processes. | |
# | |
# Instead, we recommend connecting to the headless server using "ssh -X" | |
# to forward X11 connections back to your local desktop machine with X11 | |
# running. Within your ssh session to the headless server, run SpiderOak | |
# for the first time. You should see the graphical user interface for | |
# SpiderOak appear on your local desktop, being forwarded over the X11 | |
# tunnel created by ssh. | |
# | |
# Once this is done, you can consider enable activating Spideroak | |
# Headless mode by changing the following settings. | |
# Start SpiderOak in headless mode from init.d script ? | |
# only allowed values are "yes", "no", "true" and "false" | |
SPIDEROAK_ENABLE=yes | |
# Which user/uid should be used to start SpiderOak ? | |
# Change this the username you used while performing the initial setup. | |
# This value defaults to "root" | |
SPIDEROAK_USER=root | |
# SpiderOak can be using lots of resources. | |
# In case you run Spideroak on a device such as a Media Player PC, you | |
# may want to reduce SpiderOak priority... | |
# -20 is the minimum, and 19 the maximum, default is 0 | |
SPIDEROAK_PRIORITY= | |
# Tell Spideroak to read the following environment variables | |
# see https://spideroak.com/forum/threads/id/2174/?page=1#snap_post12867 | |
SPIDEROAK_INTERNAL=1 | |
# Set log level (any of "debug", "info", "warn", "error") | |
# see https://spideroak.com/forum/threads/id/548/?page=1#snap_post4979 | |
SPIDEROAK_LOG_LEVEL=info |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# | |
### BEGIN INIT INFO | |
# Provides: | |
# Required-Start: | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: SpiderOak daemon | |
# Description: This script runs the SpiderOak backup software | |
# in headless mode | |
### END INIT INFO | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=/usr/bin/SpiderOak | |
DAEMON_OPTS=--headless | |
NAME=SpiderOak | |
DESC="SpiderOak daemon" | |
PIDFILE="/var/run/SpiderOak.pid" | |
test -x $DAEMON || exit 0 | |
set -e | |
# Include SpiderOak defaults if available | |
if [ -f /etc/default/spideroak ] ; then | |
. /etc/default/spideroak | |
fi | |
# Set default user | |
if [ -z $SPIDEROAK_USER ] ; then | |
SPIDEROAK_USER=root | |
fi | |
# Set priority | |
if [ -z $SPIDEROAK_PRIORITY ] ; then | |
SPIDEROAK_PRIORITY=0 | |
fi | |
# Set user home dir | |
HOMEDIR=$(cat /etc/passwd | grep $SPIDEROAK_USER | awk -F: '{print $6}') | |
do_start() { | |
if [ `pidof $NAME` ] ; then | |
echo "$DESC is already running" | |
else | |
case "$SPIDEROAK_ENABLE" in | |
yes|YES|true|TRUE) | |
if [ ! -f $HOMEDIR/.SpiderOak/preferences.dat ] ; then | |
echo "Not starting $DESC, you need to graphically perform the initial setup." | |
return 0 | |
fi | |
echo -n "Starting $DESC: " | |
export SPIDEROAK_LOG_LEVEL SPIDEROAK_INTERNAL SPIDEROAK_LOG_ROTATE_SIZE SPIDEROAK_LOG_ROTATE_COUNT | |
start-stop-daemon --start --quiet --background --make-pidfile --nicelevel $SPIDEROAK_PRIORITY \ | |
--pidfile $PIDFILE --chuid $SPIDEROAK_USER --exec $DAEMON -- $DAEMON_OPTS | |
if [ $? -eq 0 ] ; then | |
echo "Ok" | |
return 0 | |
else | |
echo "Error" | |
return 1 | |
fi | |
;; | |
*) | |
echo "Not starting $DESC, check /etc/default/spideroak to enable it." | |
;; | |
esac | |
fi | |
} | |
do_stop() { | |
if [ ! `pidof $NAME` ] ; then | |
echo "$DESC is already stopped" | |
else | |
echo -n "Stopping $DESC: " | |
start-stop-daemon --stop --quiet --signal 9 \ | |
--pidfile $PIDFILE | |
if [ $? -eq 0 ] ; then | |
echo "Ok" | |
return 0 | |
else | |
echo "Error" | |
return 1 | |
fi | |
fi | |
} | |
do_log() { | |
LOGTYPE=$1 | |
LOGFILE=$(ls -r $HOMEDIR/.SpiderOak | grep -e "^${LOGTYPE}_[0-9]*\.log" | head -n1) | |
tail -f $HOMEDIR/.SpiderOak/$LOGFILE | |
} | |
case "$1" in | |
start) | |
do_start | |
;; | |
stop) | |
do_stop | |
;; | |
restart|force-reload) | |
do_stop | |
if [ $? -eq 0 ] ; then | |
sleep 1 | |
do_start | |
fi | |
;; | |
status) | |
if [ -f "$PIDFILE" ]; then | |
pid=$(cat $PIDFILE) | |
else | |
pid="x" | |
fi | |
if [ `pidof SpiderOak | grep "$pid" | wc -l` -ne 0 ] ; then | |
echo "SpiderOak is currently running." | |
else | |
echo "SpiderOak is stopped." | |
fi | |
;; | |
log|log-oak) | |
do_log oak | |
;; | |
log-spider) | |
do_log spider | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop|restart|force-reload|status|log|log|oak|log-spider}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that the default config dir and prefs file have changed.
It's now better to check for
$HOMEDIR/.config/SpiderOak/prefs.dat