updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / crashplan / crashplan
blob8d5e5080a7173010904947e8b750168fe556bfc5
1 #!/usr/bin/env bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 if [[ -f /etc/profile.d/jre.sh ]]; then
7 . /etc/profile.d/jre.sh
8 elif [[ -f /etc/profile.d/openjdk6.sh ]]; then
9 . /etc/profile.d/openjdk6.sh
12 WD=/opt/crashplan
13 CRASHPLAN=$WD/lib/com.backup42.desktop.jar
14 ARGS=com.backup42.service.CPService
15 PIDFILE=/var/run/crashplan.pid
16 VARS=$WD/install.vars
17 CONFIG=$WD/bin/run.conf
19 test -f $VARS || exit 0
20 test -f $CONFIG || exit 0
21 test -f $CRASHPLAN || exit 0
23 . $VARS
24 . $CONFIG
28 if [[ ${LC_ALL} ]]; then
29 LOCALE=`sed 's/\..*//g' <<< ${LC_ALL}`
30 export LC_ALL="${LOCALE}.UTF-8"
31 elif [[ ${LC_CTYPE} ]]; then
32 LOCALE=`sed 's/\..*//g' <<< ${LC_CTYPE}`
33 export LC_CTYPE="${LOCALE}.UTF-8"
34 elif [[ ${LANG} ]]; then
35 LOCALE=`sed 's/\..*//g' <<< ${LANG}`
36 export LANG="${LOCALE}.UTF-8"
37 else
38 export LANG="en_US.UTF-8"
41 [[ -f $PIDFILE ]] && PID=`cat $PIDFILE`
43 case "$1" in
44 start)
45 stat_busy "Starting CrashPlan Engine"
46 PWD=`pwd`
47 cd $WD
48 [[ -z "$PID" ]] && nice -n 19 $JAVA_HOME/bin/java $SRV_JAVA_OPTS -classpath $CRASHPLAN:$WD/lang $ARGS > $WD/log/engine_output.log 2> $WD/log/engine_error.log &
49 if [ $? -gt 0 ]; then
50 stat_fail
51 else
52 PID=`/bin/ps -eo 'pid,cmd'| grep 'app=CrashPlanService' | grep -v grep | awk '{sub("^ ", "", $0); print $0}' | cut -d " " -f 1`
53 echo $PID > $PIDFILE
54 add_daemon crashplan
55 stat_done
57 cd $PWD
59 stop)
60 stat_busy "Stopping CrashPlan Engine"
61 [[ ! -z "&PID" ]] && kill $PID &> /dev/null
62 if [ $? -gt 0 ]; then
63 stat_fail
64 else
65 rm_daemon crashplan
66 rm $PIDFILE
67 stat_done
70 restart)
71 $0 stop
72 sleep 1
73 $0 start
75 status)
76 PID=`/bin/ps -eo 'pid,cmd'| grep 'app=CrashPlanService' | grep -v grep | awk '{sub("^ ", "", $0); print $0}' | cut -d " " -f 1`
77 if [[ -n "$PID" ]]; then
78 echo "CrashPlan (pid $PID) is running."
79 else
80 echo "CrashPlan is stopped."
84 echo "Usage: $0 <start|stop|restart|status>" >&2
85 exit 3
87 esac