Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Situation: I'm trying to build a custom rpm to place a config file in a particular location. The installation completes fine by placing config files in proper directories but the %post section is not working. This section echoes user to make an input and 'reads' it. This read value is to be placed in those config files with help of 'sed'.

Issue: 'read' is not working in the %post section ie. the installation process does not wait for user to provide input. It basically completes the installation by placing files in the directories. In short, the %post section is not being interactive for user to provide input.

Please see the SPEC file here: http://pastebin.com/5BgkJUpG . This will help to get the idea.

I wrote the exact same lines of %post section above for "postint" section of building a .deb package and it worked fine there. User installing the deb package was able to make the input and this given value was placed in the config file with 'sed'.

share|improve this question
    
I got nothing on why %post doesn't work, but you could clean up your echo/read with: read -p "Enter hostname " h –  Aaron Copley Sep 24 '12 at 20:15
    
Thanks. But your suggestion isn't working too. Is it because rpm doesn't allow %post sections to be interactive like .deb? –  user492160 Sep 24 '12 at 20:25
    
Sorry, I don't think you understood.. I was just making a suggestion for reducing an echo/read to just a read. As for it not running in %post of an RPM -- I have no experience. –  Aaron Copley Sep 24 '12 at 20:28
    
oh ok. thanks. I just found out the reason, will post it as answer. –  user492160 Sep 24 '12 at 20:32
    
Don't do this. Use a real configuration management solution like puppet or chef. –  Michael Hampton Sep 24 '12 at 20:54

3 Answers 3

I don't believe that RPMs were intended to be able to be ran interactively. You're making a couple of dangerous assumptions in that the RPM is not being installed by configuration management in an automated way or a GUI front end. Neither scenario bodes well for an RPM that expects input from the shell.

Maybe I can suggest an alternative? Is this prompt for the hostname of the target host? I.E. could your sed include $(hostname) rather than getting input from stdin?

I found this reference to someone attempting the same. Their suggestion was to get the input in %pre some how?

share|improve this answer
up vote 1 down vote accepted

A user from "Unix and Linux" contributed this answer:

From Fedora's RPM guide:

Warning Do not try to write interactive scripts. Many users install RPMs automatically. In such cases, or if the user runs a graphical RPM tool, any information your scripts output will be lost. User input will not be available.

share|improve this answer

I think you are looking for a relocatable rpm.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.