Commit faacd927 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/rootfs_override: store information about dotconfig source

Store information about protocol, server IP and filename of retrived dotconfig.
Information is stored in:
-- /tmp/dot-config_proto
-- /tmp/dot-config_host
-- /tmp/dot-config_filename

When dotconfig is local don't store source information.
When web-interface changes dot-config, remove source information because after
changes configuration is stored locally.
This is going to be used by SNMP
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 76c41662
......@@ -8,9 +8,13 @@
# First, read dot-config to get the new location, if any.
dotconfig=/wr/etc/dot-config
tmpconfig=/tmp/dot-config
tmpdir=/tmp
if [ -f $dotconfig ]; then
. $dotconfig
echo "local" > "$tmpdir"/dot-config_proto
else
echo "no_config" > "$tmpdir"/dot-config_proto
fi
# Create /etc/resolv.conf, so we can use it. /etc is ramdisk anyways
......@@ -33,6 +37,11 @@ if [ -n "$CONFIG_DOTCONF_URL" ]; then
host=$(echo $URL | cut -d/ -f 3)
filename=$(echo $URL | cut -d/ -f 4-)
# save proto, host and filename of dot-config, to be used by SNMPd
echo "$proto" > "$tmpdir"/dot-config_proto
echo "$host" > "$tmpdir"/dot-config_host
echo "$filename" > "$tmpdir"/dot-config_filename
rm -f $tmpconfig
case $proto in
http|ftp)
......
......@@ -1282,7 +1282,8 @@ function safefilerewrite($dotconfig, $tmpdotconfig){
function apply_kconfig(){
$dotconfigapp = "/usr/wr/bin/apply_dot-config";
shell_exec($dotconfigapp. " > /dev/null 2>&1 &");
/* So far all changes via web-interface are on local file. Notify apply_dot-config that changes are on local file */
shell_exec($dotconfigapp. " local_config > /dev/null 2>&1 &");
}
......
......@@ -6,6 +6,9 @@
# require restarting running processes). The script is called at
# every boot by /etc/init.d/S20dot-config
# When called with "local_config" parameter, files with information about
# dotconfig source are removed (used by SNMP)
# We create a temporary file in /tmp, to avoid wearing flash if not
# needed. Then we replace the real file if different.
......@@ -18,6 +21,14 @@ copy_conf() {
done
}
#check if config is local
if [ "$1" == "local_config" ]; then
# remove source information in case previous config was received from
# network
rm /tmp/dot-config_*
echo "local" > /tmp/dot-config_proto
fi
# Check and complain, but we need to edit some files even if unconfigured.
if [ -f /wr/etc/dot-config ]; then
. /wr/etc/dot-config
......
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