<div dir="auto"><div>I think there was some reason I couldn't rely on getent being present when I wrote that code, initially I was using it in the context of a minimal install but you are right, I will make that change, thanks for letting me know.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 31, 2020, 3:59 AM B Watson <<a href="mailto:yalhcru@gmail.com">yalhcru@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 3/30/20, Biff Eros <<a href="mailto:bifferos@gmail.com" target="_blank" rel="noreferrer">bifferos@gmail.com</a>> wrote:<br>
<br>
> I started off manually creating user/group creation scripts for<br>
> Afterpkg, looking a bit like this:<br>
> <a href="https://github.com/bifferos/afterpkg/blob/master/scripts/system/mongodb/before.sh" rel="noreferrer noreferrer" target="_blank">https://github.com/bifferos/afterpkg/blob/master/scripts/system/mongodb/before.sh</a><br>
<br>
Interesting project... not sure I'd want to mix-and-match pip-installed<br>
and SBo-installed stuff, but if someone does want to, your script looks<br>
like it should handle it well.<br>
<br>
The before.sh you linked does something horrible though. Nobody should<br>
ever grep /etc/passwd and/or group to see if a user exists (what if<br>
they're using LDAP authentication? NIS? In 15.0 we're going to have PAM,<br>
what if they're using something we never even heard of before?)<br>
<br>
Instead use getent. Like so:<br>
<br>
---cut-here---<br>
#!/bin/bash<br>
<br>
# Create the mongo group<br>
if getent group mongo >/dev/null ; then<br>
  echo "mongo group exists, no need to add it"<br>
else<br>
  echo "Creating mongo group"<br>
  groupadd -r -g 285 mongo<br>
fi<br>
<br>
# Create the mongo user<br>
if getent passwd mongo >/dev/null ; then<br>
  echo "mongo user exists, no need to add it"<br>
else<br>
  echo "Creating mongo user"<br>
  useradd -u 285 -d /var/lib/mongodb -s /bin/false -g mongo mongo<br>
fi<br>
---cut-here---<br>
<br>
Notice it's a pretty minor change: only the two "if grep" lines are<br>
different. getent is is part of glibc, so it's guaranteed to be present<br>
on any Slack box that's able to compile anything.<br>
<br>
If you're generating the uid/gid creation scripts, I guess you only have<br>
to change it in one place (the generator script).<br>
_______________________________________________<br>
SlackBuilds-users mailing list<br>
<a href="mailto:SlackBuilds-users@slackbuilds.org" target="_blank" rel="noreferrer">SlackBuilds-users@slackbuilds.org</a><br>
<a href="https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users" rel="noreferrer noreferrer" target="_blank">https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users</a><br>
Archives - <a href="https://lists.slackbuilds.org/pipermail/slackbuilds-users/" rel="noreferrer noreferrer" target="_blank">https://lists.slackbuilds.org/pipermail/slackbuilds-users/</a><br>
FAQ - <a href="https://slackbuilds.org/faq/" rel="noreferrer noreferrer" target="_blank">https://slackbuilds.org/faq/</a><br>
<br>
</blockquote></div></div></div>