Created
March 29, 2020 13:07
-
-
Save alexalouit/51962ff1a2901520074223c771dab6e6 to your computer and use it in GitHub Desktop.
nfs export ip sync (use provider ptr)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/dir *(rw,no_root_squash,no_subtree_check) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ip=`dig +short nslookup.domain.tld @ns.provider.com` | |
if /bin/ping -qc 3 $ip > /dev/null 2>&1; then | |
if [ ! -f /tmp/.ip-sync ]; then | |
logger "ip-sync: create ip rule to $ip" | |
sed -e "s/\*/$ip/" /etc/exports.default > /etc/exports | |
echo $ip > /tmp/.ip-sync | |
/usr/sbin/exportfs -r | |
else | |
if [ `cat /tmp/.ip-sync` != $ip ]; then | |
logger "ip-sync: update ip rule to $ip" | |
sed -e "s/\*/$ip/" /etc/exports.default > /etc/exports | |
echo $ip > /tmp/.ip-sync | |
/usr/sbin/exportfs -r | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment