#!/bin/sh case $# in 1) QPKG_NAME=HybridBackup ;; 2) QPKG_NAME=$2 ;; *) echo "Usage: $0 {start|stop|restart} [\$QPKG_NAME]" exit 1 esac QPKG_INSTALL_PATH=`/sbin/getcfg -f /etc/config/qpkg.conf ${QPKG_NAME} Install_Path` QPKG_VERSION=`/sbin/getcfg -f /etc/config/qpkg.conf ${QPKG_NAME} Version` export QPKG_HOME=${QPKG_INSTALL_PATH} export QPKG_VERSION=${QPKG_VERSION} export QPKG_NAME=${QPKG_NAME} CC3_HOME="$( cd "$(dirname "$0")" ; pwd -P )" ENV="${CC3_HOME}/bin/env.sh" QPKG_START_TIME_FILE_PATH=${CC3_HOME}/.qpkg_start_time CBS_ARCHIVED=${QPKG_INSTALL_PATH}/../CloudBackupSync_archived QNAP_ACL_LIBRARY=${CC3_HOME}/../lib/libuLinux_qnapaclhbs.so.1.0.0 case "$1" in start) ln -sf ${CC3_HOME} /mnt/ext/opt/CloudConnector3 if [ ! -f $CC3_HOME/cc3_config.db ] then if [ -f '/etc/config/cloudconnector/CloudConnector3/config.db' ] && [ ! -L '/etc/config/cloudconnector/CloudConnector3/config.db' ] then mv /etc/config/cloudconnector/CloudConnector3/config.db $CC3_HOME/cc3_config.db || exit 1 fi ln -sf $CC3_HOME/cc3_config.db /etc/config/cloudconnector/CloudConnector3/config.db fi ln -sf $CC3_HOME/cc3_config.db $CC3_HOME/config.db rm -f /usr/bin/cbs_busy ln -sf ${CC3_HOME}/bin/hbs_busy.sh /usr/bin/cbs_busy if [ -f $QNAP_ACL_LIBRARY ] && [ ! -f ${CC3_HOME}/lib/libuLinux_qnapaclhbs.so.1.0.0 ] then if [ ! -d 'lib' ] then mkdir 'lib' fi ln -sf $QNAP_ACL_LIBRARY ${CC3_HOME}/lib/libuLinux_qnapaclhbs.so.1.0.0 fi # CBS_ARCHIVED is folder and not a link if [ -d ${CBS_ARCHIVED} ] && [ ! -L ${CBS_ARCHIVED} ] then echo "move ${CBS_ARCHIVED} to ${CC3_HOME}" # move CBS_ARCHIVED to $CC3_HOME mv ${CBS_ARCHIVED} ${CC3_HOME} # create CBS_ARCHIVED link to CC3_HOME/CloudBackupSync_archived echo "create link ${CBS_ARCHIVED} to ${CC3_HOME}/CloudBackupSync_archived" ln -s ${CC3_HOME}/CloudBackupSync_archived ${CBS_ARCHIVED} elif [ -L ${CBS_ARCHIVED} ] then echo "${CBS_ARCHIVED} is a link" fi # now, migrate cbs is finished in package_routines ( source $ENV && migrate_backup_station "/etc/config/amazonS3_schedule.conf" $CC3_HOME ) daemon_mgr cc3-fastcgi start "QNAP_QPKG=$QPKG_NAME $CC3_HOME/HBS_CloudConnector3.sh start_fastcgi >/dev/null 2>&1" ( source $ENV && ${CC3_HOME}/bin/apache_conf.py add ) /etc/init.d/thttpd.sh reload || /etc/init.d/thttpd.sh restart /etc/init.d/stunnel.sh reload || /etc/init.d/stunnel.sh restart if [ -f ${CC3_HOME}/bin/hbs_qdff_mount ] then chmod +x ${CC3_HOME}/bin/hbs_qdff_mount fi killall -9 cc3_watchdog.sh ${CC3_HOME}/bin/cc3_watchdog.sh echo "$QPKG_NAME started" ;; start_fastcgi) pidof cc3-fastcgi && exit 0 # check abnormal shutdown BOOT_TIME=`/bin/cat /proc/stat | grep btime | awk '{ print $2 }'` ARG_RESTART_ABNORMAL='' if [ -f $QPKG_START_TIME_FILE_PATH ] then QPKG_START_TIME=`/usr/bin/stat -c %Y $QPKG_START_TIME_FILE_PATH` if [ "$BOOT_TIME" -gt "$QPKG_START_TIME" ]; then ARG_RESTART_ABNORMAL='-r' fi fi touch $QPKG_START_TIME_FILE_PATH ( source $ENV && cc3-fastcgi -w $CC3_HOME $ARG_RESTART_ABNORMAL start ) ;; stop_fastcgi) ( source $ENV && cc3-fastcgi -w $CC3_HOME stopall ) ;; stop) killall -9 cc3_watchdog.sh ( source $ENV && ${CC3_HOME}/bin/apache_conf.py del ) /etc/init.d/thttpd.sh reload || /etc/init.d/thttpd.sh restart /etc/init.d/stunnel.sh reload || /etc/init.d/stunnel.sh restart ( source $ENV && cc3-fastcgi -w $CC3_HOME stopall ) daemon_mgr cc3-fastcgi stop "QNAP_QPKG=$QPKG_NAME $CC3_HOME/HBS_CloudConnector3.sh stop_fastcgi >/dev/null 2>&1" kill $(pidof baiduNas) kill $(pidof P2PClient) /bin/rm -f /mnt/ext/opt/CloudConnector3 /bin/rm -f /usr/bin/cbs_busy /bin/rm $QPKG_START_TIME_FILE_PATH echo "$QPKG_NAME stopped" ;; restart) $0 stop ${QPKG_NAME} $0 start ${QPKG_NAME} ;; *) echo "Usage: $0 {start|stop|restart} [\$QPKG_NAME]" exit 1 esac exit 0