ensure user is setup in preinstall hook

This commit is contained in:
Cody Lee
2022-12-23 12:12:29 -06:00
parent e769401ca3
commit 03c31f8ad6
3 changed files with 87 additions and 18 deletions

View File

@@ -24,21 +24,6 @@ OS="$(uname -s)"
cleanInstall() {
printf "\033[32m Post Install of an clean install\033[0m\n"
# Step 3 (clean install), enable the service in the proper way for this platform
if [ "${OS}" = "Linux" ]; then
# Make a user and group for this app, but only if it does not already exist.
id unpoller >/dev/null 2>&1 || \
useradd --system --user-group --no-create-home --home-dir /tmp --shell /bin/false unpoller
elif [ "${OS}" = "OpenBSD" ]; then
id unpoller >/dev/null 2>&1 || \
useradd -g =uid -d /tmp -s /bin/false unpoller
elif [ "${OS}" = "FreeBSD" ]; then
id unpoller >/dev/null 2>&1 || \
pw useradd unpoller -d /tmp -w no -s /bin/false
else
echo "Unknown OS: ${OS}, please add system user unpoller manually."
fi
if [ "${use_systemctl}" = "False" ]; then
if command -V chkconfig >/dev/null 2>&1; then

18
scripts/pre-install.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/sh
OS="$(uname -s)"
if [ "${OS}" = "Linux" ]; then
# Make a user and group for this app, but only if it does not already exist.
id unpoller >/dev/null 2>&1 || \
useradd --system --user-group --no-create-home --home-dir /tmp --shell /bin/false unpoller
elif [ "${OS}" = "OpenBSD" ]; then
id unpoller >/dev/null 2>&1 || \
useradd -g =uid -d /tmp -s /bin/false unpoller
elif [ "${OS}" = "FreeBSD" ]; then
id unpoller >/dev/null 2>&1 || \
pw useradd unpoller -d /tmp -w no -s /bin/false
else
echo "Unknown OS: ${OS}, please add system user unpoller manually."
fi