mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-18 21:28:02 +00:00
procd: optimize /sbin/reload_config
* define variables, checksum tool may change * change into /etc/config directory to avoid basenaming * use mktemp to create tempory directory and verify * use "exe|while" over "for subshell" to avoid basenaming * favored "awk" over "grep+cut" * cleaned up ubus call * remove tempdir Signed-off-by: John Kirk <johnskirk@proton.me>
This commit is contained in:
parent
af611bce44
commit
8ad41e3522
@ -1,15 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
rm -rf /var/run/config.check
|
EXE=/usr/bin/md5sum
|
||||||
mkdir -p /var/run/config.check
|
FILE=/var/run/config.md5
|
||||||
for config in /etc/config/*; do
|
|
||||||
file=${config##*/}
|
cd /etc/config && DIR=$(mktemp -d) && [ -d "$DIR" ] || return 1
|
||||||
uci show "${file##*/}" > /var/run/config.check/$file
|
for conf in *; do
|
||||||
|
uci show "$conf" > "$DIR/$conf"
|
||||||
done
|
done
|
||||||
MD5FILE=/var/run/config.md5
|
cd "$DIR"
|
||||||
[ -f $MD5FILE ] && {
|
[ -f $FILE ] && {
|
||||||
for c in $(md5sum -c $MD5FILE 2>/dev/null| grep FAILED | cut -d: -f1); do
|
$EXE -c $FILE | awk -F: '/FAILED$/{print $1}' | while read conf; do
|
||||||
ubus call service event "{ \"type\": \"config.change\", \"data\": { \"package\": \"$(basename $c)\" }}"
|
ubus call service event \
|
||||||
|
"{'type':'config.change','data':{'package':'$conf'}}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
md5sum /var/run/config.check/* > $MD5FILE
|
$EXE * > $FILE
|
||||||
rm -rf /var/run/config.check
|
cd "$OLDPWD"
|
||||||
|
rm -rf "$DIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user