Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DS211> more /var/packages/AutoSub-BootstrapBill/scripts/start-stop-status
- #!/bin/sh
- # Package
- PACKAGE="autosub-bootstrapbill"
- DNAME="AutoSub-BootstrapBill"
- # Others
- INSTALL_DIR="/usr/local/${PACKAGE}"
- PYTHON_DIR="/usr/local/python"
- PYTHON=${PYTHON_DIR}/bin/python
- PATH="${PYTHON_DIR}/bin:/usr/local/bin:/bin:/usr/bin:/usr/syno/bin"
- RUNAS="${PACKAGE}"
- PROG_PY="${INSTALL_DIR}/AutoSub.py"
- LOG_FILE="${INSTALL_DIR}/AutoSubService.log"
- PID_FILE="${INSTALL_DIR}/autosub.pid"
- start_daemon ()
- {
- # Launch the application in the background
- if [ -f ${INSTALL_DIR}/config.properties ]
- then
- su - ${RUNAS} -c "PATH=${PATH} ${PYTHON} ${PROG_PY} -c "${INSTALL_DIR}/config.properties" -d -l"
- echo `ps w | grep ${PACKAGE} | grep -v -E 'grep' | awk '{print $1}' > $PID_FILE`
- else
- su - ${RUNAS} -c "PATH=${PATH} ${PYTHON} ${PROG_PY} -d -l"
- echo `ps w | grep ${PACKAGE} | grep -v -E 'grep' | awk '{print $1}' > $PID_FILE`
- fi
- }
- stop_daemon ()
- {
- # Kill the application
- kill `cat ${PID_FILE}`
- wait_for_status 1 20 || kill -9 `cat ${PID_FILE}`
- rm -f ${PID_FILE}
- }
- daemon_status ()
- {
- if [ -f ${PID_FILE} ] && kill -0 `cat ${PID_FILE}` > /dev/null 2>&1; then
- return
- fi
- rm -f ${PID_FILE}
- return 1
- }
- run_in_console ()
- {
- # Launch the application in the foreground
- su - ${RUNAS} -c "PATH=${PATH} ${PYTHON} ${PROG_PY} -c "${INSTALL_DIR}/config.properties" -l"
- echo `ps w | grep ${PACKAGE} | grep -v -E 'grep' | awk '{print $1}' > $PID_FILE`
- }
- case $1 in
- start)
- if daemon_status; then
- echo ${DNAME} is already running
- exit 0
- else
- echo Starting ${DNAME} ...
- start_daemon
- exit $?
- fi
- ;;
- stop)
- if daemon_status; then
- echo Stopping ${DNAME} ...
- stop_daemon
- exit $?
- else
- echo ${DNAME} is not running
- exit 0
- fi
- ;;
- status)
- if daemon_status; then
- echo ${DNAME} is running
- exit 0
- else
- echo ${DNAME} is not running
- exit 1
- fi
- ;;
- console)
- run_in_console
- exit $?
- ;;
- log)
- echo ${LOG_FILE}
- exit 0
- ;;
- *)
- exit 1
- ;;
- esac
- DS211>
Advertisement
Add Comment
Please, Sign In to add comment