为什么在安装 rpm 后调用 adduser 和 groupadd 不起作用?

发布于 2024-09-11 00:37:59 字数 611 浏览 10 评论 0原文

我将以下“Pre”部分添加到 rpm 安装程序的 build.spec 中。当我安装 rpm 时,没有创建新组或用户?

如果我将其粘贴到脚本中并运行,那么它会按预期工作。我缺少什么?

提前致谢,

-Ed

RHEL 5.2

#######################
# pre
#######################
%pre

# This works when run as a script by root.  Why not from the RPM?
if grep ^frontier: /etc/group >> /dev/null ; then
 : # group already exists
else
 %{_sbindir}/groupadd frontier -g 2000
fi

if ! id diagnostics >& /dev/null; then 
 %{_sbindir}/adduser diagnostics -g diaguser -d /home/diagnostics -u 2001 -p secretPassword
 usermod -a -G frontier diagnostics
fi

I added the following "Pre" section to my rpm installer's build.spec. When I install the rpm no new group or user is created?

If I paste this into a script and run, then it works as expected. What am I missing?

Thanks in advance,

-Ed

RHEL 5.2

#######################
# pre
#######################
%pre

# This works when run as a script by root.  Why not from the RPM?
if grep ^frontier: /etc/group >> /dev/null ; then
 : # group already exists
else
 %{_sbindir}/groupadd frontier -g 2000
fi

if ! id diagnostics >& /dev/null; then 
 %{_sbindir}/adduser diagnostics -g diaguser -d /home/diagnostics -u 2001 -p secretPassword
 usermod -a -G frontier diagnostics
fi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2024-09-18 00:37:59

使用

<代码>
%_sbindir/groupadd

而不是


%{_sbindir}

在使用 mc 之类的工具构建 RPM 后检查您的 RPM,提取预脚本,您将能够检查您的扩展是否正常工作。

事实上,那里不需要%_sbindir。如果你看看 RedHat 如何构建 httpd....rpm,你会发现他们只使用 groupadd 和 useradd 而没有完整路径。

Use


%_sbindir/groupadd

instead of


%{_sbindir}

Check your RPMs after they build with something like mc, extract the pre script and you'll be able to check that your expansion works right.

In fact, %_sbindir is not needed there. If you take a look how RedHat built httpd....rpm you'll see they just use groupadd and useradd without the full path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文