yalhcru at gmail.com
Tue Mar 31 02:59:34 UTC 2020
On 3/30/20, Biff Eros <bifferos at gmail.com> wrote:
> I started off manually creating user/group creation scripts for
> Afterpkg, looking a bit like this:
Interesting project... not sure I'd want to mix-and-match pip-installed
and SBo-installed stuff, but if someone does want to, your script looks
like it should handle it well.
The before.sh you linked does something horrible though. Nobody should
ever grep /etc/passwd and/or group to see if a user exists (what if
they're using LDAP authentication? NIS? In 15.0 we're going to have PAM,
what if they're using something we never even heard of before?)
Instead use getent. Like so:
# Create the mongo group
if getent group mongo >/dev/null ; then
echo "mongo group exists, no need to add it"
echo "Creating mongo group"
groupadd -r -g 285 mongo
# Create the mongo user
if getent passwd mongo >/dev/null ; then
echo "mongo user exists, no need to add it"
echo "Creating mongo user"
useradd -u 285 -d /var/lib/mongodb -s /bin/false -g mongo mongo
Notice it's a pretty minor change: only the two "if grep" lines are
different. getent is is part of glibc, so it's guaranteed to be present
on any Slack box that's able to compile anything.
If you're generating the uid/gid creation scripts, I guess you only have
to change it in one place (the generator script).
More information about the SlackBuilds-users