RPM %pre substitute user

view story

http://www.linuxquestions.org – The below is a snippet of my RPM preinstall section. Where it's failing is the su - postgres. I can't find any documentaion on why this would fail, or any possible work-arounds. The error I receive on RPM installation is "psql: FATAL: role "root" does not exist." Any ideas? Code: %pre postgres_install=`rpm -qa | grep '\<postgres.*server\>' | wc -l` if [ $postgres_install -ne 0 ]; then     foo_check=`su - postgres -c "psql -l | grep foobar | wc -l"`     if [ $foo_check -eq 0 ]; then         echo "FOOBAR table (HowTos)