[SCRIPT] create-autorun.sh
-
- New here
- Posts: 7
- Joined: Thu Nov 27, 2014 2:06 am
Re: [SCRIPT] autorun.sh installer
Thanks for the reply, turns out I was missing a / before the destination, it would run, no errors and then just wouldn't copy. Or if it was copying who knows where it went!
-
- Easy as a breeze
- Posts: 372
- Joined: Fri Apr 08, 2016 6:42 pm
Re: [SCRIPT] autorun.sh installer
Hi, just to double check, does this run the scripts after resuming from sleep? Thanks!
- OneCD
- Guru
- Posts: 12155
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] autorun.sh installer
Hmm, good question! I don't think so, but I've never used sleep mode.
-
- Easy as a breeze
- Posts: 372
- Joined: Fri Apr 08, 2016 6:42 pm
Re: [SCRIPT] autorun.sh installer
Would be nice to auto run some script also when shutdown
- OneCD
- Guru
- Posts: 12155
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] autorun.sh installer
Well, you could always hook into /etc/init.d/poweroff
You'd need to place your hook after every boot though.
You'd need to place your hook after every boot though.
-
- New here
- Posts: 5
- Joined: Thu Nov 24, 2011 4:49 pm
Re: [SCRIPT] autorun.sh installer
Hi OneCD,
thank you very much for your create-autorun script. It works very fine.
But I have troubles starting nzbget V19 as a service while system startup (nzbget -D).
The autorun.log shows me the start of 010-script.sh.
Everything seems to be fine but nzbget doesn't start.
When I start autorun.sh manually nzbget will be started.
Any ideas?
Thanks in advance.
010-script.sh...
/opt/bin/nzbget/nzbget -D
autorun.log...
Mon Apr 24 20:00:04 CEST 2017 ----- running autorun.sh -----
Mon Apr 24 20:00:04 CEST 2017 - /share/HDA_DATA/.system/autorun/scripts/010-script.sh
thank you very much for your create-autorun script. It works very fine.
But I have troubles starting nzbget V19 as a service while system startup (nzbget -D).
The autorun.log shows me the start of 010-script.sh.
Everything seems to be fine but nzbget doesn't start.
When I start autorun.sh manually nzbget will be started.
Any ideas?
Thanks in advance.
010-script.sh...
/opt/bin/nzbget/nzbget -D
autorun.log...
Mon Apr 24 20:00:04 CEST 2017 ----- running autorun.sh -----
Mon Apr 24 20:00:04 CEST 2017 - /share/HDA_DATA/.system/autorun/scripts/010-script.sh
- OneCD
- Guru
- Posts: 12155
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] autorun.sh installer
Hi and welcome to the forum.
Or, you could install the NZBGet QPKG so you won't need a script to start NZBGet daemonized. But this method requires even more work to get it running after boot.
Looks like you're using NZBGet installed through Entware. If so, Entware may not have been init before your script is run. You may need to introduce a wait so that Entware has time to load during NAS boot, and NZBGet becomes available. I already have a wait script to do this for SABnzbd. Please advise if you'd like to use this method.seppi0815 wrote:But I have troubles starting nzbget V19 as a service while system startup (nzbget -D).
The autorun.log shows me the start of 010-script.sh.
Everything seems to be fine but nzbget doesn't start.
When I start autorun.sh manually nzbget will be started.
Or, you could install the NZBGet QPKG so you won't need a script to start NZBGet daemonized. But this method requires even more work to get it running after boot.
-
- New here
- Posts: 5
- Joined: Thu Nov 24, 2011 4:49 pm
Re: [SCRIPT] autorun.sh installer
I did it this way
- OneCD
- Guru
- Posts: 12155
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] autorun.sh installer
Oh, I see.
Are you using Entware or Optware? I ask because your NZBGet path is in /opt/bin
Are you using Entware or Optware? I ask because your NZBGet path is in /opt/bin
-
- New here
- Posts: 5
- Joined: Thu Nov 24, 2011 4:49 pm
Re: [SCRIPT] autorun.sh installer
I use Optware.
- OneCD
- Guru
- Posts: 12155
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] autorun.sh installer
Maybe you could try this:
Edit your existing launcher (010-script.sh), and replace the contents with those shown above.
This will wait for up to 10 minutes for /opt/bin/nzbget/nzbget to appear when run.
Code: Select all
#!/bin/sh
[ ! -z "$1" ] && timeout="$1" || timeout=600
[ ! -z "$2" ] && testfile="$2" || testfile="/opt/bin/nzbget/nzbget"
scriptname="$(/usr/bin/basename $0)"
waitlog="/var/log/wait-counter-${scriptname}.log"
if [ ! -e "$testfile" ]; then
(
for ((count=1; count<=timeout; count++)); do
sleep 1
[ -e "$testfile" ] &&
{
echo "waited for $count seconds" >> "$waitlog"
true
exit
}
done
false
)
if [ "$?" -ne "0" ]; then
echo "timeout exceeded!" >> "$waitlog"
/sbin/write_log "[$scriptname] Could not continue: timeout exceeded." 1
false
else
# if here, then testfile has appeared, so reload environment
. /etc/profile
. /root/.profile
# finally, launch NZBGet
/opt/bin/nzbget/nzbget -D
fi
fi
This will wait for up to 10 minutes for /opt/bin/nzbget/nzbget to appear when run.
-
- New here
- Posts: 5
- Joined: Thu Nov 24, 2011 4:49 pm
Re: [SCRIPT] autorun.sh installer
Thanks for your reply.
While reboot "autorun.log" is written and 10 min later "wait...log" is created... timeout exceeded
Is it better to reinstall nzbget via optware?
While reboot "autorun.log" is written and 10 min later "wait...log" is created... timeout exceeded
Is it better to reinstall nzbget via optware?
- OneCD
- Guru
- Posts: 12155
- Joined: Sun Aug 21, 2016 10:48 am
- Location: "... there, behind that sofa!"
Re: [SCRIPT] autorun.sh installer
I don't know if NZBGet is available through Optware. Optware is deprecated.
Try Entware instead. NZBGet is available as an installable IPK.
Try Entware instead. NZBGet is available as an installable IPK.
Code: Select all
opkg install nzbget
-
- New here
- Posts: 5
- Joined: Thu Nov 24, 2011 4:49 pm
Re: [SCRIPT] autorun.sh installer
Thank you for the "Entware" hint.
I didn't know about the end of Optware
I removed it, installed Entware and nzbget.
It works fine and starts actually without autorun scripts.
Thanks again for you help.
I didn't know about the end of Optware
I removed it, installed Entware and nzbget.
It works fine and starts actually without autorun scripts.
Thanks again for you help.
-
- New here
- Posts: 2
- Joined: Mon Dec 08, 2014 2:36 am
Re: [SCRIPT] autorun.sh installer
There is an order if QNAP initialization, it looks somewhat like this:
You have to run autorun.sh in background. I ended up with these scripts:
/share/MD0_DATA/.system/autorun/autorun.sh
/share/MD0_DATA/.system/autorun/autorun2.sh
- ...
- LCD shows Starting Service Please wait
- ...
- autorun.sh
- ...
- Optware initialization
- ...
- QNAP beeps, initialization is complete
You have to run autorun.sh in background. I ended up with these scripts:
/share/MD0_DATA/.system/autorun/autorun.sh
Code: Select all
#!/bin/bash
AUTORUN_PATH="/share/MD0_DATA/.system/autorun"
SCRIPT_STORE_PATH="/share/MD0_DATA/.system/autorun/scripts"
LOGFILE="/var/log/autorun.log"
echo "$(date) ----- running autorun.sh -----" >> "$LOGFILE"
"$AUTORUN_PATH/autorun2.sh" 2>&1 >> "$LOGFILE" &
echo "$(date) ----- finished autorun.sh -----" >> "$LOGFILE"
Code: Select all
#!/bin/bash
AUTORUN_PATH="/share/MD0_DATA/.system/autorun"
SCRIPT_STORE_PATH="/share/MD0_DATA/.system/autorun/scripts"
LOGFILE="/var/log/autorun.log"
echo "$(date) ----- running autorun2.sh -----" >> "$LOGFILE"
for i in ${SCRIPT_STORE_PATH}/* ; do
if [[ -x $i ]] ; then
echo -n "$(date)" >> "$LOGFILE"
echo " - $i " >> "$LOGFILE"
$i 2>&1 >> "$LOGFILE"
fi
done
echo "$(date) ----- finished autorun2.sh -----" >> "$LOGFILE"