tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

rc.d/postfix:postfix_precmd()



I think the part of postfix_precmd() that tries to re-build the alias 
databases is less than helpful:

1. It doesn't deal with alias_database entries seperated by commas
2. It doesn't do variable expansion on the alias_database entries
3. It runs newaliases for every outdated or missing member instead of once.

I don't know how to properly handle (2). The only way I can think of is 
through postconf -b, but that's quite ugly.
The most common case should be a leading $config_directory


	_rebuild=false
	_configdir=$($postconf -h config_directory)
	_IFS="$IFS"; IFS=",$IFS"
	for f in $($postconf -h alias_database); do
		case $f in
			hash:*) f="${f#hash:}" ;;
			*) continue ;;
		esac
		case $f in
			\$config_directory*) f="$_configdir${f#\$config_directory}" ;;
			\${config_directory}*) f="$_configdir${f#\${config_directory\}}" ;;
			\$\(config_directory\)*) f="$_configdir${f#\$(config_directory)}" ;;
		esac
		if [ ! -e "$f.db" ]; then
			_reason="missing"
			_rebuild=true;
		elif [ "$f" -nt "$f.db" ]; then
			_reason="out of date"
			_rebuild=true;
		else
			_reason=""
		fi
		if [ -n "$_reason" ]; then
			echo "${name}: rebuilding $f ($_reason $f.db)"
			_rebuild=true
		fi
	done
	IFS="$_IFS"
	
	if $_rebuild; then
		echo $($postconf -h newaliases_path)
	fi


Home | Main Index | Thread Index | Old Index