【发布时间】:2017-03-15 21:40:48
【问题描述】:
我是 linux 打包的新手,所以我可能会遗漏一些明显的东西。我正在将我的程序打包到deb 和rpm 包中,我正在使用fpm 来帮助我。我需要人们在安装结束时输入他们的 API 密钥,以便可以自动更新配置文件。我有一个包含这部分的blah.postinst 文件:
#!/bin/bash
set -e
read -p 'Please enter your API key(skip this step by just press ENTER): ' apikey_var
if [[ ! -z $apikey_var ]]
then
echo "The API key is set. You could always change it by editing /etc/agent/process-collector.ini file"
sed "s/sample_apikey/$apikey_var/" /etc/agent/process-collector.ini.example > /etc/agent/process-collector.ini
else
echo "You didn't enter any API key, you could always add it by editing /etc/agent/process-collector.ini file"
mv /etc/agent/process-collector.ini.example /etc/agent/process-collector.ini
fi
我正在使用 fpm 的 --after-install 标志来包含此脚本。
这适用于deb 包,但是在我使用 fpm 创建rpm 包并尝试安装它之后,read -p 'Please enter your API key(skip this step by just press ENTER): ' apikey_var(我认为)行会产生错误:
warning: %post(process-agent-0.99.0-1.x86_64) scriptlet failed, exit status 1
Non-fatal POSTIN scriptlet failure in rpm package dd-process-agent-0.99.0-1.x86_64
我想如果我手动创建一个 rpm 包,blah.postinst 脚本中的代码将正好适合spec 文件的%post 部分,但我不知道会出现什么问题。有人可以帮忙吗?或者至少我该如何调试?谢谢。
【问题讨论】: