From d12de839b139bcdc1551c1b2b642fa7832d88653 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Mon, 27 Nov 2023 06:11:08 +0000 Subject: [PATCH] Fixed group permissions --- .../run_onchange_after_57-netdata.sh.tmpl | 6 +++-- ..._onchange_before_11-install-docker.sh.tmpl | 2 +- home/dot_local/bin/executable_add-user | 6 ++--- home/dot_local/bin/executable_install-program | 23 +------------------ software.yml | 2 ++ 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/home/.chezmoiscripts/universal/run_onchange_after_57-netdata.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_57-netdata.sh.tmpl index 58daaad6..e33098a4 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_57-netdata.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_57-netdata.sh.tmpl @@ -66,8 +66,8 @@ if command -v netdata-claim.sh > /dev/null; then NETDATA_ETC='/usr/local/etc/netdata/' elif [ -d /etc/netdata ]; then NETDATA_ETC='/etc/netdata' - elif [ -d "$HOMEBREW_PREFIX/etc/netdata" ]; then - NETDATA_ETC="$HOMEBREW_PREFIX/etc/netdata" + elif [ -d "${HOMEBREW_PREFIX:-/opt/homebrew}/etc/netdata" ]; then + NETDATA_ETC="${HOMEBREW_PREFIX:-/opt/homebrew}/etc/netdata" else logg error 'No etc location found for netdata' && exit 1 fi @@ -79,6 +79,8 @@ if command -v netdata-claim.sh > /dev/null; then NETDATA_LIB='/usr/local/lib/netdata' elif [ -d /usr/lib/netdata ]; then NETDATA_LIB='/usr/lib/netdata' + elif [ -d "${HOMEBREW_PREFIX:-/opt/homebrew}/lib/netdata" ]; then + NETDATA_LIB="${HOMEBREW_PREFIX:-/opt/homebrew}/lib/netdata" else logg error 'No lib location found for netdata' && exit 1 fi diff --git a/home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.sh.tmpl index 4067cd90..338e5ff2 100644 --- a/home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.sh.tmpl @@ -117,7 +117,7 @@ function gVisorPreBuilt() { function gVisorGo() { # Official build timed out - use Go method logg info 'Installing gVisor using the Go fallback method' - sudo chown -Rf "$(whoami)" /usr/local/src/gvisor + sudo chown -Rf sudo chown -Rf rclone:rclone "$PRIVATE_SHARE" || sudo chown -Rf rclone:$(id -g -n) "$PRIVATE_SHARE" /usr/local/src/gvisor cd /usr/local/src/gvisor echo "module runsc" > go.mod GO111MODULE=on go get gvisor.dev/gvisor/runsc@go diff --git a/home/dot_local/bin/executable_add-user b/home/dot_local/bin/executable_add-user index 9d9dc26e..5dce4d30 100644 --- a/home/dot_local/bin/executable_add-user +++ b/home/dot_local/bin/executable_add-user @@ -46,8 +46,8 @@ if [[ "$(uname)" == "Darwin" ]]; then sudo dscl . create /Groups/"${GROUP}" # Ensure the group has a GID if [[ "$(sudo dscl . read /Groups/"$group" gid 2>&1)" == *"No such key"* ]]; then - MAX_ID_GROUP=$(dscl . -list /Groups gid | awk '{print $2}' | sort -ug | tail -1) - GROUP_ID=$((MAX_ID_GROUP+1)) + MAX_ID_GROUP="$(dscl . -list /Groups gid | awk '{print $2}' | sort -ug | tail -1)" + GROUP_ID="$((MAX_ID_GROUP+1))" sudo dscl . create /Groups/"${GROUP}" gid "$GROUP_ID" fi else @@ -68,7 +68,7 @@ if [[ "$(uname)" == "Darwin" ]]; then fi # Ensure the user has a UniqueID if [[ "$(sudo dscl . read /Users/"${GROUP}" UniqueID 2>&1)" == *"No such key"* ]]; then - MAX_ID_USER=$(dscl . -list /Users UniqueID | sort -nr -k 2 | head -1 | grep -oE "[0-9]+$") + MAX_ID_USER="$(dscl . -list /Users UniqueID | sort -nr -k 2 | head -1 | grep -oE "[0-9]+$")" USER_ID="$((MAX_ID_USER+1))" sudo dscl . create /Users/"${GROUP}" UniqueID "$USER_ID" fi diff --git a/home/dot_local/bin/executable_install-program b/home/dot_local/bin/executable_install-program index 4646733f..5dc9318a 100644 --- a/home/dot_local/bin/executable_install-program +++ b/home/dot_local/bin/executable_install-program @@ -1536,28 +1536,7 @@ async function installPackageList(packageManager, packages) { async function addUserGroup(group) { const logStage = 'Users / Groups' log('info', logStage, `Ensuring the ${group} group / user is added`) - if (osType === 'linux') { - const useradd = which.sync('useradd', { nothrow: true }) - const usermod = which.sync('usermod', { nothrow: true }) - if (useradd && usermod) { - runCommand(`Adding the ${group} user / group`, `sudo useradd ${group}`) - runCommand(`Adding the ${process.env.USER} user to the ${group} group`, `sudo usermod -a -G ${group} ${process.env.USER}`) - } else { - log('error', logStage, `The useradd and / or usermod command is unavailable`) - } - } else if (osType === 'darwin') { - runCommand(`Creating the ${group} group`, `sudo dscl . create /Groups/${group}`) - runCommand(`Ensuring the ${group} group has a GID`, `bash -c 'if [[ "$(sudo dscl . read /Groups/$GROUP gid 2>&1)" == *"No such key"* ]]; then MAX_ID_GROUP="$(dscl . -list /Groups gid | awk "{print $2}" | sort -ug | tail -1)"; GROUP_ID="$((MAX_ID_GROUP+1))"; sudo dscl . create /Groups/${group} gid "$GROUP_ID"; fi'`) - runCommand(`Adding the ${group} user`, `sudo dscl . create /Users/${group}`) - runCommand(`Ensuring the ${group} user has a PrimaryGroupID`, `bash -c 'if [[ "$(sudo dscl . read /Users/${group} PrimaryGroupID 2>&1)" == *"No such key"* ]]; then sudo dscl . create /Users/${group} PrimaryGroupID 20; fi'`) - runCommand(`Ensuring the ${group} user has a UniqueID`, `bash -c 'if [[ "$(sudo dscl . read /Users/${group} UniqueID 2>&1)" == *"No such key"* ]]; then MAX_ID_USER="$(dscl . -list /Users UniqueID | sort -nr -k 2 | head -1 | grep -oE "[0-9]+$")"; USER_ID="$((MAX_ID_USER+1))"; sudo dscl . create /Users/${group} UniqueID "$USERID"; fi'`) - runCommand(`Adding the ${group} user to the ${group} group`, `sudo dseditgroup -o edit -t user -a ${group} ${group}`) - runCommand(`Adding the ${process.env.USER} user to the ${group} group`, `sudo dseditgroup -o edit -t user -a ${process.env.USER} ${group}`) - } else if (osType === 'windows') { - log('warn', logStage, `Windows support not yet added`) - } else { - log('warn', logStage, `Unknown operating system type`) - } + runCommand(`Creating the ${group} user / group`, `bash -c 'sudo add-user ${group}'`) } /** diff --git a/software.yml b/software.yml index 25073f9a..660e226a 100644 --- a/software.yml +++ b/software.yml @@ -6347,6 +6347,8 @@ softwarePackages: _github: https://github.com/netdata/netdata _home: https://www.netdata.cloud/ _name: Netdata + _groups: + - netdata _service: netdata _serviceEnabled: true _deps: