• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

SOLVED: Injecting config file in embedded *.img

Scheduled Pinned Locked Moved Problems Installing or Upgrading pfSense Software
5 Posts 2 Posters 2.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N
    netphreak
    last edited by Jun 3, 2009, 9:22 PM Jun 3, 2009, 7:41 AM

    I'm referring to the 3 years old sticky in this forum…

    Is this still the most relevant way to inject a config file into an *.img file?

    1 Reply Last reply Reply Quote 0
    • D
      dotdash
      last edited by Jun 3, 2009, 2:33 PM

      Yeah, AFAIK, the easiest way to do this is to have a FreeBSD box to work on the image. The script just mounts the image and replaces the config. If you want to do this manually, just use the commands in the script as a starting point.

      1 Reply Last reply Reply Quote 0
      • N
        netphreak
        last edited by Jun 3, 2009, 9:12 PM

        Thank you for replying.

        I do want to make this work, as I can't have my firewall down for a long time… So I installed freebsd 7.2 as guest OS on my esxi server. Working well, but I run into problems - here's what the script outputs:

        # ./pfscript.sh config.xml pfscript.sh
        Working Directory: /usr/home/testuser/pf
        Image File: pfscript.sh
        Image File Device: md0
        mount: /dev/md0d : No such file or directory
        mv: rename /usr/home/testuser/pf/config.xml to /usr/home/testuser/pf/d/conf/config.xml: No such file or directory
        chmod: /usr/home/testuser/pf/d/conf/config.xml: No such file or directory
        Repalced Config With config.xml
        umount: /usr/home/testuser/pf/d: not a file system root directory
        #
        

        The script is cut from the sticky:

        #!/bin/sh
        # The script replaces the default config file in the
        # image with your specified config file.
        # Usage {configfile} {imagefile}
        # Example ./replace_conf.sh myconfig.xml pfSense.img
        
        NEWCONFIG="$1"
        IMGFILE="$2"
        WORKDIR=`pwd`
        echo "Working Directory: $WORKDIR"
        echo "Image File: $IMGFILE"
        MD=`mdconfig -a -t vnode -f $WORKDIR/$IMGFILE`
        echo "Image File Device: $MD"
        mkdir $WORKDIR/d
        mount /dev/${MD}d $WORKDIR/d
        mv $WORKDIR/$NEWCONFIG $WORKDIR/d/conf/config.xml
        chmod 640 $WORKDIR/d/conf/config.xml
        echo "Repalced Config With $NEWCONFIG"
        umount $WORKDIR/d
        rm -rf $WORKDIR/d
        mdconfig -d -u ${MD}
        

        So - does this mean I'll need a cf adapter connected? Or am I missing something?

        Thanks!

        1 Reply Last reply Reply Quote 0
        • D
          dotdash
          last edited by Jun 3, 2009, 9:16 PM

          You're missing the last argument on the script, the pfsense.img file.
          Try something like:

          ./pfscript.sh config.xml pfscript.sh pfSense-1.2.2-Embedded.img.gz

          If you still have problems, try running the commands in the script manually, replacing the variables appropriately.

          1 Reply Last reply Reply Quote 0
          • N
            netphreak
            last edited by Jun 3, 2009, 9:21 PM

            OMG! I am sorry (and very tired) - I retyped the name of the script instead of the image file  :-[ - now everything runs well.

            Thank you for pointing this out so quick!  :)

            1 Reply Last reply Reply Quote 0
            5 out of 5
            • First post
              5/5
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
              This community forum collects and processes your personal information.
              consent.not_received