Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ##########################################################################
- # pyLoad STARTUP SCRIPT for QNAP pyload-noarch.ipk
- # AUTOSTART pyLoad as DAEMON - UPDATE PROGRAM FILES
- # <./S99pyload info> for more details and help
- ##########################################################################
- PATH=/opt/bin:/opt/sbin:/opt/share/pyload:/sbin:/bin:/usr/sbin:/usr/bin
- DAEMON="pyLoadCore --daemon"
- DAEMON_OPTS="--debug"
- QUIT="pyLoadCore --quit"
- STATUS="pyLoadCore --status"
- VERSION="pyLoadCore --version"
- UPDATE_SRC="https://bitbucket.org/spoob/pyload/get/tip.zip"
- ##########################################################################
- # COMMANDS START
- ##########################################################################
- start()
- {
- if [ `$STATUS` = false ]; then
- echo "try to start `$VERSION`"
- echo "`$VERSION`" `$DAEMON`
- sleep 2
- else
- echo "`$VERSION` is already up, nothing to do!"
- fi
- if [ `$STATUS` != false ]; then
- echo "`$VERSION` successfully started"
- else
- `$DAEMON`
- fi
- }
- ##########################################################################
- stop()
- {
- if [ `$STATUS` != false ]; then
- echo "try to stop `$VERSION`"
- echo "`$QUIT`"
- else
- echo "`$VERSION` is not running, nothing to do!"
- fi
- }
- ##########################################################################
- update()
- {
- if [ `$STATUS` != false ];then
- stop; sleep 5;
- else
- echo "try to update `$VERSION`"
- fi
- cd /opt #edit path
- wget --no-check-certificate -q `$UPDATE_SRC`
- if [ $? -eq 0 ] ; then
- echo "successfully loaded dev version"
- else
- update
- fi
- unzip-unzip -q tip.zip; rm tip.zip
- if [ $? -eq 0 ] ; then
- echo "archive unzipped and removed"; sleep 2
- else
- update
- fi
- rsync -qr /opt/spoob*/ /opt/share/pyload/ # edit path
- if [ $? -eq 0 ] ; then
- echo "`$VERSION` successfully updated"
- else
- update
- fi
- # rm -rf /opt/spoob*/
- echo "`date '+%d.%m.%Y %T'` INFO Update complete"
- start
- }
- ###############################################################################
- debug()
- {
- if [ `$STATUS` != false ]; then
- echo "restart `$VERSION`"
- stop
- sleep 5
- debug
- else
- echo "try to start in debug mode and print out debug log"
- echo "`$VERSION`:" `$DAEMON $DAEMON_OPTS`
- sleep 2
- if [ `$STATUS` != false ]; then
- echo "successfully started debug mode"
- echo ""
- echo "***** ctrl + c to STOP OUTPUT and return *****"
- echo ""
- tail -f $LOG
- else
- `$DAEMON $DAEMON_OPTS`
- fi
- fi
- }
- ##########################################################################
- info()
- {
- if [ `$STATUS` != false ];then
- echo "`$VERSION` Process ID is `$STATUS`"
- echo ""
- echo -e '\e[33m####################################################################\e[0m'
- echo -e '\e[33m# OPERATIONS\e[0m'
- echo -e '\e[33m# start = start pyLoad (default)\e[0m'
- echo -e '\e[33m# stop = stop pyLoad\e[0m'
- echo -e '\e[33m# restart = stop and start pyLoad\e[0m'
- echo -e '\e[33m# debug = enable debug mode + output\e[0m'
- echo -e '\e[33m# info = print out PID and status of pyLoad\e[0m'
- echo -e '\e[33m# show = print out Logfile while executing\e[0m'
- echo -e '\e[33m####################################################################\e[0m'
- else
- echo "`$VERSION` process is not active, nothing to do!"
- fi
- }
- ##########################################################################
- show()
- {
- start
- while [ `$STATUS` != false ]; do
- echo ""
- echo "***** ctrl + c to STOP OUTPUT and return *****"
- echo ""
- tail -f $LOG
- done
- }
- ##########################################################################
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- sleep 5
- start
- ;;
- update)
- update
- ;;
- debug)
- debug
- ;;
- info)
- info
- ;;
- show)
- show
- ;;
- *)
- echo "Usage: (start|stop|restart|update|debug|info|show)" >&2
- exit 1
- ;;
- esac
- exit 0
- ##########################################################################
- # End of script
- ##########################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement