aboutsummarylogtreecommitdiffstats
path: root/crashplan-pro
blob: 4ff51355bc6d04d5a1c8d1ac7c4aedff55b8fdd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash

. /etc/rc.conf
. /etc/rc.d/functions

if [[ -f /etc/profile.d/jre.sh ]]; then
    . /etc/profile.d/jre.sh
elif [[ -f /etc/profile.d/openjdk6.sh ]]; then
    . /etc/profile.d/openjdk6.sh
fi

WD=/opt/crashplan-pro
CRASHPLAN=$WD/bin/CrashPlanEngine
VARS=$WD/install.vars
CONFIG=$WD/bin/run.conf

test -f $VARS || exit 0
test -f $CONFIG || exit 0
test -f $CRASHPLAN || exit 0

. $VARS
. $CONFIG



if [[ ${LC_ALL} ]]; then
    LOCALE=`sed 's/\..*//g' <<< ${LC_ALL}`
    export LC_ALL="${LOCALE}.UTF-8"
elif [[ ${LC_CTYPE} ]]; then
    LOCALE=`sed 's/\..*//g' <<< ${LC_CTYPE}`
    export LC_CTYPE="${LOCALE}.UTF-8"
elif [[ ${LANG} ]]; then
    LOCALE=`sed 's/\..*//g' <<< ${LANG}`
    export LANG="${LOCALE}.UTF-8"
else
    export LANG="en_US.UTF-8"
fi

[[ `$CRASHPLAN status` != "CrashPlan Engine is stopped." ]] && PID=`$CRASHPLAN status | sed -r 's/CrashPlan Engine \(pid ([0-9]+)\).*/\1/'`

case "$1" in
    start)
	stat_busy "Starting CrashPlan Engine"
	PWD=`pwd`
	cd $WD
	[[ -z "$PID" ]] && nice -n 19 $CRASHPLAN start > /dev/null
	if [ $? -gt 0 ]; then
	    stat_fail
	else
	    add_daemon crashplan
	    stat_done
	fi
	cd $PWD
	;;
    stop)
	stat_busy "Stopping CrashPlan Engine"
	[[ ! -z "&PID" ]] && $CRASHPLAN stop &> /dev/null
	if [ $? -gt 0 ]; then
	    stat_fail
	else
	    rm_daemon crashplan
	    stat_done
	fi
	;;
    restart)
	$0 stop
	sleep 1
	$0 start
	;;
    status)
	$CRASHPLAN status
	;;
    *)
	echo "Usage: $0 <start|stop|restart|status>" >&2
	exit 3
	;;
esac