1 #!/bin/bash 2 kinds='rpms nmon' 3 stub="/etc/rsyncd.conf.stub" 4 nodes='/etc/rsyncd.nodes' 5 6 out='/etc/rsyncd.conf' 7 8 rm -f ${out}.tmp 9 cp ${stub} ${out}.tmp 10 11 for kind in ${kinds} 12 do 13 echo "############################################################" >> ${out}.tmp 14 echo "#" >> ${out}.tmp 15 echo "# $kind info" >> ${out}.tmp 16 echo "#" >> ${out}.tmp 17 echo "###########################################################" >> ${out}.tmp 18 19 cat ${nodes}.${kind}.txt | while read host 20 do 21 subdir='public_html' 22 if [[ 'nmon' == "${kind}" ]] 23 then 24 subdir='data' 25 fi 26 dest="/home/${kind}/${subdir}" 27 # make sure directory is there 28 if [[ ! -d ${dest}/${host} ]] 29 then 30 mkdir -p ${dest}/${host} 31 chown ${kind}:${kind} ${dest}/${host} 32 fi 33 # make rsync stanza 34 echo " " >> ${out}.tmp 35 echo "[${kind}-${host}]" >> ${out}.tmp 36 echo " comment = ${host} to drop ${kind} related info into" >> ${out}.tmp 37 echo " uid = ${kind}" >> ${out}.tmp 38 echo " gid = ${kind}" >> ${out}.tmp 39 echo " readonly = false" >> ${out}.tmp 40 echo " writeonly = true" >> ${out}.tmp 41 echo " list = false" >> ${out}.tmp 42 echo " path = /home/${kind}/${subdir}/${host}" >> ${out}.tmp 43 echo " hosts allow = ${host}" >> ${out}.tmp 44 echo " " >> ${out}.tmp 45 done 46 done 47 dt=$(date '+%Y%m%d'); 48 cp -p ${out} ${out}.${dt} 49 cp -f ${out}.tmp ${out} 50 51 # rm -f ${out}.tmp 52 53 exit