Commit 6d4631ff authored by Alessandro Rubini's avatar Alessandro Rubini

build: apply some dot-config choices at run-time, not build-time

We are aiming at a system where build-time configuration is irrelevant,
as every configuration happens at run-time, based on dot-config.
This is the first step.

Please note that this breaks the web interface, because it edits
wr_date.conf. A later commit will fix the web interface.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 06f78be9
......@@ -47,18 +47,6 @@ rm -rf $TMPFS/dev
(cd $TMPFS && tar xzf $DEVTAR)
(cd $TMPFS && ln -fs sbin/init .)
if [ ! -z "$CONFIG_NTP_SERVER" ]; then
echo "ntpserver $CONFIG_NTP_SERVER" > $TMPFS/wr/etc/wr_date.conf
fi
if [ ! -z "$CONFIG_DNS_SERVER" ]; then
rm -f $TMPFS/etc/resolv.conf
echo "nameserver $CONFIG_DNS_SERVER" > $TMPFS/etc/resolv.conf
if [ ! -z "$CONFIG_DNS_DOMAIN" ]; then
echo "domain $CONFIG_DNS_DOMAIN" >> $TMPFS/etc/resolv.conf
fi
fi
if [ "$CONFIG_REMOTE_SYSLOG_UDP" = "y" ]; then
sed -i 's/@@remote-host/@remote-host/' $TMPFS/etc/rsyslog.conf
fi
......
#!/bin/sh
# This script applies the dot-config. It is a boot script, but actual
# functionality is moved to a separate binary, so the web interface
# could edit dot-config and run /wr/bin/apply_dot-config like we do here,
# without the need to rember wheter this is S20 or S10 during boot.
. /wr/bin/apply_dot-config
\ No newline at end of file
#!/bin/sh
# This script applies the current dot-config to make
# the choices users wanted. You can change the dot-config on flash,
# and call this script to apply changes (please note that some changes
# require restarting running processes). The script is called at
# every boot by /etc/init.d/S20dot-config
# We create a temporary file in /tmp, to avoid wearing flash if not
# needed. Then we replace the real file if different.
T=$(mktemp /tmp/config-XXXXXX)
copy_conf() {
# busybox cmp exits 1 or 2 according to GNU man page
for dest in $*; do
cmp -s $T $1 || cp $T $1
done
}
# Check and complain, but we need to edit some files even if unconfigured.
if [ -f /wr/etc/dot-config ]; then
. /wr/etc/dot-config
configured=true
else
echo "No /wr/etc/dot-config to use" >& 2
configured=false
fi
##### Actual configuration actions start here.
# A non-existent wr_date.conf means no NTP. So "rm" if unconfigured
if [ ! -z "$CONFIG_NTP_SERVER" ]; then
echo "ntpserver $CONFIG_NTP_SERVER" > $T
copy_conf /wr/etc/wr_date.conf
else
rm -f /wr/etc/wr_date.conf
fi
# /etc/resolv.conf can be empty, so start empty
> $T
if [ ! -z "$CONFIG_DNS_SERVER" ]; then
echo "nameserver $CONFIG_DNS_SERVER" >> $T
if [ ! -z "$CONFIG_DNS_DOMAIN" ]; then
echo "domain $CONFIG_DNS_DOMAIN" >> $T
fi
fi
copy_conf /etc/resolv.conf /usr/etc/resolv.conf
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment