<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-07-20 12:01 GMT+02:00 Kristian <span dir="ltr"><<a href="mailto:kristianonline28@gmail.com" target="_blank">kristianonline28@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
thank you for your reply. Yes, I add the script with<br>
> set(CPACK_RPM_POST_INSTALL_<wbr>SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/<wbr>postinstall")<br>
<br>
and it basically works, because this file is changing a settings file<br>
without any problems. Only the add of the group and the user does not<br>
work, somehow.<br>
<br>
This is the part in the postinstall script, which should add group and user:<br>
<br>
=====<br>
WEB_USER=web1<br>
WEB_GROUP=web1<br>
<br>
# create group<br>
groupadd "${WEB_GROUP}" --force --system<br>
# retrieve group id<br>
WEB_GROUP_ID="$(getent group '$WEB_GROUP' | cut -d: -f3)"<br>
echo "Group '${WEB_GROUP}' added with id '${WEB_GROUP_ID}'"<br>
# create user<br>
useradd "$WEB_USER" -g "${WEB_GROUP_ID}" -M -r -s /sbin/nologin -c<br>
"Web user - created during the installation."<br>
echo "User '${WEB_USER}' added."<br>
=====<br>
<br>
And this is, what is being printed during installation:<br>
=====<br>
Group 'web1' added with id ''<br>
useradd: group '' does not exist<br>
User 'web1' added.<br>
=====<br></blockquote><div><br></div><div>What is the shebang your ar using at the top of this script?</div><div><br></div><div>this syntax:</div><div><div>WEB_GROUP_ID="$(getent group '$WEB_GROUP' | cut -d: -f3)"</div></div><div><br></div><div>may be bash only.</div><div><br></div><div>not sure it makes a difference but you could try:</div><div><br></div><div>WEB_GROUP_ID="$(getent group '${WEB_GROUP}' | cut -d: -f3)"<br></div><div><br></div><div>note that getting the numeric group id seems unecessary.</div><div><br></div><div>useradd "$WEB_USER" -g "${WEB_GROUP}" -M -r -s /sbin/nologin -c<br></div><div><br></div><div>should work, useradd should work equally well with numeric or symbolic id of a group.</div><div><br></div><div><br></div><div>--</div><div>Eric</div></div>
</div></div>