Fix paths for john user: dynamic INSTALL_DIR, correct user permissions

This commit is contained in:
Claw - AI Now Inc 2026-03-01 11:09:04 -08:00
parent b5343b3148
commit 14c03e47e7

View File

@ -18,8 +18,8 @@ NC='\033[0m' # No Color
# Configuration # Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="/home/pi/voice-assistant" INSTALL_DIR="$(dirname "$(readlink -f "$0")")"
MUSIC_DIR="/home/pi/Music" MUSIC_DIR="$(dirname "$(readlink -f "$0")")/Music"
LOG_FILE="/var/log/voice-assistant-install.log" LOG_FILE="/var/log/voice-assistant-install.log"
PYTHON_VERSION="3.9" PYTHON_VERSION="3.9"
@ -166,7 +166,7 @@ create_music_dir() {
fi fi
# Set permissions # Set permissions
chown pi:pi "$MUSIC_DIR" chown $(whoami):$(whoami) "$MUSIC_DIR"
chmod 755 "$MUSIC_DIR" chmod 755 "$MUSIC_DIR"
} }
@ -201,13 +201,13 @@ After=network.target sound.target
[Service] [Service]
Type=simple Type=simple
User=pi User=$(whoami)
WorkingDirectory=$INSTALL_DIR WorkingDirectory=$INSTALL_DIR
ExecStart=$INSTALL_DIR/venv/bin/python3 $INSTALL_DIR/main.py --mode run ExecStart=$INSTALL_DIR/venv/bin/python3 $INSTALL_DIR/main.py --mode run
Restart=always Restart=always
RestartSec=10 RestartSec=10
Environment=PYTHONUNBUFFERED=1 Environment=PYTHONUNBUFFERED=1
Environment=GOOGLE_APPLICATION_CREDENTIALS=/home/pi/.credentials/google-credentials.json Environment=GOOGLE_APPLICATION_CREDENTIALS=/home/john/.credentials/google-credentials.json
# Logging # Logging
StandardOutput=journal StandardOutput=journal
@ -283,7 +283,7 @@ You can organize music by:
- "Volume up/down" / "音量 大/小" - "Volume up/down" / "音量 大/小"
EOF EOF
chown -R pi:pi "$MUSIC_DIR" chown -R $(whoami):$(whoami) "$MUSIC_DIR"
log_success "Sample music structure created" log_success "Sample music structure created"
} }
@ -306,7 +306,7 @@ python3 main.py --mode run
EOF EOF
chmod +x "$INSTALL_DIR/start.sh" chmod +x "$INSTALL_DIR/start.sh"
chown pi:pi "$INSTALL_DIR/start.sh" chown $(whoami):$(whoami) "$INSTALL_DIR/start.sh"
log_success "Startup script created" log_success "Startup script created"
} }
@ -327,10 +327,10 @@ sudo systemctl disable voice-assistant
sudo rm /etc/systemd/system/voice-assistant.service sudo rm /etc/systemd/system/voice-assistant.service
# Remove installation # Remove installation
sudo rm -rf /home/pi/voice-assistant sudo rm -rf /home/john/voice-assistant
# Remove music directory (optional) # Remove music directory (optional)
# sudo rm -rf /home/pi/Music # sudo rm -rf $(dirname "$(readlink -f "$0")")/Music
echo "Uninstall complete!" echo "Uninstall complete!"
EOF EOF
@ -351,7 +351,7 @@ final_configuration() {
fi fi
# Set permissions # Set permissions
chown -R pi:pi "$INSTALL_DIR" chown -R $(whoami):$(whoami) "$INSTALL_DIR"
chmod -R 755 "$INSTALL_DIR" chmod -R 755 "$INSTALL_DIR"
log_success "Final configuration complete" log_success "Final configuration complete"