From: <abe...@us...> - 2017-05-11 21:24:37
|
Revision: 8298 http://sourceforge.net/p/astlinux/code/8298 Author: abelbeck Date: 2017-05-11 21:24:35 +0000 (Thu, 11 May 2017) Log Message: ----------- wide-dhcpv6, dhcp6c.script, add 'dhcp6c_cache' file and 'dhcp6c_changed' exported env variable Modified Paths: -------------- branches/1.0/package/wide-dhcpv6/dhcp6c.script Modified: branches/1.0/package/wide-dhcpv6/dhcp6c.script =================================================================== --- branches/1.0/package/wide-dhcpv6/dhcp6c.script 2017-05-11 15:24:04 UTC (rev 8297) +++ branches/1.0/package/wide-dhcpv6/dhcp6c.script 2017-05-11 21:24:35 UTC (rev 8298) @@ -6,6 +6,8 @@ SCRIPTFILE="/mnt/kd/dhcp6c.script" +CACHEFILE="/var/db/dhcp6c_cache" + get_ipv6_global_addr() { local interface="$1" @@ -41,6 +43,32 @@ esac } +update_cache() +{ + local changed + + echo "## dhcp6c cache +dhcp6c_interface=$dhcp6c_interface +dhcp6c_address=$dhcp6c_address +dhcp6c_prefix_interfaces=$dhcp6c_prefix_interfaces +dhcp6c_prefix_addresses=$dhcp6c_prefix_addresses" > "$CACHEFILE.new" + chmod 600 "$CACHEFILE.new" + + if [ -f "$CACHEFILE" ] && cmp -s "$CACHEFILE" "$CACHEFILE.new"; then + changed="no" + rm -f "$CACHEFILE.new" + else + if [ -f "$CACHEFILE" ]; then + changed="yes" + else + changed="" + fi + mv "$CACHEFILE.new" "$CACHEFILE" + fi + + echo "$changed" +} + setup_env() { local conffile pd_1 prefix_len prefix_if interface ipv6 ipv6_ex cut_chars prefix_label IFS @@ -48,6 +76,7 @@ ## Globals to export dhcp6c_interface="" dhcp6c_address="" + dhcp6c_changed="" dhcp6c_prefix_interfaces="" dhcp6c_prefix_addresses="" dhcp6c_prefix="" @@ -77,6 +106,8 @@ dhcp6c_prefix_interfaces="${dhcp6c_prefix_interfaces#,}" dhcp6c_prefix_addresses="${dhcp6c_prefix_addresses#,}" + dhcp6c_changed="$(update_cache)" + if [ -z "$dhcp6c_prefix_addresses" ]; then return fi @@ -99,7 +130,7 @@ if [ -x $SCRIPTFILE ]; then setup_env - export dhcp6c_interface dhcp6c_address + export dhcp6c_interface dhcp6c_address dhcp6c_changed export dhcp6c_prefix_interfaces dhcp6c_prefix_addresses export dhcp6c_prefix dhcp6c_prefix_base dhcp6c_prefix_len This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |