代码之家  ›  专栏  ›  技术社区  ›  Ed of the Mountain

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

  •  2
  • Ed of the Mountain  · 技术社区  · 15 年前

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

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

    提前谢谢,

    -埃德

    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
    
    1 回复  |  直到 15 年前
        1
  •  1
  •   m1tk4    15 年前

    使用

    %_sbindir/groupadd

    %{_sbindir}

    在使用类似mc的东西构建rpm之后,检查它们,提取pre脚本,您就可以检查扩展是否正常工作。

    实际上,那里不需要%\u sbindir。如果你看看RedHat是如何构建httpd….rpm的,你会发现他们只使用groupadd和useradd,没有完整的路径。

    推荐文章