35 lines
976 B
Bash
Executable File
35 lines
976 B
Bash
Executable File
#!/bin/bash
|
|
# Quick fix script to add current user to ZFS sudoers for development
|
|
# Usage: sudo ./fix-sudoers.sh
|
|
|
|
set -e
|
|
|
|
CURRENT_USER=$(whoami)
|
|
SUDOERS_FILE="/etc/sudoers.d/atlas-zfs"
|
|
|
|
echo "Adding $CURRENT_USER to ZFS sudoers for development..."
|
|
|
|
# Check if sudoers file exists
|
|
if [ ! -f "$SUDOERS_FILE" ]; then
|
|
echo "Creating sudoers file..."
|
|
cat > "$SUDOERS_FILE" <<EOF
|
|
# Allow ZFS commands without password for development
|
|
# This file is auto-generated - modify with caution
|
|
EOF
|
|
chmod 440 "$SUDOERS_FILE"
|
|
fi
|
|
|
|
# Check if user is already in the file
|
|
if grep -q "^$CURRENT_USER" "$SUDOERS_FILE"; then
|
|
echo "User $CURRENT_USER already has ZFS sudoers access"
|
|
exit 0
|
|
fi
|
|
|
|
# Add user to sudoers file
|
|
cat >> "$SUDOERS_FILE" <<EOF
|
|
$CURRENT_USER ALL=(ALL) NOPASSWD: /usr/sbin/zpool, /usr/bin/zpool, /sbin/zpool, /usr/sbin/zfs, /usr/bin/zfs, /sbin/zfs
|
|
EOF
|
|
|
|
echo "Added $CURRENT_USER to ZFS sudoers"
|
|
echo "You can now run atlas-api without sudo password prompts"
|