LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-18-2014, 09:05 AM   #1
jeewiz
LQ Newbie
 
Registered: Jan 2007
Distribution: CentOS 6.5
Posts: 21

Rep: Reputation: 0
RPM %pre substitute user


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 not found, attempting to create"
        su - postgres
            psql -c "CREATE DATABASE foobar;"
            psql -U postgres -d foobar -c "CREATE USER foo WITH PASSWORD 'foopass';"
            psql -U postgres -d foobar -c "GRANT ALL PRIVILEGES ON DATABASE foobar TO foo;"
            psql -U postgres -d foobar -c "CREATE EXTENSION postgis;"
        exit
    fi
else
    echo "Postgres not found locally, please modify /etc/foo/foobar.xml line 23 and 31 to point to the Postgres host and create foobar therein"
fi
 
Old 07-18-2014, 11:03 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,353
Blog Entries: 55

Rep: Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541Reputation: 3541
Quote:
Originally Posted by jeewiz View Post
The error I receive on RPM installation is "psql: FATAL: role "root" does not exist." Any ideas?
AFAIK this hasn't got anything to do with RPM or %pre but with database roles. Start here: http://www.postgresql.org/docs/curre...ser-manag.html ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
create rpm from pre compile tar.gz netguy2000 Linux - General 6 04-25-2011 07:12 AM
Best way to code rpm pre/post scripts thespaceman Linux - Software 3 03-24-2010 03:38 AM
Call scripts in Rpm's: %pre %post section vibhor_agarwalin Linux - General 4 04-13-2009 12:18 AM
How to build a pre compiled kernel with source as a single rpm? sundarhere Linux - Kernel 0 10-26-2006 02:27 AM
rpm --verify net-tools gives pre link errors abefroman Fedora - Installation 0 04-11-2004 10:42 AM


All times are GMT -5. The time now is 08:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration