What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Running user scripts

tonysamson

Regular Contributor
Hi,

This may be a dumb question but I really could not make a User Script work. I did the following:

Code:
 admin@TheVault:/jffs/scripts# nano init-start

then I typed the following:

Code:
#!/bin/sh
swapon UUID=8979265a-d332-428b-984b-807a7b2704c9

then I

Code:
chmod a+rx /jffs/scripts/init-start

When I'd enter

Code:
/jffs/scripts/init-start

in the terminal. The script will run. But, if I'd restart the router, I think the script doesn't run because the swap isn't mounted when I enter:

Code:
free

the swap becomes 0 (zero) again. I also noticed that when I run

Code:
/jffs/scripts/init-start

the script will run but when I run

Code:
admin@TheVault:/jffs/scripts# init-start
-sh: init-start: not found

without the file path, I get the above return. Please help.. I really need the swap for my Rsync script.
 
Hi,

This may be a dumb question but I really could not make a User Script work. I did the following:

Code:
 admin@TheVault:/jffs/scripts# nano init-start

then I typed the following:

Code:
#!/bin/sh
swapon UUID=8979265a-d332-428b-984b-807a7b2704c9

Hi,

I have had the same problem
Put your code into the pre-mount script.
Create one or simply rename your init-script to pre-mount.(if you don't need it for something else)
That will also do the job.:)

Code:
/jffs/scripts/init-start

in the terminal. The script will run. But, if I'd restart the router, I think the script doesn't run because the swap isn't mounted when I enter:

Code:
admin@TheVault:/jffs/scripts# init-start
-sh: init-start: not found

Same results
It has nothing to do with swap that isn't mounted.
you must specify full path like "/jffs/scripts/init-start"
 
Last edited by a moderator:
Code:
 admin@TheVault:/jffs/scripts# nano init-start
Hi,

The init-start script is "too early" in the boot process. The disk is not yet recognized by the system! :eek:

Place it into the pre-mount script and you will see that it works. :rolleyes:
The sequence of the scripts executed is shown in my posting here.

With kind regards
Joe :cool:
 
I'll try your advice when I get home. I merely followed this instructions:

Find the UUID of that swap partition with blkid and test it:
Code:

Code:
swapon UUID="swap_partition_UUID"

Verify it with free command.

If is working add the command swapon to init-start.

I think I'll just try to put the the Swap command in the post-mount right?
 
For debugging, I add the following to my script files:

touch /tmp/<script-name>.ran

For example:

touch /tmp/init-start.ran

Then I can look in /tmp and see if the script in question actually was run since I last booted (/tmp is in RAM, so its previous contents go away at each boot). If the flag file is there in /tmp and it still didn't work, then I know that it isn't because the script didn't run, it's because it doesn't work *smile*.
 
Last edited:
I too am not sure init-start is being run, perhaps /jffs isn't mounted yet? I just noticed today when I was checking my gc_thresh values and they were still default, in spite of being set in init-start.

For debugging, I add the following to my script files:

touch /tmp/<script-name>.ran

For example:

touch /tmp/init-start.ran

Then I can look in /tmp and see if the script in question actually was run since I last booted (/tmp is in RAM, so its previous contents go away at each boot). If the flag file is there in /tmp and it still didn't work, then I know that it isn't because the script didn't run, it's because it doesn't work *smile*.

An alternative would be to use the logger utility. It prints a message to your system log (and optionally stderr).

Code:
logger -t init-start Init start script finished
Will output the following in your syslog
Code:
Jul 23 18:51:26 init-start: Init start script finished

This way you can also use the web console to see if your script ran, or a simple grep of the syslog.
 
For debugging, I add the following to my script files:

RogerSC, thanks for your input. :)

If I'd run my script manually, the swap would mount. And I can verify it when I run the "free" command. But when I reboot the router and thereafter run the "free" command, the swap is still 0. Meaning the swap failed to mount after boot.
 
I pasted the:

Code:
swapon UUID=8979265a-d332-428b-984b-807a7b2704c9

in the post-mount script. Restarted my router. Run "free" command, and now my Swap has some figures in it. Now its mounted. Thank you.
 
but when I run

Code:
admin@TheVault:/jffs/scripts# init-start
-sh: init-start: not found

without the file path, I get the above return.
I know it's not the main topic of the post, but the reason for this is because the current directory (.) is not in your path. You can run it by typing ./init-start if you're in the same directory as the script. You could add "." to your path, but I don't recommend it.
 
I know it's not the main topic of the post, but the reason for this is because the current directory (.) is not in your path. You can run it by typing ./init-start if you're in the same directory as the script. You could add "." to your path, but I don't recommend it.

Yes, it is not recommended to have "." in your path if you're running as admin or root.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top