2440657742
system intended for use by wireless edge routers ('nodes').
48 lines
1.1 KiB
Bash
48 lines
1.1 KiB
Bash
#!/bin/sh
|
|
|
|
PATH=/bin:/usr/sbin
|
|
|
|
if [ -z "${ENABLE_USER}" ]; then
|
|
ENABLE_USER=nocat
|
|
fi
|
|
|
|
if [ -z "${ENABLE_GROUP}" ]; then
|
|
ENABLE_GROUP=nocat
|
|
fi
|
|
|
|
case $2 in
|
|
PRE-INSTALL)
|
|
UID=181
|
|
GID=${UID}
|
|
if pw group show "${ENABLE_GROUP}" 2>/dev/null; then
|
|
echo "You already have a group \"${ENABLE_GROUP}\", so I will use it."
|
|
else
|
|
if pw groupadd ${ENABLE_GROUP} -g ${GID}; then
|
|
echo "Added group \"${ENABLE_GROUP}\."
|
|
else
|
|
echo "Adding group \"${ENABLE_GROUP}\" failed."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if pw user show "${ENABLE_USER}" 2>/dev/null; then
|
|
echo "You already have a user \"${ENABLE_USER}\", so I will use it."
|
|
if pw usermod ${ENABLE_USER} -d ${NOCAT_DIR}
|
|
then
|
|
echo "Changed home directory of \"${ENABLE_USER}\" to \"${SYSCONF_DIR}\""
|
|
else
|
|
"${SYSCONF_DIR}\" failed..."
|
|
exit 1
|
|
fi
|
|
else
|
|
if pw useradd ${ENABLE_USER} -u ${UID} -g ${ENABLE_GROUP} -h \
|
|
-d ${SYSCONF_DIR} -s /sbin/nologin -c "NoCat Daemon"
|
|
then
|
|
echo "Added user \"${ENABLE_USER}\"."
|
|
else
|
|
echo "Adding user \"${ENABLE_USER}\" failed..."
|
|
exit 1
|
|
fi
|
|
fi
|
|
;;
|
|
esac
|