Imagebuilder - help with adding config files

I’ve been studying the imagebuilder README and am still a bit confused on where to add/modify files for custom config files. I understand the custom ipk package instructions, but this is not what I’d like to accomplish.

What I’m trying to do is create custom default configurations for an otherwise stock image. For example, I’d like to include my own /etc/passed, /etc/shadow and various /etc/config/* files so that when I load a firmware, the router is already fully configured to our needs. Where in the imagebuilder/ sub-directory structure is the right place to be focusing on?

Thank you.

You’d probably have better luck consulting the OpenWrt Wiki or posing the question in the Forums… though I suspect @solidus1983 has some insights on this base on his builds for the Flint v1 & Slate AX.

1 Like

@bring.fringe18 Thank you. I’ll check out the wiki.

@solidus1983 any pointers would be appreciated.

i normally place mine in the packages/base-files/files folder using the folder format like below (this is my custom files folder that i use a script to cp into 'packages/base-files/files`

|-- etc
|   |-- init.d
|   |   `-- fan_control
|   `-- ssl
|       `-- openssl.cnf
`-- usr
    `-- sbin
        `-- fan_monitor

So in your case it will just be the /etc/config or /etc/ folders just make sure if you include any executable make sure you chmod +x before hand.

It should be the same for the infrabuilder just that you would place it into the openwrt folder in the same location.

Thank you @solidus1983. I will look into that further. I did figure out how to do it by adding files in /gl_imagebuilder/imagebuilder/3.8/openwrt-imagebuilder-ramips-mt76x8_3.8/files/*. The one part I cannot figure out is how to set a new default root password using custom firmware. I’ve been trying various scripts for this using uci-defaults with no luck.

Setting a hash in using “uci set glconfig.general.password=” doesn’t seem to do the trick. Is there anyway to set root using a first-boot firmware script that will do away with the default “welcome” screen after first boot?

Default root password is set else where and not directly in firmware.
However you can get making sure the shadow and passed file is in etc during compile that should work.

Nice. Thank you. I’ll give this a shot now. Will the hash value also need set using in glconfig.general.password for GL UI to know it’s been set?

If you try to customize the configuration, you can read this Chinese forum post, maybe it will help you.

1 Like

@shi05275 - thank you… the root passwd portion looks just like what I needed.

1 Like

@shi05275 - just tested as the code from that script works. Thank you!

EDIT: see comment below before using.

For future reference to others. This is the script I’ve used to set a new default root password via a custom image script and avoid the “welcome” screen at first boot. (on a mango)

Placed in:
~/gl_imagebuilder/imagebuilder/3.8/openwrt-imagebuilder-ramips-mt76x8_3.8/files/etc/uci-defaults/99-defaultconfig.sh

#!/bin/sh

# You can also modify the configuration by directly modifying the configuration file
# E.g. modify the root default password and set the public key to log in
# get the password hashes from /etc/shadow and "uci show" from the backup config of a router already configured with the correct password.

sed -i'/root/d' /etc/shadow
sed -i '1i\root:$1$G.elgsxV$IBS8iGDyioldPta4rAH0h0:19065:0:9999:7::'/etc/shadow
echo'ssh-rsa Your Pub Key' > /etc/dropbear/authorized_keys

uci set glconfig.general.password='l9082lj2o882ceb885a7590c238bfc283c49902d5a8e2822d474af8b851a205c822'
uci set glconfig.general.language='EN'
uci commit

exit 0

This is originally based on the link @solidus1983 provided above.

1 Like

UPDATE - turns out I was wrong. The above code did set the admin panel password, but was not actually setting the root password or authorized keys.

I am able to accomplish the same thing by adding replacement /shadow and /passwd files in the image and only using the uci portions in the script above.

1 Like