Changed permissions applied by various services

This commit is contained in:
Brian Zalewski 2023-11-07 07:22:34 +00:00
parent 651ef0341a
commit 7c9f5446ec
5 changed files with 13 additions and 13 deletions

View file

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

View file

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

View file

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

View file

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

View file

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