rpm - rpm.spec 中设置 systemd 预设的正确命令是什么
问题描述
我的程序中有几个单元,例如:
- 程序服务
- 程序清理服务
- 程序-cleanup.timer
- ...
以及一个“program-cleanup.preset”文件,它只是说:
enable program-cleanup.timer
我无法理解我应该如何在此处设置文件。目前我的 rpm.spec 运行以下命令:
...
install -D -m 0644 %{_sourcedir}/build/program.service %{_unitdir}/program.service
install -D -m 0644 %{_sourcedir}/build/program-cleanup.service %{_unitdir}/program-cleanup.service
install -D -m 0644 %{_sourcedir}/build/program-cleanup.timer %{_unitdir}/program-cleanup.timer
install -D -m 0644 %{_sourcedir}/build/program-cleanup.preset %{_presetdir}/program-cleanup.preset
我需要在 .spec 文件systemctl preset program-cleanup.preset
的%post
一部分中运行吗?如果我添加更多预设,我是否必须为每个预设再添加一行?
解决方案
我个人以前没有使用过预设文件,但它们看起来很有趣。这里似乎是一个很好的设置(我只提到相关部分):
%install
install -D -m 0644 %{_sourcedir}/build/program-cleanup.preset %{_presetdir}/program-cleanup.preset
%post
systemd preset program-cleanup.preset
%preun
if [ $1 -eq 0 ] ; then
# really uninstalling, not upgrading:
# probably you might want to stop and disable your units when uninstalling:
systemctl stop program.service
systemctl disable program.service
...
fi
%files
%{_presetdir}/program-cleanup.preset
推荐阅读
- amazon-web-services - AWS Amplify SES sendmail AccessDenied
- r - 邓恩的测试循环数据框的列
- kotlin - mock 验证 lambda 在 mock 中传递
- google-analytics - 谷歌分析未能在产品列表表现中记录产品列表点击
- javascript - 结合图表和地图
- c# - 使用列表会导致意外行为
- python - 求解具有许多不同初始条件的相同微分方程?
- ios - 如何在 iOS 中为暗模式更改设置动画?
- google-apps-script - 谷歌表格脚本删除新行
- javascript - 如何在不去除背景的情况下去除两个矩形的交集?