forked from samba-team/samba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request samba-team#6 from dl566/fix-issue2-configuration-sync
samba-issue5-v1: add feature of configuration files sync based on ctdb fix issue samba-team#5
- Loading branch information
Showing
16 changed files
with
593 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ config.status | |
configure | ||
ctdb.pc | ||
publish*.sh | ||
push*.sh | ||
web/packages | ||
TAGS | ||
tags | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
. /etc/ctdb/pull_config.sh | ||
|
||
update_config() | ||
{ | ||
if [ "x$1" == "xall" ] ; then | ||
pull_smb | ||
pull_dns | ||
pull_nfs | ||
fi | ||
|
||
if [ "x$1" == "xsmb" ] ; then | ||
pull_smb | ||
fi | ||
|
||
if [ "x$1" == "xdns" ] ; then | ||
pull_dns | ||
fi | ||
|
||
if [ "x$1" == "xnfs" ] ; then | ||
pull_nfs | ||
fi | ||
} | ||
|
||
case "$1" in | ||
sync) | ||
update_config $2 | ||
;; | ||
healthy) | ||
update_config $2 | ||
;; | ||
esac |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
#!/bin/sh | ||
tmp_dir="/var/run/ctdb" | ||
cache_file="$tmp_dir/netcache.$$" | ||
|
||
reload_smb() | ||
{ | ||
service smb status >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
return 0 | ||
fi | ||
smbcontrol smbd reload-config >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to reload smb service." | ||
return 1 | ||
fi | ||
|
||
return 0 | ||
} | ||
|
||
reload_nfs() | ||
{ | ||
service nfs-ganesha status >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
return 0 | ||
fi | ||
|
||
service nfs-ganesha reload >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to reload nfs service." | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
reload_dns() | ||
{ | ||
service dnsmasq status >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
return 0 | ||
fi | ||
service dnsmasq restart >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to reload dnsmasq service." | ||
return 1 | ||
fi | ||
|
||
return 0 | ||
} | ||
pull_smb() | ||
{ | ||
tmp_smb_file="$tmp_dir/smb.conf.$$" | ||
touch $tmp_smb_file >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to create temp file for pull smb config." | ||
return 1 | ||
fi | ||
|
||
echo "begin to....." | ||
rm -f $cache_file >/dev/null 2>&1 | ||
content=$(net registry enumerate "HKLM\Software\Samba\smbconf") | ||
if [ $? -ne 0 ] ||[ x"$content" == x ] ; then | ||
echo "Failed to read smb configuration from registry.tdb." | ||
return 1 | ||
fi | ||
for service in ` net registry enumerate 'HKLM\Software\Samba\smbconf' |grep "Keyname"|awk -F= '{print $2}' |sed 's/^[ ]*//g'` | ||
do | ||
echo "service is $service" | ||
echo "[$service]" >> $tmp_smb_file | ||
|
||
net registry enumerate "HKLM\Software\Samba\smbconf\\$service" |grep "Valuename" |awk -F= '{print $2}'|sed 's/^[ ]*//g' > $cache_file 2>/dev/null | ||
|
||
while read valuename | ||
do | ||
echo "valuename is $valuename" | ||
value=$(net registry getvalueraw "HKLM\Software\Samba\smbconf\\$service" "$valuename") | ||
if [ $? -eq 0 ] ; then | ||
echo "$valuename = $value" >> $tmp_smb_file | ||
fi | ||
done < $cache_file | ||
|
||
done | ||
|
||
mv $tmp_smb_file /etc/samba/smb.conf | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to override smb.conf." | ||
rm -rf $tmp_smb_file >/dev/null 2>&1 | ||
rm -rf $cache_file >/dev/null 2>&1 | ||
return 1 | ||
fi | ||
rm -rf $tmp_smb_file >/dev/null 2>&1 | ||
rm -rf $cache_file >/dev/null 2>&1 | ||
reload_smb | ||
if [ $? -ne 0 ] ; then | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
pull_nfs() | ||
{ | ||
tmp_nfs_file="$tmp_dir/gluster.ganesha.conf.$$" | ||
touch $tmp_nfs_file >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to create temp for pull nfs config." | ||
return 1 | ||
fi | ||
|
||
rm -rf $cache_file >/dev/null 2>&1 | ||
content=$(net registry enumerate "HKLM\Software\nfs") | ||
if [ $? -ne 0 ] ; then | ||
echo "Failed to read nfs configuration from registry.tdb." | ||
return 1 | ||
fi | ||
|
||
for export_id in `net registry enumerate 'HKLM\Software\nfs' |grep "Keyname"|awk -F= '{print $2}' |sed 's/^[ ]*//g'` | ||
do | ||
echo "EXPORT" >> $tmp_nfs_file | ||
echo "{" >> $tmp_nfs_file | ||
net registry enumerate "HKLM\Software\nfs\\$export_id" |grep "Valuename" |awk -F= '{print $2}'|sed 's/^[ ]*//g' > $cache_file 2>/dev/null | ||
while read valuename | ||
do | ||
if [ x"$valuename" == x"Name" -o x"$valuename" == x"Hostname" -o x"$valuename" == x"Volume" ] ; then | ||
continue | ||
fi | ||
value=$(net registry getvalueraw "HKLM\Software\nfs\\$export_id" "$valuename") | ||
if [ $? -eq 0 ] ; then | ||
echo " $valuename = $value" >> $tmp_nfs_file | ||
fi | ||
done < $cache_file | ||
|
||
echo "FSAL {" >> $tmp_nfs_file | ||
|
||
value=$(net registry getvalueraw "HKLM\Software\nfs\\$export_id" Name) | ||
if [ $? -eq 0 ] ; then | ||
echo " Name = $value" >> $tmp_nfs_file | ||
fi | ||
|
||
value=$(net registry getvalueraw "HKLM\Software\nfs\\$export_id" Hostname) | ||
if [ $? -eq 0 ] ; then | ||
echo " Hostname = $value" >> $tmp_nfs_file | ||
fi | ||
|
||
value=$(net registry getvalueraw "HKLM\Software\nfs\\$export_id" Volume) | ||
if [ $? -eq 0 ] ; then | ||
echo " Volume = $value" >> $tmp_nfs_file | ||
fi | ||
echo " }" >> $tmp_nfs_file | ||
echo "}" >> $tmp_nfs_file | ||
done | ||
|
||
mv $tmp_nfs_file /etc/ganesha/gluster.ganesha.conf | ||
if [ $? -ne 0 ] ; then | ||
echo "Failed to override nfs configuration." | ||
rm -rf $tmp_nfs_file >/dev/null 2>&1 | ||
rm -rf $cache_file >/dev/null 2>&1 | ||
return 1 | ||
fi | ||
|
||
rm -rf $tmp_nfs_file >/dev/null 2>&1 | ||
rm -rf $cache_file >/dev/null 2>&1 | ||
reload_nfs | ||
if [ $? -ne 0 ] ; then | ||
return 1 | ||
fi | ||
|
||
return 0 | ||
|
||
} | ||
|
||
|
||
pull_dns() | ||
{ | ||
tmp_dns_file="$tmp_dir/zone.conf.$$" | ||
touch $tmp_dns_file >/dev/null 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to create file $tmp_dns_file." | ||
return 1 | ||
fi | ||
|
||
rm -f $cache_file >/dev/null 2>&1 | ||
content=$(net registry enumerate "HKLM\Software\dns") | ||
if [ $? -ne 0 ] ; then | ||
echo "Failed to read dns configuration from registry.tdb." | ||
return 1; | ||
|
||
fi | ||
|
||
for zone in ` net registry enumerate 'HKLM\Software\dns' |grep "Keyname"|awk -F= '{print $2}' |sed 's/^[ ]*//g'` | ||
do | ||
echo "zone is $zone" | ||
echo "zone $zone" >> $tmp_dns_file | ||
net registry enumerate "HKLM\Software\dns\\$zone" |grep "Valuename" |awk -F= '{print $2}'|sed 's/^[ ]*//g' > $cache_file 2>/dev/null | ||
|
||
while read valuename | ||
do | ||
echo "valuename is $valuename" | ||
value=$(net registry getvalueraw "HKLM\Software\dns\\$zone" "$valuename") | ||
if [ $? -eq 0 ] ; then | ||
echo " $valuename $value" >> $tmp_dns_file | ||
fi | ||
done < $cache_file | ||
|
||
|
||
echo "end zone" >> $tmp_dns_file | ||
done | ||
|
||
mv $tmp_dns_file /etc/zone.conf | ||
if [ $? -ne 0 ] ; then | ||
echo "failed to override zone.conf." | ||
rm -rf $tmp_dns_file >/dev/null 2>&1 | ||
rm -rf $cache_file >/dev/null 2>&1 | ||
return 1 | ||
fi | ||
rm -rf $tmp_dns_file >/dev/null 2>&1 | ||
rm -rf $cache_file >/dev/null 2>&1 | ||
reload_dns | ||
if [ $? -ne 0 ] ; then | ||
return 1 | ||
fi | ||
|
||
return 0 | ||
} | ||
|
Oops, something went wrong.