-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts to create and enable systemd service files
- Loading branch information
1 parent
3394d28
commit fbf6928
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Get the current working directory | ||
CURRENT_DIR="$(pwd)" | ||
|
||
# Define the service file content | ||
SERVICE_CONTENT="[Unit] | ||
Description=Go Music Player Service | ||
After=network.target | ||
[Service] | ||
ExecStart=$CURRENT_DIR/player/go_player | ||
WorkingDirectory=$CURRENT_DIR/player | ||
User=melvin | ||
Group=melvin | ||
Restart=always | ||
[Install] | ||
WantedBy=multi-user.target" | ||
|
||
# Specify the path for the service file | ||
SERVICE_FILE_PATH="/etc/systemd/system/go_music_player.service" | ||
|
||
# Print the service content to the file | ||
echo "$SERVICE_CONTENT" | sudo tee "$SERVICE_FILE_PATH" > /dev/null | ||
|
||
# Inform the user that the file has been created | ||
echo "Service file created at $SERVICE_FILE_PATH" | ||
|
||
# Reload systemd to pick up the new service file | ||
sudo systemctl daemon-reload | ||
|
||
# Enable and start the service | ||
sudo systemctl enable go_music_player.service | ||
sudo systemctl start go_music_player.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Get the current working directory | ||
CURRENT_DIR="$(pwd)" | ||
|
||
# Define the service file content | ||
SERVICE_CONTENT="[Unit] | ||
Description=Yoda RFID Reader | ||
After=network.target go-music-player.service | ||
Wants=go-music-player.service | ||
[Service] | ||
ExecStart=$CURRENT_DIR/.venv/bin/python $CURRENT_DIR/reader/read.py | ||
WorkingDirectory=$CURRENT_DIR/reader/ | ||
User=melvin | ||
Group=melvin | ||
Restart=always | ||
[Install] | ||
WantedBy=multi-user.target" | ||
|
||
# Specify the path for the service file | ||
SERVICE_FILE_PATH="/etc/systemd/system/yoda_rfid_reader.service" | ||
|
||
# Print the service content to the file | ||
echo "$SERVICE_CONTENT" | sudo tee "$SERVICE_FILE_PATH" > /dev/null | ||
|
||
# Inform the user that the file has been created | ||
echo "Service file created at $SERVICE_FILE_PATH" | ||
|
||
# Reload systemd to pick up the new service file | ||
sudo systemctl daemon-reload | ||
|
||
# Enable and start the service | ||
sudo systemctl enable yoda_rfid_reader.service | ||
sudo systemctl start yoda_rfid_reader.service |