-
-
Save Assassin9520/e5115db3f6d86277c4f49c705c27a968 to your computer and use it in GitHub Desktop.
Synology NAS - How to make a program run at startup
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
Synology NAS - How to make a program run at startup | |
Forked from https://gist.github.com/SanCoder-Q/f3755435e6e8bd46ba95bf0ec54ae1a4 | |
To make a startup service on DSM7.2 see below comment. | |
(TL;DR): | |
touch /etc/systemd/system/startup_service_mine.service | |
systemctl enable startup_service_mine.service | |
systemctl status startup_service_mine.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue:
When upgrading from DSM 6.2 -> DSM 7.2 on Synology NAS (DS2++), UPS USB not recognized anymore.
Handle/Solution:
Let's go:
1. Open ssh connection to Synology DS220j
Go to the control panel of your NAS and open telnet and ssh. Login into your NAS(enable also root and make sure to disable the rights after you finish the work for this operation)
2. Adding/Writing the service file
Create a file in /etc/systemd/system using the .service extension (e.g.: restart-UPSUSB_service_at_boot.service)
Body contents should be:
Also, you will want to keep the ownership like the original system services:
chmod 751 restart-UPSUSB_service_at_boot.service
.
After doing so, in order to stick this at start of NAS system:
systemctl enable restart-UPSUSB_service_at_boot.service
You will see that the symlink has been created.
.
Check the status anytime with:
systemctl status restart-UPSUSB_service_at_boot.service
3. Writing the systemctl sh service
You can see that our service is calling a shell script. -> restart-UPSUSB.sh
The body contents of .sh should be:
.
Let us loop this step by step:
-First and foremost, we want to hand the service from restarting the ups service until the BOOT process of NAS is succefully done and uninterrupted, by using
sleep 180
. (we wait 3 minutes to restart usb ups, interrupting NAS boot behaviour might not trigger our restart)-Second, we need to call synosystemctl with full abs path, otherwise systemctl is not recognizing the binary:
/usr/syno/bin/synosystemctl restart ups-usb
-also, make sure to change ownership of the sh script to admin (use
chown
).
4. Final Steps. Close ssh connection(keep yourself secure)
Now, that all is set, enable the service like in step2, close your ssh for your safety and restart the NAS.
After the normal boot, your should see in Control panel that NAS is connected succesfully.