What's new

Looking for compiling help - jffs

  • 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!

mrdude

Regular Contributor
Hi guys, I have compiled the latest firmware and added some libraries to the firmware to make oscam work. I run oscam from jffs (and some scripts) and would like to compile a firmware with these binaries built into the firmware by default so when I enable jffs - these files are present.

Where in the makefile would I find the part to include files in jffs - I have been looking for a couple of days but with no luck. I know how to add libraries no problem, the only issue I have is with this.

I should also say in using a RT-AC87U.

Thanks.
 
JFFS is a separate partition that's part of the unused flash, it's not a portion of the firmware itself.
 
@RMerlin, thanks for the fast reply. I never knew that so thanks. Ok what about if I compressed the files I want to add into a file that's stored in the firmware and add a button/checkbox to run a script to decompress those files. How would I go about putting that on the web interface in the admin/system page.

I don't need help to make the script, or how to put the compressed files in the firmware - just need to know where the web page is in the source code and how to make it run the script.

Thanks, and sorry if this question is a pain to answer.
 
@RMerlin, thanks for the fast reply. I never knew that so thanks. Ok what about if I compressed the files I want to add into a file that's stored in the firmware and add a button/checkbox to run a script to decompress those files. How would I go about putting that on the web interface in the admin/system page.

I don't need help to make the script, or how to put the compressed files in the firmware - just need to know where the web page is in the source code and how to make it run the script.

Thanks, and sorry if this question is a pain to answer.

The firmware already compresses its content with lzma, so there's nothing to be gained by compressing it.

The RT-AC87U has up to 64 MB of space on rootfs, so I don't know what you want to add that would be so large as it would no longer fit. Sounds like something that should rather be put on a USB disk if it's that large.
 
Thanks for the fast reply, maybe I should have made myself clearer.

OK this is what I have, I have built the firmware for personal use, I have also added some extra libraries so that I can run a program called oscam.

Currently If I have a new router with nvram erased (blank jffs) I need to use winscp to manually put the oscam files on on the jffs partition/folder - then I need to chmod all the files I added to the correct properties.

Now say I didn't want to do that with winscp - I want to run a script to automatically untar a file (that is stored in the firmware) that has all those oscam files set with the correct properties from the web interface. I know how to do this already. I can do this from telnet already. (don't worry about compression - i'm not bothered about that, my files are less than 1mb).

What I want to do is modify the web interface so I can run a script when jffs is enabled to untar the file with the oscam files in it - that way it puts all the files in jffs with the correct properties - and I don't need to use winscp or telnet to do it.

Does that make sense? I just need to know where the web interface files are in the source code - and then modify one to make it run a shell script from a button or check box.
 
Why not simply put the files in their correct final locations (modules in /lib/modules/, binaries in /usr/bin, etc...)? It will be far simpler to implement, look at how it's dome in the router/others and router/rom directories.

What you want to do would require you to also modify the httpd source code. A webpage is run client-side, not server-side, so it cannot do anything on its own.
 
@RMerlin,

Thanks, the reason I never done it like that is that some files need to be replaced sometimes (such as the binary) so they need to be in a writable part of the router - same with some of the configs that the binary uses.

I have figured out how to do it another way using a script when the router starts,

It checks if the files are present in the router on booting - if they are the script exits, if not it installs them then reboots the router so they become usable.

This is the script:

Code:
#!/bin/sh
#DESCRIPTION=This script checks if jffs/oscam directory exists - if not, it extracts oscam to jffs.
#Test script in usr/sbin/

cd /

Dir="/jffs/configs"

if [ -d $Dir ]

then
    echo "Directory $Dir exists, going to check if oscam directory is already present in jffs."
  
OscamDir="/jffs/oscam"

if [ -d $OscamDir ]
then
    echo "$OscamDir directory already existed - exiting script now."
    #Do nothing because oscam directory already exists.
else
    echo "$OscamDir directory didn't exist - extract files now!, then reboot router"
    #put extact command here..
    tar -xzvf /usr/bin/oscam.tar.gz
    #put sleep here..wait 5 seconds to make sure all files are extracted.
    sleep 5
fi   

else
    echo "$Dir does not exist."
    #Do nothing if /jffs/configs does not exist.
fi

Do I just put that script into: usr/sbin

So that it executes when the router boots up (and jffs is enabled), or do I need to put it somewhere else? Thanks.

Thanks for your advice though, I appreciate you taking the time to answer and for your advice, although thanks for making this firmware - it's really awesome. :)
 
Last edited:
@RMerlin,

Thanks, the reason I never done it like that is that some files need to be replaced sometimes (such as the binary) so they need to be in a writable part of the router - same with some of the configs that the binary uses.

I have figured out how to do it another way using a script when the router starts,

It checks if the files are present in the router on booting - if they are the script exits, if not it installs them then reboots the router so they become usable.

This is the script:

Code:
#!/bin/sh
#DESCRIPTION=This script checks if jffs/oscam directory exists - if not, it extracts oscam to jffs.
#Test script in usr/sbin/

cd /

Dir="/jffs/configs"

if [ -d $Dir ]

then
    echo "Directory $Dir exists, going to check if oscam directory is already present in jffs."
  
OscamDir="/jffs/oscam"

if [ -d $OscamDir ]
then
    echo "$OscamDir directory already existed - exiting script now."
    #Do nothing because oscam directory already exists.
else
    echo "$OscamDir directory didn't exist - extract files now!, then reboot router"
    #put extact command here..
    tar -xzvf /usr/bin/oscam.tar.gz
    #put reboot command here..wait 5 seconds before rebooting to make sure all files are extracted.
    sleep 5
    reboot
fi   

else
    echo "$Dir does not exist."
    #Do nothing if /jffs/configs does not exist.
fi

Do I just put that script into: usr/sbin

So that it executes when the router boots up (and jffs is enabled), or do I need to put it somewhere else? Thanks.

Thanks for your advice though, I appreciate you taking the time to answer and for your advice, although thanks for making this firmware - it's really awesome. :)

Just putting the script on the router won't make it execute automatically - you will also have to modify the code to make it run. Best location is probably right where I've put the init-start script, which is right after the JFFS partition gets mounted. Look in rc/init.c around line 5700, and add a system("/usr/sbin/yourscript") right before the line where I run the init-start script.
 
Thank you, I was looking for etc/init.d but couldn't find it. At least I know now how to run a script on starting.
I really appreciate that so thanks very much.
 
Would that code look like this then?

Code:
#if defined(RTCONFIG_PSISTLOG)
    { //set soft link for some app such as 3ginfo.sh
        char *syslog[]  = { "/tmp/syslog.log", "/tmp/syslog.log-1" };
        char *filename;
        int i;
        for(i = 0; i < 2; i++)
        {
            filename = get_syslog_fname(i);
            if(strcmp(filename, syslog[i]) != 0)
                eval("ln", "-s", filename, syslog[i]);
        }
    }
#endif

//Run oscam script here.
system("/usr/sbin/oscam.sh");

#ifdef RTN65U
        extern void asm1042_upgrade(int);
        asm1042_upgrade(1);    // check whether upgrade firmware of ASM1042
#endif

        run_custom_script("init-start", NULL);
        use_custom_config("fstab", "/etc/fstab");
        run_postconf("fstab", "/etc/fstab");
        state = SIGUSR2;    /* START */

Edit:

Thanks, I tested that and it works fine, thanks very much for your help RMerlin.
 
Last edited:

Latest threads

Sign Up For SNBForums Daily Digest

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