#!/sbin/runscript # Simple transcription of the crashplan systemd init script # Note that this script can be found in /opt/crashplan/bin/CrashPlanEngine # in typical installs extra_commands="checkconfig" description="Starts the Code42 CrashPlan Daemon" description_checkconfig="Verifies environment exists" CRASHPLAN_DIR="/opt/crashplan" # Typical installation directory CRASHPLAN_IVARS="${CRASHPLAN_DIR}/install.vars" # Variables recorded by installation CRASHPLAN_PIDFILE="/var/run/${SVCNAME}.pid" # Target location for current PID CRASHPLAN_RCONF="${CRASHPLAN_DIR}/bin/run.conf" # Should be a config file CRASHPLAN_DAEMON="${CRASHPLAN_DIR}/lib/com.backup42.desktop.jar" # Jar containing relevant classes CRASHPLAN_SERVICE="com.backup42.service.CPService" # Name of the service class CRASHPLAN_FULL_CP="${CRASHPLAN_DAEMON}:${CRASHPLAN_DIR}/lang" # Probably the java class path # This function performs basic configuration checks # If anything is missing or broken we can't start the process checkconfig() { CRASHPLAN_RC=0 # The installation directory for crashplan if [ ! -d $CRASHPLAN_DIR ] ; then eerror "CrashPlan does not exist at ${CRASHPLAN_DIR}" CRASHPLAN_RC=1 fi # We need the daemon file if [ ! -e $CRASHPLAN_DAEMON ]; then eerror "${CRASHPLAN_DAEMON} is missing!" fi # Parameters needed for the run if [ -e $CRASHPLAN_RCONF ]; then . $CRASHPLAN_RCONF else eerror "${CRASHPLAN_RCONF} is missing!" CRASHPLAN_RC=1 fi # Check to make sure install variable file exists if [ -e "${CRASHPLAN_IVARS}" ]; then . $CRASHPLAN_IVARS else eerror "${CRASHPLAN_IVARS} is missing!" CRASHPLAN_RC=1 fi # We need a LANG variable to end up as .UTF-8 # worst case we'll fall back to en_US.UTF-8 if [ ${LANG} ]; then LOCALE=$(sed 's/\..*//g' <<< ${LANG}) export LANG="${LOCALE}.UTF-8" else export LANG="en_US.UTF-8" ewarn "A valid local could not be extracted from \$LANG" ewarn "Defaulting in ${LANG}" fi return $CRASHPLAN_RC } # We need net to operate # but it may be more sensible to list # this as a start-after depend() { need localmount use net } # Actual startup routine - depends on checkconfig start() { ebegin "Starting ${SVCNAME}" checkconfig || eend 1 start-stop-daemon --pidfile "${CRASHPLAN_PIDFILE}" \ --make-pidfile --chdir "${CRASHPLAN_DIR}" \ --stdout $CRASHPLAN_DIR/log/engine_output.log \ --stderr $CRASHPLAN_DIR/log/engine_error.log \ --nice 19 --start --background --progress \ --exec $JAVACOMMON -- ${SRV_JAVA_OPTS} -classpath ${CRASHPLAN_FULL_CP} ${CRASHPLAN_SERVICE} eend $? } # Stop routine should attempt to kill via TERM, then KILL stop() { ebegin "Stopping ${SVCNAME}" start-stop-daemon --pidfile "${CRASHPLAN_PIDFILE}" \ --progress --stop $JAVACOMMON --retry SIGTERM/15 SIGKILL/5 eend $? }