1

我是 linux 包装的新手,所以我可能会遗漏一些明显的东西。我正在打包我的程序debrpm打包,我正在使用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脚本中的代码只会适合文件的%post部分spec,但我不知道会出现什么问题。有人可以帮忙吗?或者至少我该如何调试?谢谢。

4

1 回答 1

2

这之前已经讨论过;rpms 旨在实现自动化。不要期望终端那里进行交互。它可能在另一个会话中(喜欢anacondapuppet愿意)。可能是有背景的。这可能是一项 cron 工作。让它在第一次运行时收集信息,或者让他们运行“入门”指南中注明的脚本。

于 2017-03-16T01:18:16.387 回答