diff --git a/install_service.sh b/install_service.sh index 100a4e6..3bf609f 100644 --- a/install_service.sh +++ b/install_service.sh @@ -67,14 +67,18 @@ echo "" # Update the service file with the correct path echo "Configuring service file..." TEMP_SERVICE="/tmp/wedding-phone.service" -cat "$SERVICE_FILE" | sed "s|/home/pi/wedding-phone|$SCRIPT_DIR|g" > "$TEMP_SERVICE" - -# Update User in service file CURRENT_USER=$(whoami) -sed -i "s|User=pi|User=$CURRENT_USER|g" "$TEMP_SERVICE" -sed -i "s|Group=pi|Group=$CURRENT_USER|g" "$TEMP_SERVICE" +USER_HOME=$(eval echo ~$CURRENT_USER) + +cat "$SERVICE_FILE" | \ + sed "s|User=berwn|User=$CURRENT_USER|g" | \ + sed "s|Group=berwn|Group=$CURRENT_USER|g" | \ + sed "s|/home/berwn/wedding-phone|$SCRIPT_DIR|g" | \ + sed "s|/home/berwn/.local/bin|$USER_HOME/.local/bin|g" \ + > "$TEMP_SERVICE" echo -e "${GREEN}✓ Service file configured for user: $CURRENT_USER${NC}" +echo -e "${GREEN}✓ Working directory: $SCRIPT_DIR${NC}" echo "" # Install the service diff --git a/wedding-phone.service b/wedding-phone.service index 879e009..492b1b0 100644 --- a/wedding-phone.service +++ b/wedding-phone.service @@ -5,11 +5,11 @@ Wants=network.target sound.target [Service] Type=simple -User=pi -Group=pi -WorkingDirectory=/home/pi/wedding-phone -Environment="PATH=/home/pi/.local/bin:/usr/local/bin:/usr/bin:/bin" -ExecStart=/usr/bin/make start +User=berwn +Group=berwn +WorkingDirectory=/home/berwn/wedding-phone +Environment="PATH=/home/berwn/.local/bin:/usr/local/bin:/usr/bin:/bin" +ExecStart=/usr/bin/python3 rotary_phone_web.py Restart=always RestartSec=10