#!/bin/bash kinds='rpms nmon' stub="/etc/rsyncd.conf.stub" nodes='/etc/rsyncd.nodes' out='/etc/rsyncd.conf' rm -f ${out}.tmp cp ${stub} ${out}.tmp for kind in ${kinds} do echo "############################################################" >> ${out}.tmp echo "#" >> ${out}.tmp echo "# $kind info" >> ${out}.tmp echo "#" >> ${out}.tmp echo "###########################################################" >> ${out}.tmp cat ${nodes}.${kind}.txt | while read host do subdir='public_html' if [[ 'nmon' == "${kind}" ]] then subdir='data' fi dest="/home/${kind}/${subdir}" # make sure directory is there if [[ ! -d ${dest}/${host} ]] then mkdir -p ${dest}/${host} chown ${kind}:${kind} ${dest}/${host} fi # make rsync stanza echo " " >> ${out}.tmp echo "[${kind}-${host}]" >> ${out}.tmp echo " comment = ${host} to drop ${kind} related info into" >> ${out}.tmp echo " uid = ${kind}" >> ${out}.tmp echo " gid = ${kind}" >> ${out}.tmp echo " readonly = false" >> ${out}.tmp echo " writeonly = true" >> ${out}.tmp echo " list = false" >> ${out}.tmp echo " path = /home/${kind}/${subdir}/${host}" >> ${out}.tmp echo " hosts allow = ${host}" >> ${out}.tmp echo " " >> ${out}.tmp done done dt=$(date '+%Y%m%d'); cp -p ${out} ${out}.${dt} cp -f ${out}.tmp ${out} # rm -f ${out}.tmp exit