init script

General discussion about Gargoyle, OpenWrt or anything else even remotely related to the project

Moderator: Moderators

Post Reply
Doom
Posts: 4
Joined: Wed Apr 22, 2009 10:48 am

init script

Post by Doom »

Hi Eric,

I'm trying to run a script at startup without luck :(
I've put it in the /etc/init.d/ directory, then changed attribute using chmod 755
According to Kamikaze documentation, next step should be to enable it in this way :
/etc/init.d/filename enable
This should create a script file into /etc/rc.d/ but unfortunately I've got this error :
root@OpenWrt:/# chmod 755 /etc/init.d/filename
root@OpenWrt:/# /etc/init.d/filename
/bin/sh: can't open /etc/rc.common
Is there any particularity using Gargoyle to create init script ?
Thank you.

Regards

Eric
Site Admin
Posts: 1443
Joined: Sat Jun 14, 2008 1:14 pm

Re: init script

Post by Eric »

The init scripts in Gargoyle have exactly the same structure as in OpenWrt. I suspect the problem is something within your script -- can you post the script itself?

If what you want to do is simple you can just edit the /etc/init.d/done script, which runs right after everything is initialized. Edit the start() function in that script and add on whatever you want to do.

Doom
Posts: 4
Joined: Wed Apr 22, 2009 10:48 am

Re: init script

Post by Doom »

Sorry, you're right, some mistakes in my script
All is perfect now ;)

Thank you.
Regards

pier4r
Posts: 4
Joined: Sat Oct 08, 2011 3:32 pm

Re: init script

Post by pier4r »

Sorry for the gravedigging, but the search route me here.

I have the exact problem but i didn't find a solution.

For example i try to run (only run) a simple script:

Code: Select all

#!/bin/sh /etc/rc.common
echo culo
the result is

Code: Select all

root@741nd:/etc/init.d# chmod 755 scriptName
root@741nd:/etc/init.d# ./scriptName
'bin/sh: can't open '/etc/rc.common
(same, obviously, for the longer script that i would like to put as startup script)

Can anyone help me?

info: gargoyle 1.4.0 r27980 from here http://wiki.openwrt.org/toh/tp-link/tl-wr741nd

pier4r
Posts: 4
Joined: Sat Oct 08, 2011 3:32 pm

Re: init script

Post by pier4r »

fun fact, if i use a direct call to busybox it works (at least the run part)

Code: Select all

root@741nd:/etc/init.d# ls -l z_prova*
-rwxr-xr-x    1 root     root           37 Oct  8 21:30 z_prova_02.txt



root@741nd:/etc/init.d# /bin/ash z_prova_02.txt
culo
root@741nd:/etc/init.d# /bin/sh z_prova_02.txt
culo
but with the standard method...

Code: Select all

root@741nd:/etc/init.d# ./z_prova_02.txt
'bin/sh: can't open '/etc/rc.common
Weird.

pier4r
Posts: 4
Joined: Sat Oct 08, 2011 3:32 pm

Re: init script

Post by pier4r »

OMFG i have wasted an entire afternoon.

SOLUTION: use line endings encode linefeed (unix) and not windows one.

Post Reply