1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to make /etc/l7-extra folder permanent

Discussion in 'Tomato Firmware' started by Mark Barabus, Feb 26, 2018.

  1. Mark Barabus

    Mark Barabus Serious Server Member

    I've added some custom l7 filters for windows update and youtube but the /etc/l7-extra/ folder vanishes after a reboot meaning they are not getting initiated at boot and i'm having to create the folder manaully.

    How can i make /etc/l7-extra/ folder stick so its not removed after a reboot?

  2. koitsu

    koitsu Network Guru Member

    Yes, on a router reboot, /etc and all of its contents come from ROM. TomatoUSB recreates some of the files from NVRAM variables on boot. TomatoUSB is not a Linux distro with a hard disk. Routers/embedded devices are quite different in this regard. Thus, manual recreation of /etc/l7-extra is required.

    There may be an automated way to do this, but you need to disclose "how" you're putting files into /etc/l7-extra on the router, and where those source files come from (on the Internet?). You're probably going to need a USB stick (assuming your router has a USB port), but I can't say that for sure without getting answers to the previous questions.
  3. Mark Barabus

    Mark Barabus Serious Server Member

    Thanks i'm using the init script feature to populate the directory at boot.

    echo "windowsupdate" > /etc/l7-extra/windowsupdate.pat
    echo "(Microsoft-Delivery-Optimization/|.mp.microsoft.com)" >> /etc/l7-extra/windowsupdate.pat
    echo "youtube-2015" > /etc/l7-extra/youtube-2015.pat
    echo "(stream.com|video.com)" >> /etc/l7-extra/youtube-2015.pat
    I supposed i could set up a USB stick for this purpose i was just hoping i could utilise the onboard flash seeing as the files are only a few bytes and its a one-time write. Not to mention i have plenty of flash space, i'm using an Asus N66U which i believe has 256MB.
  4. koitsu

    koitsu Network Guru Member

    If you're using Scripts -> Init already for this (this is the proper place!), then are you saying mkdir -p /etc/l7-extra as the first line of your script doesn't work? I'm confused by this report. Help clue me in!

    P.S. -- You can "clean up" that script in such a way that this should make it easier to add entries if/when you see fit (i.e. it removes the echo statements):

    mkdir -p /etc/l7-extra
    cat > /etc/l7-extra/windowsupdate.pat << 'EOF'
    cat > /etc/l7-extra/youtube-2015.pat << 'EOF'
    This uses what is called a heredoc to make things a little more manageable. The apostrophes around the EOF in the heredoc use (but not at the end!) ensures that special symbols (especially $, which is commonly used in regular expressions) don't get interpreted by the shell when using a heredoc.
  5. Mark Barabus

    Mark Barabus Serious Server Member

    Thanks for the informative reply koitsu.

    After reviewing this it turns out i was missing the mkdir command. I guess i was just under the impression once i created the directory manually it would stay. Now i understand that this is only stored in the NVRAM and its wiped at boot so the mkdir command is necessary. So its all working great and as it should be now i've included the mkdir command.

    I'll need to review the "clean" code so i can understand it fully. It just looks more complicated to me but i'm sure once i learn UNIX better this will come in handy - thanks.

Share This Page