全新安装操作系统后是否可以构建用于系统配置的 RPM?
我想做的是创建一个 RPM,我将在全新安装操作系统后运行它。我希望它运行我创建的自定义脚本,该脚本当前将一堆东西复制到操作系统并配置不同的服务等,以及安装一堆 rpm。如果可以做到这一点,那么我所需要的只是闪存驱动器上包含所有内容的单个 rpm 文件(我需要输入的只是 rpm -i xxx.rpm),而不是那些乱七八糟的目录和文件。我目前有(我当前输入 install.sh)。这可以做到吗?
What I'm trying to do is create an RPM that I will run after a fresh install of the OS. I want it to run a custom script I have created that currently copies over a bunch of things to the OS and configures different services and such, as well as installs a bunch of rpms. If this can be done, then all I will need is the single rpm file on my flash drive that contains everything inside (and all I would need to type is rpm -i xxx.rpm) instead of the whole mess of directories and files that I currently have (where I currently type install.sh). Can this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当您安装 rpm 时,成功安装后都会调用 %post-scriplet。因此,如果您在 %post-install scriplet 下调用脚本,它将在每次 rpm 安装后执行。
Whenever you install a rpm, the %post-scriplet will get invoked after the successful installation. Thus if you call your script under the %post-install scriplet, it will get executed after every rpm installation.
是的。尽可能多地放入 /etc 的“.d”目录中,以便卸载后一切都会恢复。这还有一个优点,即执行“rpm -ql”将使您很好地了解此 RPM 修改了哪些设置。
对于需要编辑配置文件的设置,请遵循 Ashok 的建议,并将自定义内容放在安装后部分中。更好的是,创建两个脚本来修改和恢复设置,将它们安装在适当的位置(可能在路径外的 /usr/share 下),并分别从 post-in 和 post-un 部分调用它们。
Yes. Put as much as you can in /etc's ".d" directories, so that after un-installation everything is restored. This also has the advantage that doing a "rpm -ql" will give you a good idea of what settings this RPM modifies.
For the settings that require editing config files, follow Ashok's advice and put customizations in the post-install section. Better yet, create two scripts that modify and revert the settings, install them somewhere appropriate (probably under /usr/share out of the path), and call them from the post-in and post-un sections respectively.