Update set-permissions.sh

This commit is contained in:
SpudGunMan
2025-11-06 20:41:50 -08:00
parent 2fe1196a90
commit d1d5d6ba30

View File

@@ -10,15 +10,17 @@ fi
# Use first argument as user, or default to meshbot
TARGET_USER="${1:-meshbot}"
echo "DEBUG: TARGET_USER='$TARGET_USER'"
id "$TARGET_USER"
# Check if user exists
if ! id "$TARGET_USER" &>/dev/null; then
if ! id "$TARGET_USER" >/dev/null 2>&1; then
echo "User '$TARGET_USER' does not exist."
read -p "Would you like to use the current user ($(logname)) instead? [y/N]: " yn
if [[ "$yn" =~ ^[Yy]$ ]]; then
TARGET_USER="$(logname)"
CUR_USER="$(whoami)"
printf "Would you like to use the current user (%s) instead? [y/N]: " "$CUR_USER"
read yn
if [ "$yn" = "y" ] || [ "$yn" = "Y" ]; then
TARGET_USER="$CUR_USER"
echo "Using current user: $TARGET_USER"
if ! id "$TARGET_USER" &>/dev/null; then
if ! id "$TARGET_USER" >/dev/null 2>&1; then
echo "Current user '$TARGET_USER' does not exist or cannot be determined."
exit 1
fi
@@ -28,6 +30,8 @@ if ! id "$TARGET_USER" &>/dev/null; then
fi
fi
id "$TARGET_USER"
echo "Setting ownership to $TARGET_USER:$TARGET_USER"
for dir in "/opt/meshing-around" "/opt/meshing-around/logs" "/opt/meshing-around/data"; do