From 155dfde2a1a69f4d5d3c5ea337a1c809373de5c9 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Thu, 22 Sep 2022 13:42:11 +0100 Subject: [PATCH 1/2] FreeBSD: Create run dir. Create owner. Add users to group --- scripts/packages/postinstall.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/packages/postinstall.sh b/scripts/packages/postinstall.sh index 52c97310c..4187163ae 100755 --- a/scripts/packages/postinstall.sh +++ b/scripts/packages/postinstall.sh @@ -91,7 +91,6 @@ fi printf "Found nginx-agent %s\n" "${AGENT_EXE}" -# Fill in data to unit file that's acquired post install if command -v systemctl; then printf "PostInstall: Adding nginx-agent group %s\n" "${AGENT_GROUP}" groupadd "${AGENT_GROUP}" @@ -102,13 +101,28 @@ if command -v systemctl; then printf "PostInstall: Adding NGINX Worker user %s to group %s\n" "${WORKER_USER}" "${AGENT_GROUP}" usermod -a -G "${AGENT_GROUP}" "${WORKER_USER}" fi +fi - printf "PostInstall: Creating NGINX Agent run directory \n" - mkdir -p "${AGENT_RUN_DIR}" +if [ "$ID" = "freebsd" ]; then + printf "PostInstall: Adding nginx-agent group %s\n" "${AGENT_GROUP}" + pw groupadd "${AGENT_GROUP}" - printf "PostInstall: Modifying group ownership of NGINX Agent run directory \n" - chown "${AGENT_USER}":"${AGENT_GROUP}" "${AGENT_RUN_DIR}" + printf "PostInstall: Adding NGINX / agent user %s to group %s\n" "${AGENT_USER}" "${AGENT_GROUP}" + pw groupmod "${AGENT_GROUP}" -M "${AGENT_USER}" + if [ "${WORKER_USER}" ]; then + printf "PostInstall: Adding NGINX Worker user %s to group %s\n" "${WORKER_USER}" "${AGENT_GROUP}" + pw groupmod "${AGENT_GROUP}" -M "${WORKER_USER}" + fi +fi + +printf "PostInstall: Creating NGINX Agent run directory \n" +mkdir -p "${AGENT_RUN_DIR}" +printf "PostInstall: Modifying group ownership of NGINX Agent run directory \n" +chown "${AGENT_USER}":"${AGENT_GROUP}" "${AGENT_RUN_DIR}" + +# Fill in data to unit file that's acquired post install +if command -v systemctl; then printf "PostInstall: Modifying NGINX Agent unit file with correct locations and user information\n" EXE_CMD="s|\${AGENT_EXE}|${AGENT_EXE}|g" sed -i -e $EXE_CMD ${AGENT_UNIT_LOCATION}/${AGENT_UNIT_FILE} From 60e67c0b10356fc3e5ec29fe38598bfdae2228e0 Mon Sep 17 00:00:00 2001 From: Dean Coakley Date: Thu, 22 Sep 2022 14:59:59 +0100 Subject: [PATCH 2/2] Add alpine user/group management --- scripts/packages/postinstall.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/packages/postinstall.sh b/scripts/packages/postinstall.sh index 4187163ae..f503bd58a 100755 --- a/scripts/packages/postinstall.sh +++ b/scripts/packages/postinstall.sh @@ -115,6 +115,18 @@ if [ "$ID" = "freebsd" ]; then fi fi +if [ "$ID" = "alpine" ]; then + printf "PostInstall: Adding nginx-agent group %s\n" "${AGENT_GROUP}" + addgroup "${AGENT_GROUP}" + + printf "PostInstall: Adding NGINX / agent user %s to group %s\n" "${AGENT_USER}" "${AGENT_GROUP}" + addgroup "${AGENT_USER}" "${AGENT_GROUP}" + if [ "${WORKER_USER}" ]; then + printf "PostInstall: Adding NGINX Worker user %s to group %s\n" "${WORKER_USER}" "${AGENT_GROUP}" + addgroup "${WORKER_USER}" "${AGENT_GROUP}" + fi +fi + printf "PostInstall: Creating NGINX Agent run directory \n" mkdir -p "${AGENT_RUN_DIR}"