开发者

How to take user input during install

So when I create a debian package, I am able to write a post-installation shell script that runs just fine. Currently mine is configured to do

  echo "Please enter your MySQL Database user (default root)"
  read MYSQL_USER
  echo "Please enter the MySQL Database user password (default root)"
  read -s MYSQL_PASS

DBEXIST=0    
CMD="create database lportal;use lportal;"
(mysql -u$MYSQL_USER -p$MYSQL_PASS -e "$CMD") || ((DBEXIST++))
if [ $DBEXIST -ne 0 ]; then
  echo "Setup finished, but MySQL already has an lportal table. This could be from a previous installation of Liferay. If you want a fresh installation of this bundle, please remove the lportal table and reinstall this package."
fi

This works fine for Ubuntu. However, I can't seem to get user input to work with RPMs for Fedora. Is there a good way to take user input? From what I understand, RPMs were designed not to allow interactive installs. However I can't see a better way to do this..

Is there possibly a way to automatically find local MySQL settings without asking the开发者_开发问答 user? Otherwise, what's the best way to ask for user input?


Okay I've resolved this without a real answer -- basically from what I understand, I have two options -- one is a wrapper script like Bind or CUPS uses. It's not considered good packaging practice though, and I'm still unsure how to go about doing it. Better is just to assign default values in the %POST script, and create a firstrun flag. The first time the user launches the software, it prompts for configuration settings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜