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