forked from dmacias72/unRAID_6.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sickbeard_unplugged_64.plg
780 lines (714 loc) · 24.8 KB
/
sickbeard_unplugged_64.plg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
<?xml version='1.0' standalone='yes'?>
<PLUGIN>
<!--
This is the dev branch!!!
This Plugin installs and controls Sickbeard for UnRaid.
All dependencies are installed as needed and everything is controlable from the webgui
Credits:
Benni-Chan: Originally creating the plug-in. Much of his code is still in
place and changes have been made for new features and fixes.
WW: Install & Data Directory size, some config page formatting, multi-branch selection
I have...
* probably missed some credits here, not intentional but I do not have a perfect memory!
* made changes and added features myself. I have removed the changelog from the plug-in itself.
* done this because since I am hosting the plug-ins on github, there is an accurate changelog with the commits.
-->
<FILE Name="/boot/packages/python-cheetah-2.4.4-x86_64-1alien.tgz" Run="upgradepkg --install-new">
<URL>http://www.slackware.com/~alien/sbrepos/14.1/x86_64/python-cheetah/python-cheetah-2.4.4-x86_64-1alien.tgz</URL>
<MD5>f2e4ab251fe05c3c5e03bb5ed20b3b7a</MD5>
</FILE>
<FILE Name="/boot/packages/sqlite-3.7.17-x86_64-1.txz" Run="upgradepkg --install-new">
<URL>http://slackware.cs.utah.edu/pub/slackware/slackware64-14.1/slackware64/ap/sqlite-3.7.17-x86_64-1.txz</URL>
<MD5>730417ec4d8158c6bb5862417107b9f4</MD5>
</FILE>
<FILE Name="/boot/packages/git-1.8.4-x86_64-1.txz" Run="upgradepkg --install-new">
<URL>http://slackware.osuosl.org/slackware64-14.1/slackware64/d/git-1.8.4-x86_64-1.txz</URL>
<MD5>e24d44ec30e7afc16c5509c4d9446140</MD5>
</FILE>
<FILE Name="/boot/config/plugins/sickbeard/sickbeard.png">
<URL>--no-check-certificate https://github.com/downloads/W-W/unRAID/sickbeard.png</URL>
</FILE>
<FILE Name="/boot/config/plugins/images/device_status.png">
<URL>--no-check-certificate https://github.com/downloads/Influencer/UNplugged/device_status.png</URL>
</FILE>
<FILE Name="/boot/config/plugins/images/new_config.png">
<URL>--no-check-certificate https://github.com/downloads/Influencer/UNplugged/new_config.png</URL>
</FILE>
<FILE Name="/boot/config/plugins/images/information.png">
<URL>--no-check-certificate https://github.com/downloads/Influencer/UNplugged/information.png</URL>
</FILE>
<!-- clean up previous install -->
<FILE Name="/tmp/sickbeard-cleanup" Run="/bin/bash">
<INLINE>
<![CDATA[
[ -d /usr/local/emhttp/plugins/sickbeard ] && rm -f -R /usr/local/emhttp/plugins/sickbeard
[ -f /etc/rc.d/rc.sickbeard ] && rm -f /etc/rc.d/rc.sickbeard
[ -f /boot/config/plugins/sickbeard/plgver.txt ] && rm -f /boot/config/plugins/sickbeard/plgver.txt
rm /tmp/sickbeard-cleanup
]]>
</INLINE>
</FILE>
<FILE Name="/boot/config/plugins/sickbeard/plgver.txt">
<INLINE>
<![CDATA[
2.5.5
]]>
</INLINE>
</FILE>
<FILE Name="/boot/config/plugins/sickbeard/sickbeard.cfg">
<INLINE>
<![CDATA[
# SickBeard configuration:
SERVICE="disable"
INSTALLDIR="/usr/local/sickbeard"
DATADIR="/usr/local/sickbeard"
RUNAS="nobody"
PLG_STORAGESIZE="yes"
PLG_DATACHECK="yes"
FORCEUPDATE="no"
INSTALLURL="https://github.com/midgetspy/Sick-Beard"
BRANCH="master"
PORT="8081"
]]>
</INLINE>
</FILE>
<FILE Name="/tmp/checkconfig" Run="/bin/bash">
<INLINE>
<![CDATA[
#!/bin/sh
test=`cat /boot/config/plugins/sickbeard/sickbeard.cfg | grep BRANCH`
if [[ $test = "" ]]; then
echo "" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "INSTALLURL=\"https://github.com/midgetspy/Sick-Beard\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "BRANCH=\"master\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
fi
plgstorage=`cat /boot/config/plugins/sickbeard/sickbeard.cfg | grep PLG_STORAGESIZE`
if [[ $plgstorage = "" ]]; then
echo "PLG_STORAGESIZE=\"yes\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
fi
plgdata=`cat /boot/config/plugins/sickbeard/sickbeard.cfg | grep PLG_DATACHECK`
if [[ $plgdata = "" ]]; then
break
else
sed "/$plgdata^/d" /boot/config/plugins/sickbeard/sickbeard.cfg >tmp
mv tmp /boot/config/plugins/sickbeard/sickbeard.cfg
fi
plgforceupdate=`cat /boot/config/plugins/sickbeard/sickbeard.cfg | grep FORCEUPDATE`
if [[ $plgforceupdate = "" ]]; then
echo "FORCEUPDATE=\"yes\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
fi
rm /tmp/checkconfig
]]>
</INLINE>
</FILE>
<FILE Name="/etc/rc.d/rc.sickbeard" Mode="0770">
<INLINE>
<![CDATA[
#!/bin/sh
# start|stop|restart|enable|disable|install|update|storagesize|datacheck SickBeard.
sickbeard_start()
{
# no-op if not enabled
if [ $SERVICE != "enable" ]; then
sed -i "s/"disable"/"enable/"" $CONFIG
fi
# no-op if already running
if [ -r /var/run/sickbeard/sickbeard.pid ]; then
return
fi
# if directory doesn't exist or sickbeard is not found, install it
if [[ "$INSTALLDIR" != "" && ! -e "$INSTALLDIR/SickBeard.py" ]]; then
sickbeard_install
fi
cd
#Check if force-update should be done on startup
if [ "$FORCEUPDATE" = "yes" ]; then
CMDLINE="sudo -u $RUNAS python $INSTALLDIR/SickBeard.py --daemon --forceupdate --port $PORT --datadir $DATADIR --pidfile /var/run/sickbeard/sickbeard.pid > /dev/null 2>&1"
echo "Starting SickBeard: $CMDLINE"
sleep 1
nohup $CMDLINE > /dev/null 2>&1 &
else
CMDLINE="sudo -u $RUNAS python $INSTALLDIR/SickBeard.py --daemon --port $PORT --datadir $DATADIR --pidfile /var/run/sickbeard/sickbeard.pid > /dev/null 2>&1"
echo "Starting SickBeard: $CMDLINE"
sleep 1
nohup $CMDLINE > /dev/null 2>&1 &
fi
TIMER=0
while [ ! -e /var/run/sickbeard/sickbeard.pid ]; do
sleep 1
let TIMER=$TIMER+1
echo -n $TIMER
if [ $TIMER -gt 10 ]; then
echo -n "sickbeard.pid not created for some reason"
break
fi
done
echo "... OK"
}
sickbeard_stop()
{
# no-op if not running
if [ ! -r /var/run/sickbeard/sickbeard.pid ]; then
return
fi
echo "Stopping SickBeard..."
sleep 1
kill $(cat /var/run/sickbeard/sickbeard.pid)
sleep 3
if [ -e /var/run/sickbeard/sickbeard.pid ]; then
kill -9 $(cat /var/run/sickbeard/sickbeard.pid )
rm /var/run/sickbeard/sickbeard.pid
fi
echo "... OK"
sleep 1
}
sickbeard_restart()
{
sickbeard_stop
sleep 1
sickbeard_start
}
sickbeard_buttonstart()
{
echo "Enabling Sickbeard"
CONFIG="/boot/config/plugins/sickbeard/sickbeard.cfg"
if [ -f $CONFIG ]; then
sed -i "s/"disable"/"enable/"" $CONFIG
sleep 3
echo "Starting Sickbeard"
sickbeard_start
fi
}
sickbeard_update()
{
sickbeard_stop
sleep 1
sickbeard_install
sleep 1
sickbeard_start
}
write_config()
{
echo "# SickBeard configuration:" > /boot/config/plugins/sickbeard/sickbeard.cfg
echo "SERVICE=\"$SERVICE\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "INSTALLDIR=\"$INSTALLDIR\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "DATADIR=\"$DATADIR\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "RUNAS=\"$RUNAS\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "PLG_STORAGESIZE=\"$PLG_STORAGESIZE\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "INSTALLURL=\"$INSTALLURL\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "BRANCH=\"$BRANCH\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "PORT=\"$PORT\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
echo "FORCEUPDATE=\"$FORCEUPDATE\"" >> /boot/config/plugins/sickbeard/sickbeard.cfg
}
sickbeard_change_settings()
{
PORT="$2"
INSTALLDIR="$3"
DATADIR="$4"
if [ $DATADIR == "" ]; then
$DATADIR="$INSTALLDIR"
fi
if [ $RUNAS != $1 ]; then
chown -R $1:users "$INSTALLDIR" "$DATADIR"
fi
RUNAS="$1"
PLG_STORAGESIZE="$5"
FORCEUPDATE="$6"
INSTALLURL="$7"
BRANCH="$8"
# create SickBeard user if necessary
if [[ $RUNAS != "nobody" && $RUNAS != "root" ]]; then
if ( ! grep -q ^$RUNAS /etc/passwd ); then
useradd -r -g users -d / -s /bin/false $RUNAS &> /dev/null
cp /etc/passwd /etc/shadow /boot/config
fi
fi
}
sickbeard_enable()
{
SERVICE=enable
sickbeard_change_settings $1 $2 $3 $4 $5 $6 $7 $8 $9
write_config
sickbeard_restart
}
sickbeard_disable()
{
sickbeard_stop
SERVICE=disable
sickbeard_change_settings $1 $2 $3 $4 $5 $6 $7 $8 $9
write_config
}
sickbeard_install()
{
echo "Installing latest version of SickBeard..."
if [ ! -e "$INSTALLDIR" ]; then
mkdir -p $INSTALLDIR
fi
if [ ! -e "$DATADIR" ]; then
mkdir -p $DATADIR
fi
if [ -e ""$INSTALLDIR"/version.txt" ]; then
rm ""$INSTALLDIR"/version.txt"
fi
cd /tmp
git clone -b $BRANCH $INSTALLURL Sick-Beard
cp -Rfu /tmp/Sick-Beard/* $INSTALLDIR
cd /tmp/Sick-Beard/
git rev-parse HEAD >> "$INSTALLDIR"/version.txt
rm -Rf /tmp/Sick-Beard
chown -R $RUNAS:users "$INSTALLDIR" "$DATADIR"
sleep 3
echo "... OK"
sleep 1
}
sickbeard_storagesize()
{
if [ $1 ] && [ $2 ]; then
if [ -d $1 ]; then
INST=`du -sh $1 | cut -f1`
elif [ -f $1 ]; then
INST=`ls -lah $1 | awk '{ print $5}'`
fi
if [ -d $2 ]; then
DAT=`du -sh $2 | cut -f1`
elif [ -f $2 ]; then
DAT=`ls -lah $2 | awk '{ print $5}'`
fi
if [ $1 == $2 ]; then
echo "<p style="margin-left:10px\;">Storage memory usage: install + data directory: <b>$INST</b></p>"
else
echo "<p style="margin-left:10px\;">Storage memory usage: install directory: <b>$INST</b>, data directory: <b>$DAT</b></p>"
fi
elif [ $1 ]; then
if [ -d $1 ]; then
INST=`du -sh $1 | cut -f1`
elif [ -f $1 ]; then
INST=`ls -lah $1 | awk '{ print $5}'`
fi
echo "<p style="margin-left:10px\;">Storage memory usage: <b>$INST</b></p>"
fi
}
sickbeard_datacheck()
{
array=( ramfs proc tempfs sysfs )
fs=$( stat -f -c '%T' $DATADIR )
for i in "${array[@]}"
do
if [ $i = $fs ]; then
echo "<p style="color:red\;margin-left:10px\;margin-right:10px\;"><b>WARNING:</b> Your Data Directory is not persistent and WILL NOT survive a reboot. Please locate Data Directory on disk for persistency</p>"
break
elif [ $i = msdos ]; then
echo "<p style="color:red\;margin-left:10px\;margin-right:10px\;"><b>WARNING:</b> Your Data Directory is located on your flash drive. This will decrease your flash drives life span!</p>"
break
else
echo "<p style="color:green\;margin-left:10px\;margin-right:10px\;">Your data will persist after a reboot</p>"
break
fi
done
}
sickbeard_updateplg()
{
cd /boot/config/plugins
[ -f sickbeard_unplugged_64.plg.old ] && rm -f sickbeard_unplugged_64.plg.old
if [ -f sickbeard_unplugged_64.plg ]; then
mv sickbeard_unplugged_64.plg sickbeard_unplugged_64.plg.old
echo "Updating plugin"
wget -q --no-check-certificate https://github.com/dmacias72/unRAID_6.0/raw/master/sickbeard_unplugged_64.plg
/usr/local/sbin/installplg /boot/config/plugins/sickbeard_unplugged_64.plg
else
echo "Updating plugin"
wget -q --no-check-certificate https://github.com/dmacias72/unRAID_6.0/raw/master/sickbeard_unplugged_64.plg
/usr/local/sbin/installplg /boot/config/plugins/sickbeard_unplugged_64.plg
fi
}
sickbeard_downgradeplg()
{
cd /boot/config/plugins
if [ -f sickbeard_unplugged_64.plg.old ]; then
rm -f /sickbeard_unplugged_64.plg
mv sickbeard_unplugged_64.plg.old sickbeard_unplugged_64.plg
echo "downgrading plugin"
/usr/local/sbin/installplg /boot/config/plugins/sickbeard_unplugged_64.plg
fi
}
# read our configuration
source /boot/config/plugins/sickbeard/sickbeard.cfg
case "$1" in
'start')
sickbeard_start
;;
'stop')
sickbeard_stop
;;
'restart')
sickbeard_restart
;;
'enable')
sickbeard_enable $2 $3 $4 $5 $6 $7 $8 $9
;;
'disable')
sickbeard_disable $2 $3 $4 $5 $6 $7 $8 $9
;;
'install')
sickbeard_install
;;
'update')
sickbeard_update
;;
'storagesize')
sickbeard_storagesize $2 $3
;;
'datacheck')
sickbeard_datacheck
;;
'updateplg')
sickbeard_updateplg
;;
'downgradeplg')
sickbeard_downgradeplg
;;
'buttonstart')
sickbeard_buttonstart
;;
*)
echo "usage $0 start|stop|restart|enable|disable|install|update|storagesize|datacheck|updateplg|downgradeplg"
esac
]]>
</INLINE>
</FILE>
<FILE Name="/usr/local/emhttp/plugins/sickbeard/sickbeard.page">
<INLINE>
<![CDATA[
Menu="NetworkServices"
Icon="sickbeard.png"
Version="1.0"
Author="Benjamin Waller; Influencer"
Type="php"
Title="SickBeard"
]]>
</INLINE>
</FILE>
<FILE Name="/usr/local/emhttp/plugins/sickbeard/sickbeard.png">
<LOCAL>/boot/config/plugins/sickbeard/sickbeard.png</LOCAL>
</FILE>
<FILE Name="/usr/local/emhttp/plugins/sickbeard/device_status.png">
<LOCAL>/boot/config/plugins/images/device_status.png</LOCAL>
</FILE>
<FILE Name="/usr/local/emhttp/plugins/sickbeard/new_config.png">
<LOCAL>/boot/config/plugins/images/new_config.png</LOCAL>
</FILE>
<FILE Name="/usr/local/emhttp/plugins/sickbeard/information.png">
<LOCAL>/boot/config/plugins/images/information.png</LOCAL>
</FILE>
<FILE Name="/usr/local/emhttp/plugins/sickbeard/sickbeard.php">
<INLINE>
<![CDATA[
<?PHP
$sickbeard_cfg = parse_ini_file( "/boot/config/plugins/sickbeard/sickbeard.cfg" );
$sickbeard_installed = file_exists( $sickbeard_cfg["INSTALLDIR"] . "/SickBeard.py" ) ? "yes" : "no";
$sickbeard_rollback = file_exists( "boot/config/plugins/sickbeard_unplugged_64.plg.old" ) ? "yes" : "no";
if ($sickbeard_installed=="yes")
{
$sickbeard_running = file_exists( "/var/run/sickbeard/sickbeard.pid") ? "yes" : "no";
if ($sickbeard_cfg['PLG_STORAGESIZE']=="yes")
$sickbeard_datasize = shell_exec ( "/etc/rc.d/rc.sickbeard storagesize $sickbeard_cfg[INSTALLDIR] $sickbeard_cfg[DATADIR]" );
if ($sickbeard_cfg['PLG_DATACHECK']=="yes")
$sickbeard_datacheck = shell_exec ( "/etc/rc.d/rc.sickbeard datacheck" );
$sickbeard_plgver = shell_exec ( "cat /boot/config/plugins/sickbeard/plgver.txt" );
if (file_exists($sickbeard_cfg["INSTALLDIR"] . "/version.txt"))
$sickbeard_curversion = trim(shell_exec( "cat $sickbeard_cfg[INSTALLDIR]/version.txt" ));
else
$sickbeard_curversion = "couldn't determine the SickBeard version";
$sickbeard_newversion = trim(shell_exec( "cd /tmp/ && wget -q -O feed.atom --no-check-certificate $sickbeard_cfg[INSTALLURL]/commits/$sickbeard_cfg[BRANCH].atom && cat feed.atom | sed -n 's|tag:github.com,2008:Grit::Commit/\(.*\)|\\1|p' | sed '1q;d' | cut -d' ' -f5- | sed 's/....\(.*\)...../\\1/' && rm feed.atom" ));
}
?>
<div style="width: 49%; float:left">
<div id="title">
<span class="left">Status: <img src='/plugins/sickbeard/device_status.png'>
<?if ($sickbeard_installed=="yes"):?>
<?if ($sickbeard_running=="yes"):?>
<a href="http://<?=$var['NAME'];?>:<?=$sickbeard_cfg['PORT'];?>" target="_blank"><span class="green"><b>RUNNING</b></span></a><span style="font-size:12px;"> with version: <b><?=$sickbeard_curversion?></b></span>
<?else:?>
<span class="red"><b>STOPPED</b></span>
<?endif;?>
<?else:?>
<span class="red"><b>NOT INSTALLED</b></span>
<?endif;?>
</span>
</div>
<?if ($sickbeard_installed=="yes"):?>
<?if ($sickbeard_running=="yes"):?>
<div style="position:relative;float:left;width:50%;text-align:right; margin-bottom:24px">
<form name="sickbeard_start_stop" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard stop">
<input type="submit" name="runCmd" value="Stop">
</form>
</div>
<div style="position:relative;float:left;width:50%;margin-bottom:24px">
<form name="sickbeard_restart" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard restart">
<input type="submit" name="runCmd" value="Restart">
</form>
</div>
<?else:?>
<div style="position:relative;float:left;width:100%;text-align:center;margin-bottom:24px">
<form name="sickbeard_start" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard buttonstart">
<input type="submit" name="runCmd" value="Start">
</form>
</div>
<?endif;?>
<?else:?>
<div style="position:relative;float:left;width:100%;text-align:center;margin-bottom:24px">
<form name="sickbeard_install" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard install">
<input type="submit" name="runCmd" value="Install">
<form name="sickbeard_update1" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard updateplg">
<input type="submit" name="runCmd" value="Update PLG">
</form>
</div>
<div style="position:relative;float:left;width:50%;text-align:left;margin-bottom:24px">
<form name="sickbeard_downgrade" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard downgradeplg">
<input type="submit" name="runCmd" value="Downgrade PLG">
<form name="sickbeard_update" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard updateplg">
<input type="submit" name="runCmd" value="Update PLG">
</form>
</div>
<?endif;?><br/>
<? if ($sickbeard_installed=="yes"): ?>
<center><hr size="3" width="50%" color="grey"></center>
<p style="margin-left:10px;">Installed from <?=$sickbeard_cfg['BRANCH']?> branch of <?=$sickbeard_cfg['INSTALLURL']?> site</p>
<? if ($sickbeard_cfg['PLG_STORAGESIZE']=="yes"): ?>
<?=$sickbeard_datasize?>
<? endif; ?>
<?=$sickbeard_datacheck?>
<p style="margin-left:10px;"><b>Plug-in Version: <?=$sickbeard_plgver;?></b></p>
<? if (strcmp($sickbeard_curversion, $sickbeard_newversion)!=0 && $sickbeard_curversion!="couldn't determine the SickBeard version"): ?>
<center>
<form name="sickbeard_settings" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard update">
<p style="color:blue;margin-left:10px;">Update available to version: <b><?=$sickbeard_newversion;?></b></p>
<hr size="3" width="50%" color="grey" style="margin-bottom:15px">
<input type="submit" name="runCmd" value="Update">
</form>
</center>
<? endif; ?>
<? endif; ?>
</div>
<div style="width: 49%; float:right">
<div id="title">
<span class="left">Configuration: <img src='/plugins/sickbeard/new_config.png'></span>
</div>
<form name="sickbeard_settings" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="cmd" value="/etc/rc.d/rc.sickbeard">
<table class="settings">
<tr>
<td>Enable SickBeard:</td>
<td>
<select name="arg1" size="1">
<?=mk_option($sickbeard_cfg['SERVICE'], "disable", "No");?>
<?=mk_option($sickbeard_cfg['SERVICE'], "enable", "Yes");?>
</select>
</td>
</tr>
<tr>
<td>Install directory:</td>
<td><input type="text" name="arg4" maxlength="60" value="<?=$sickbeard_cfg['INSTALLDIR'];?>"></td>
</tr>
<tr>
<td>Data directory:</td>
<td><input type="checkbox" name="use_data" <?=($sickbeard_cfg['DATADIR']!=$sickbeard_cfg['INSTALLDIR'])?"checked=\"checked\"":"";?> onChange="checkDATADIR(this.form);"> <input type="text" name="arg5" style="width:86%" maxlength="60" value="<?=$sickbeard_cfg['DATADIR'];?>"></td>
</tr>
<tr>
<td>Port:</td>
<td><input type="text" name="arg3" maxlength="40" value="<?=$sickbeard_cfg['PORT'];?>"></td>
</tr>
<tr>
<td>Run as user:</td>
<td>
<select name="runas" size="1" onChange="checkUSER(this.form);">
<?=mk_option($sickbeard_cfg['RUNAS'], "nobody", "nobody");?>
<?=mk_option($sickbeard_cfg['RUNAS'], "root", "root");?>
<option value='other'<?=($sickbeard_cfg['RUNAS'] != "root" && $sickbeard_cfg['RUNAS'] != "nobody")?" selected=yes":"" ;?>>other</option>
</select>
<input type="hidden" name="arg2" style="width:66%" maxlength="40" value="<?=$sickbeard_cfg['RUNAS'];?>">
</td>
</tr>
<tr><td>---</td></tr>
<tr>
<td>Show storage memory usage:</td>
<td>
<select name="storagesize" size="1" onChange="checkSTORAGE(this.form);">
<?=mk_option($sickbeard_cfg['PLG_STORAGESIZE'], "yes", "Yes");?>
<?=mk_option($sickbeard_cfg['PLG_STORAGESIZE'], "no", "No");?>
</select>
<input type="hidden" name="arg6" value="<?=$sickbeard_cfg['PLG_STORAGESIZE'];?>">
</td>
</tr>
<tr>
<td>Force Update on Start?</td>
<td>
<select name="arg7" size="1">
<?=mk_option($sickbeard_cfg['FORCEUPDATE'], "yes", "Yes");?>
<?=mk_option($sickbeard_cfg['FORCEUPDATE'], "no", "No");?>
</select>
</td>
</tr>
</table>
<div align="center">
<hr size="3" align="center" width="75%" color="grey" style="margin-top:20px;margin-bottom:18px" >
<input type="submit" name="runCmd" value="Apply" style="margin-bottom:8px">
<? if ($sickbeard_installed=="no"): ?>
<input type="button" value="Show advanced configuration" style="margin-bottom:35px" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide advanced configuration'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show advanced configuration'; }">
<? endif; ?>
<button type="button" style="margin-bottom:35px" onClick="done();">Done</button>
</div>
<div>
<div style="display: none;">
<br />
<table class="settings">
<tr>
<td style="width:auto">Install from:</td>
<td>
<select name="url" size="1" onChange="checkURL(this.form);">
<?=mk_option($sickbeard_cfg['INSTALLURL'], "https://github.com/midgetspy/Sick-Beard", "official github");?>
<option value='other'<?=($sickbeard_cfg['INSTALLURL'] != "https://github.com/midgetspy/Sick-Beard")?" selected=yes":"" ;?>>other github</option>
</select>
<input type="hidden" name="arg8" maxlength="100" style="text-align:left;width:63%" value="<?=$sickbeard_cfg['INSTALLURL'];?>">
<img src="/plugins/sickbeard/information.png" title="Installing from other than official github site is not recommended. Use this option at your own risk!"/>
</td>
</tr>
<tr>
<td style="width:auto">Specify branch:</td>
<td>
<select name="branch" size="1" onChange="checkBRANCH(this.form);">
<?=mk_option($sickbeard_cfg['BRANCH'], "master", "master");?>
<option value='other'<?=($sickbeard_cfg['BRANCH'] != "master")?" selected=yes":"" ;?>>other</option>
</select>
<input type="hidden" name="arg9" maxlength="40" style="text-align:left;width:71%" value="<?=$sickbeard_cfg['BRANCH'];?>">
<img src="/plugins/sickbeard/information.png" title="Installing other branch than master is not recommended. Use this option at your own risk!"/>
</td>
</tr>
</table>
</div>
</div>
</form>
<br />
</div>
<script type="text/javascript">
function checkUSER(form)
{
if (form.runas.selectedIndex < 2 )
{
form.arg2.value = form.runas.options[form.runas.selectedIndex].value;
form.arg2.type = "hidden";
}
else
{
form.arg2.value = "<?=$sickbeard_cfg['RUNAS'];?>";
form.arg2.type = "text";
}
}
function checkDATADIR(form)
{
if (form.use_data.checked == false )
{
form.arg5.value = form.arg4.value;
form.arg5.type = "hidden";
}
else
{
form.arg5.value = "<?=$sickbeard_cfg['DATADIR'];?>";
form.arg5.type = "text";
}
}
function checkSTORAGE(form)
{
form.arg6.value = form.storagesize.options[form.storagesize.selectedIndex].value;
}
function checkDATA(form)
{
form.arg7.value = form.datacheck.options[form.datacheck.selectedIndex].value;
}
function checkURL(form)
{
if (form.url.selectedIndex < 1 )
{
form.arg8.value = form.url.options[form.url.selectedIndex].value;
form.arg8.type = "hidden";
}
else
{
form.arg8.value = "<?=$sickbeard_cfg['INSTALLURL'];?>";
form.arg8.type = "text";
}
}
function checkBRANCH(form)
{
if (form.branch.selectedIndex < 1 )
{
form.arg9.value = form.branch.options[form.branch.selectedIndex].value;
form.arg9.type = "hidden";
}
else
{
form.arg9.value = "<?=$sickbeard_cfg['BRANCH'];?>";
form.arg9.type = "text";
}
}
checkUSER(document.sickbeard_settings);
checkDATADIR(document.sickbeard_settings);
checkSTORAGE(document.sickbeard_settings);
checkDATA(document.sickbeard_settings);
checkURL(document.sickbeard_settings);
checkBRANCH(document.sickbeard_settings);
</script>
]]>
</INLINE>
</FILE>
<!-- event handler -->
<FILE Name="/usr/local/emhttp/plugins/sickbeard/event/disks_mounted" Mode="0770">
<INLINE>
<![CDATA[
#!/bin/bash
source /boot/config/plugins/sickbeard/sickbeard.cfg
if [ $SERVICE = enable ]; then
/etc/rc.d/rc.sickbeard start
fi
]]>
</INLINE>
</FILE>
<!-- event handler -->
<FILE Name="/usr/local/emhttp/plugins/sickbeard/event/unmounting_disks" Mode="0770">
<INLINE>
<![CDATA[
#!/bin/bash
/etc/rc.d/rc.sickbeard stop
]]>
</INLINE>
</FILE>
<FILE Name="/tmp/sickbeard-install" Run="/bin/bash">
<INLINE>
<![CDATA[
# include our config vars
source /boot/config/plugins/sickbeard/sickbeard.cfg
# create sickbeard-writable directory for pid file
if [ ! -e /var/run/sickbeard ]; then
mkdir /var/run/sickbeard
chown $RUNAS:users /var/run/sickbeard
chmod 0777 /var/run/sickbeard
fi
rm /tmp/sickbeard-install
]]>
</INLINE>
</FILE>
<FILE Name="/var/log/plugins/sickbeard">
<INLINE>
<![CDATA[
]]>
</INLINE>
</FILE>
</PLUGIN>