hd-usb.service.example 875 B

12345678910111213141516171819202122232425262728293031
  1. [Unit]
  2. Description=Send usb drive to sleep and switch off the usb port
  3. #After=local-fs-pre.target ???
  4. # retry ten times, then give up:
  5. StartLimitBurst=10
  6. StartLimitIntervalSec=111
  7. [Service]
  8. # this identifies a specific usb port, see "lsusb -t" and /sys/bus/usb/devices/. Required
  9. Environment="node=X-X"
  10. # this name does not reflect the above USB node at all, but it's the same device. Required.
  11. Environment="hdparm_device=/dev/disk/by-id/asdasdXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  12. # default value, optional
  13. #Environment="restore_autosuspend=2000}"
  14. # default value, optional
  15. #Environment="restore_control=on}"
  16. # On success, end service
  17. Restart=on-failure
  18. # take 10s between restarts, max. 10 restarts (see [Unit] section)
  19. RestartSec=10
  20. ExecStart=/full/path/to/hd-usb.sh off
  21. [Install]
  22. # System Initialization
  23. WantedBy=sysinit.target
  24. # Basic System
  25. #WantedBy=basic.target