Fixed group permissions

This commit is contained in:
Brian Zalewski 2023-11-27 06:11:08 +00:00
parent f4d955d349
commit d12de839b1
5 changed files with 11 additions and 28 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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}'`)
}
/**

View file

@ -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: