View difference between Paste ID: sibgcmEr and 1VTZRK5p
SHOW: | | - or go back to the newest paste.
1
#!/bin/sh
2
3
##########################################################################
4-
# pyLoad STARTUP and UPDATE SCRIPT for Synology NAS
4+
# pyLoad STARTUP SCRIPT for QNAP pyload-noarch.ipk
5
# AUTOSTART pyLoad as DAEMON - UPDATE PROGRAM FILES
6
# <./S99pyload info>  for  more  details  and  help
7
##########################################################################
8
9-
PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin
9+
PATH=/opt/bin:/opt/sbin:/opt/share/pyload:/sbin:/bin:/usr/sbin:/usr/bin
10-
SYNO=/usr/syno/bin
10+
DAEMON="pyLoadCore --daemon"
11-
DAEMON="python /opt/pyload/pyLoadCore.py --daemon"
11+
12
QUIT="pyLoadCore --quit"
13-
QUIT="python /opt/pyload/pyLoadCore.py --quit"
13+
STATUS="pyLoadCore --status"
14-
STATUS="python /opt/pyload/pyLoadCore.py --status"
14+
VERSION="pyLoadCore --version"
15-
VERSION="python /opt/pyload/pyLoadCore.py --version"
15+
16-
RELEASE_SRC="https://bitbucket.org/spoob/pyload/get/v0.4.8.zip"
16+
17
18-
LOG="/volume1/public/.pyload/Logs/log.txt" #your path to the Logfile here!
18+
19-
SCRN=/opt/etc/init.d/S99pyload
19+
20
##########################################################################
21
22
start()
23
{
24
        if [ `$STATUS` = false ]; then
25
          echo "try to start `$VERSION`"
26
          echo "`$VERSION`" `$DAEMON`
27-
          echo "`$VERSION`: try to start"
27+
28-
          echo "`$VERSION`:" `$DAEMON`
28+
29
        echo "`$VERSION` is already up, nothing to do!"
30-
               if [ `$STATUS` -gt 3 ]; then
30+
31-
                   echo "`$VERSION`: successfully started"
31+
               if [ `$STATUS` != false ]; then
32
                   echo "`$VERSION` successfully started"
33
               else
34
                  `$DAEMON`
35
               fi
36
}
37
38
##########################################################################
39
40
stop()
41-
          echo "`$VERSION`: try to kill myself"
41+
42
          if [ `$STATUS` != false ]; then
43
          echo "try to stop `$VERSION`"
44
          echo "`$QUIT`"
45
          else
46
        echo "`$VERSION` is not running, nothing to do!"
47-
setup()
47+
48
}
49-
   echo "pyLoad: installing latest stable release - only run once!"
49+
50-
   cd /opt/; $SYNO/wget --no-check-certificate -q $RELEASE_SRC
50+
51
52-
                 echo "pyLoad: successfully loaded latest stable release"
52+
53
{
54-
                 setup
54+
        if [ `$STATUS` != false ];then
55
        stop; sleep 5;
56-
              unzip -q spoob-pyload*.zip; rm spoob-pyload*.zip
56+
57
        echo "try to update `$VERSION`"
58-
                 echo "pyLoad: archive unzipped and removed"; sleep 2
58+
59
        cd /opt #edit path
60-
                 setup
60+
        wget --no-check-certificate -q `$UPDATE_SRC`
61
              if [ $? -eq 0 ] ; then
62-
                 mv spoob-pyload* pyload
62+
                 echo "successfully loaded dev version"
63
              else
64-
                 cd /opt/pyload/
64+
65-
                 python pyLoadCore.py -s
65+
66
              unzip-unzip -q tip.zip; rm tip.zip
67-
                 setup
67+
68
                 echo "archive unzipped and removed"; sleep 2
69
              else
70
                 update
71
              fi
72
                 rsync -qr /opt/spoob*/ /opt/share/pyload/ # edit path
73
              if [ $? -eq 0 ] ; then
74
                 echo "`$VERSION` successfully updated"
75-
#   if [ `$STATUS` -gt 3 ]; then
75+
76
                 update
77-
#   fi
77+
78-
        echo "UPDATE: updating `$VERSION`"
78+
                # rm -rf /opt/spoob*/
79-
        echo "`date '+%d.%m.%Y %T'` INFO      Updating `$VERSION`" >>$LOG
79+
        echo "`date '+%d.%m.%Y %T'` INFO      Update complete"
80-
        cd /opt/
80+
81-
        $SYNO/wget --no-check-certificate -q $UPDATE_SRC
81+
82
83-
                 echo "UPDATE: successfully loaded dev version"
83+
###############################################################################
84
85
debug()
86
{
87-
              unzip -q spoob-pyload*.zip; rm spoob-pyload*.zip
87+
    if [ `$STATUS` != false ]; then
88
        echo "restart `$VERSION`"
89-
                 echo "UPDATE: archive unzipped and removed"; sleep 2
89+
90
        sleep 5
91
        debug
92
    else
93-
                 $SYNO/rsync -qr /opt/spoob-pyload-*/ /opt/pyload/
93+
        echo "try to start in debug mode and print out debug log"
94
        echo "`$VERSION`:" `$DAEMON $DAEMON_OPTS`
95-
                 echo "UPDATE: `$VERSION` successfully updated"
95+
96
        if [ `$STATUS` != false ]; then
97
               echo "successfully started debug mode"
98
               echo ""
99-
                 rm -rf /opt/spoob-pyload-*/
99+
100-
                 echo "`date '+%d.%m.%Y %T'` INFO      Update complete" >>$LOG
100+
101
               tail -f $LOG
102
        else
103
               `$DAEMON $DAEMON_OPTS`
104
        fi
105
    fi
106-
stable()
106+
107
108-
   if [ `$STATUS` -gt 3 ]; then
108+
109
110-
   fi
110+
111-
        echo "`$VERSION`: installing latest stable release"
111+
112-
        mkdir pyload_tip; cd /opt/pyload/; cp -r * /opt/pyload_tip/
112+
     if [ `$STATUS` != false ];then
113-
        cd /opt/
113+
          echo "`$VERSION` Process ID is `$STATUS`"
114-
        $SYNO/wget --no-check-certificate -q $RELEASE_SRC
114+
115
echo -e '\e[33m####################################################################\e[0m'
116-
                 echo "`$VERSION`: successfully loaded latest stable release"
116+
117
echo -e '\e[33m# start   = start pyLoad (default)\e[0m'
118-
                 stable
118+
119
echo -e '\e[33m# restart = stop and start pyLoad\e[0m'
120-
              unzip -q spoob-pyload*.zip; rm spoob-pyload*.zip
120+
121
echo -e '\e[33m# info    = print out PID and status of pyLoad\e[0m'
122-
                 echo "`$VERSION`: archive unzipped and removed"; sleep 2
122+
123
echo -e '\e[33m####################################################################\e[0m'
124-
                 stable
124+
125
     else
126-
                 $SYNO/rsync -qr /opt/spoob-pyload-*/ /opt/pyload/
126+
           echo "`$VERSION` process is not active, nothing to do!"
127
     fi
128-
                 echo "`$VERSION`: successfully installed"
128+
129
130-
                 stable
130+
131
132-
                 rm -rf /opt/spoob-pyload-*/
132+
133
{
134
     start
135
     while [ `$STATUS` != false ]; do
136
        echo ""
137
        echo "***** ctrl + c to STOP OUTPUT and return *****"
138
        echo ""
139
        tail -f $LOG
140-
    if [ `$STATUS` -gt 3 ]; then
140+
141-
        echo "`$VERSION`: already performing ... restart"
141+
142
143
##########################################################################
144
145
case "$1" in
146-
        echo "`$VERSION`: try to start in debug mode + show output"
146+
147
              start
148
              ;;
149-
        if [ `$STATUS` -gt 3 ]; then
149+
150-
               echo "`$VERSION`: successfully startet in debug mode"
150+
151
              ;;
152
      restart)
153
              stop
154
              sleep 5
155
              start
156
              ;;
157
      update)
158
              update
159
              ;;
160
      debug)
161
              debug
162
              ;;
163
      info)
164
              info
165-
     if [ `$STATUS` -gt 3 ];
165+
166-
     then
166+
167-
          echo "`$VERSION`: Process ID is `$STATUS`"
167+
168
              ;;
169
      *)
170
echo "Usage: (start|stop|restart|update|debug|info|show)" >&2
171
              exit 1
172
              ;;
173
esac
174-
echo -e '\e[33m# setup   = install pyLoad **only run at the first time**\e[0m'
174+
175-
echo -e '\e[33m# stable  = run the latest stable version\e[0m'
175+
176-
echo -e '\e[33m# update  = update program files\e[0m'
176+
177
##########################################################################
178
# End of script
179
##########################################################################