From 7c9f5446ec5960d4c328f1d2c6215eb68ef1e8a1 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Tue, 7 Nov 2023 07:22:34 +0000 Subject: [PATCH] Changed permissions applied by various services --- .../universal/run_onchange_after_28-privoxy.sh.tmpl | 2 +- .../universal/run_onchange_after_50-rclone.sh.tmpl | 6 +++--- .../universal/run_onchange_after_51-samba.sh.tmpl | 12 ++++++------ .../universal/run_onchange_after_57-netdata.sh.tmpl | 4 ++-- home/dot_local/bin/executable_rclone-mount | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/home/.chezmoiscripts/universal/run_onchange_after_28-privoxy.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_28-privoxy.sh.tmpl index 144b98df..fb45fb08 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_28-privoxy.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_28-privoxy.sh.tmpl @@ -43,7 +43,7 @@ if command -v privoxy > /dev/null; then if command -v add-user > /dev/null; then sudo add-user privoxy fi - sudo chown privoxy:privoxy "$PRIVOXY_CONFIG" + sudo chown privoxy:privoxy "$PRIVOXY_CONFIG" || sudo chown privoxy:$(id -g -n) "$PRIVOXY_CONFIG" # @description Restart Privoxy after configuration is applied if [ -d /Applications ] && [ -d /System ]; then diff --git a/home/.chezmoiscripts/universal/run_onchange_after_50-rclone.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_50-rclone.sh.tmpl index 9c4d87f4..8f33b982 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_50-rclone.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_50-rclone.sh.tmpl @@ -85,12 +85,12 @@ EOT if command -v add-user > /dev/null; then sudo add-user rclone fi - sudo chown -Rf rclone:rclone /var/cache/rclone + sudo chown -Rf rclone:rclone /var/cache/rclone || sudo chown -Rf rclone:$(id -g -n) /var/cache/rclone logg info 'Ensuring /var/log/rclone exists' sudo mkdir -p /var/log/rclone sudo chmod 770 /var/log/rclone - sudo chown -Rf rclone:rclone /var/log/rclone + sudo chown -Rf rclone:rclone /var/log/rclone || sudo chown -Rf rclone:$(id -g -n) /var/log/rclone logg info 'Adding ~/.local/bin/rclone-mount to /usr/local/bin' sudo cp -f "$HOME/.local/bin/rclone-mount" /usr/local/bin/rclone-mount @@ -117,7 +117,7 @@ EOT logg info "Ensuring /mnt/$SERVICE_ID is created with proper permissions" sudo mkdir -p "/mnt/$SERVICE_ID" sudo chmod 770 "/mnt/$SERVICE_ID" - sudo chown -Rf rclone:rclone "/mnt/$SERVICE_ID" + sudo chown -Rf rclone:rclone "/mnt/$SERVICE_ID" || sudo chown -Rf rclone:$(id -g -n) "/mnt/$SERVICE_ID" ### Enable / restart the service logg info "Enabling / restarting the $SERVICE_ID S3 service" diff --git a/home/.chezmoiscripts/universal/run_onchange_after_51-samba.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_51-samba.sh.tmpl index 7cc0304f..b6f27635 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_51-samba.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_51-samba.sh.tmpl @@ -76,17 +76,17 @@ if command -v smbd > /dev/null; then logg info "Ensuring $PRIVATE_SHARE is created" sudo mkdir -p "$PRIVATE_SHARE" sudo chmod 770 "$PRIVATE_SHARE" - sudo chown -Rf rclone:$(id -g -n) "$PRIVATE_SHARE" + sudo chown -Rf rclone:rclone "$PRIVATE_SHARE" || sudo chown -Rf rclone:$(id -g -n) "$PRIVATE_SHARE" logg info "Ensuring $PUBLIC_SHARE is created" sudo mkdir -p "$PUBLIC_SHARE" sudo chmod 775 "$PUBLIC_SHARE" - sudo chown -Rf rclone:$(id -g -n) "$PUBLIC_SHARE" + sudo chown -Rf rclone:rclone "$PUBLIC_SHARE" || sudo chown -Rf rclone:$(id -g -n) "$PUBLIC_SHARE" logg info "Ensuring $HOME/Public is created" mkdir -p "$HOME/Public" chmod 775 "$HOME/Public" - chown -Rf {{ .user.username }}:$(id -g -n) "$HOME/Public" + chown -Rf {{ .user.username }}:{{ .user.username }} "$HOME/Public" || chown -Rf {{ .user.username }}:$(id -g -n) "$HOME/Public" sudo sharing -a "$PRIVATE_SHARE" -S "Private (System)" -n "Private (System)" -g 000 -s 001 -E 1 -R 1 && logg success "Configured $PRIVATE_SHARE as a private Samba share" || logg info 'sharing command failed - it is likely that the share was already set up' sudo sharing -a "$PUBLIC_SHARE" -S "Public (System)" -n "Public (System)" -g 001 -s 001 -E 1 -R 0 && logg success "Configured $PUBLIC_SHARE as a public Samba share" || logg info 'sharing command failed - it is likely that the share was already set up' @@ -97,17 +97,17 @@ if command -v smbd > /dev/null; then logg info "Ensuring $PRIVATE_SHARE is created" sudo mkdir -p "$PRIVATE_SHARE" sudo chmod 770 "$PRIVATE_SHARE" - sudo chown -Rf rclone:rclone "$PRIVATE_SHARE" + sudo chown -Rf rclone:rclone "$PRIVATE_SHARE" || sudo chown -Rf rclone:$(id -g -n) "$PRIVATE_SHARE" logg info "Ensuring $PUBLIC_SHARE is created" sudo mkdir -p "$PUBLIC_SHARE" sudo chmod 775 "$PUBLIC_SHARE" - sudo chown -Rf rclone:rclone "$PUBLIC_SHARE" + sudo chown -Rf rclone:rclone "$PUBLIC_SHARE" || sudo chown -Rf rclone:$(id -g -n) "$PUBLIC_SHARE" logg info "Ensuring $HOME/Public is created" mkdir -p "$HOME/Public" chmod 775 "$HOME/Public" - chown -Rf {{ .user.username }}:rclone "$HOME/Public" + chown -Rf {{ .user.username }}:rclone "$HOME/Public" || chown -Rf {{ .user.username }}:$(id -g -n) "$HOME/Public" logg info "Copying Samba server configuration to /etc/samba/smb.conf" sudo cp -f "${XDG_CONFIG_HOME:-$HOME/.config}/samba/config" "/etc/samba/smb.conf" 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 17648d46..b6179959 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_57-netdata.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_57-netdata.sh.tmpl @@ -17,10 +17,10 @@ ensureNetdataOwnership() { ### Ensure /usr/local/var/lib/netdata/cloud.d is owned by user if [ -d /usr/local/var/lib/netdata ]; then logg info 'Ensuring permissions are correct on /usr/local/var/lib/netdata' - sudo chown -Rf netdata /usr/local/var/lib/netdata + sudo chown -Rf netdata:netdata /usr/local/var/lib/netdata || sudo chown -Rf netdata:$(id -g -n) /usr/local/var/lib/netdata elif [ -d /var/lib/netdata ]; then logg info 'Ensuring permissions are correct on /var/lib/netdata' - sudo chown -Rf netdata /var/lib/netdata + sudo chown -Rf netdata:netdata /var/lib/netdata || sudo chown -Rf netdata:$(id -g -n) /var/lib/netdata fi } diff --git a/home/dot_local/bin/executable_rclone-mount b/home/dot_local/bin/executable_rclone-mount index e7467165..30074f72 100644 --- a/home/dot_local/bin/executable_rclone-mount +++ b/home/dot_local/bin/executable_rclone-mount @@ -44,7 +44,7 @@ for FOLDER in "$CACHE_FOLDER" "$CONFIG_FOLDER" "$LOG_FOLDER" "$MOUNT_PATH"; do if [ ! -d "$FOLDER" ]; then sudo mkdir -p "$FOLDER" || echo "ERROR: Need permissions for $FOLDER" sudo chmod 755 "$FOLDER" - sudo chown -Rf rclone:rclone "$FOLDER" + sudo chown -Rf rclone:rclone "$FOLDER" || sudo chown -Rf rclone:$(id -g -n) "$FOLDER" fi done