Created
February 20, 2024 01:35
-
-
Save diogoalexsmachado/4b71accfb3c6359a6dd5b905c5013343 to your computer and use it in GitHub Desktop.
Startup Script for WD Home NAS + Docker compose start
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
#!/bin/bash | |
# Wait for LAN to be available | |
while ! ping -c 1 192.168.0.1 >/dev/null; do | |
sleep 1 | |
done | |
# Change directory | |
cd Desktop/docker_radarr/ | |
# Stop docker-compose services | |
docker-compose stop | |
# Unmount the network drive | |
sudo umount /mnt/wdcloud | |
# Mount the network drive | |
sudo mount -t cifs -o username=USERNAME,password=PASSWORD,vers=3,uid=1000,gid=1000 //192.168.0.123/diogomachado /mnt/wdcloud | |
# Start docker-compose services | |
docker-compose start | |
How to add to startup (Debian based OS's, using systemd):
- Create a systemd service unit file:
sudo nano /etc/systemd/system/startup_script.service
- Add the following content to the file:
[Unit]
Description=Startup Script
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=/path/to/your/script/startup_script.sh
[Install]
WantedBy=default.target
-
Replace /path/to/your/script/startup_script.sh with the actual path to your script.
-
Save the file by pressing Ctrl + X, then Y, and finally Enter to confirm.
-
Reload systemd to read the new unit file:
sudo systemctl daemon-reload
- Enable the service to run at startup:
sudo systemctl enable startup_script.service
- Reboot your system to apply the changes:
sudo reboot
Note: do not forget to make startup_script.sh executable:
chmod+x startup_script.sh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to add to startup (Debian based OS's, using rc.local):
Replace /path/to/your/script/startup_script.sh with the actual path to your script.
Save the file by pressing Ctrl + X, then Y, and finally Enter to confirm.
Make sure the rc.local file is executable: