I use these kinds of things all the time when creating services, timers, and mountpoints so I should keep them in the repo.master
@@ -0,0 +1,29 @@ | |||
[Unit] | |||
Description=Automount and Unmount a Filesystem | |||
After=network-online.target | |||
Wants=network-online.target | |||
[Automount] | |||
# Takes an absolute path of a directory of the | |||
# automount point. If the automount point does | |||
# not exist at time that the automount point is | |||
# installed, it is created. This string must be | |||
# reflected in the unit filename. | |||
Where=/mount | |||
# Directories of automount points (and any parent | |||
# directories) are automatically created if needed. | |||
# This option specifies the file system access mode | |||
# used when creating these directories. Takes an | |||
# access mode in octal notation. | |||
#DirectoryMode=0755 | |||
# Configures an idle timeout. Once the mount has | |||
# been idle for the specified time, systemd will | |||
# attempt to unmount. Takes a unit-less value in | |||
# seconds, or a time span value such as "5min 20s". | |||
# Pass 0 to disable the timeout logic. | |||
#TimeoutIdleSec=0 | |||
[Install] | |||
WantedBy=multi-user.target |
@@ -0,0 +1,71 @@ | |||
[Unit] | |||
Description=Mount a Filesystem Mount Point | |||
[Mount] | |||
# Takes an absolute path of a device node, | |||
# file or other resource to mount. See mount(8) | |||
# for details. If this refers to a device node, | |||
# a dependency on the respective device unit | |||
# is automatically created. (See | |||
# systemd.device(5) for more information.) | |||
# This option is mandatory. Note that the usual | |||
# specifier expansion is applied to this setting, | |||
# literal percent characters should hence be | |||
# written as "%%". | |||
What=/dev/sdx | |||
# Takes an absolute path of a directory for the | |||
# mount point; in particular, the destination | |||
# cannot be a symbolic link. If the mount point | |||
# does not exist at the time of mounting, it is | |||
# created. This string must be reflected in the | |||
# unit filename. | |||
Where=/mount | |||
# Takes a string for the file system type. | |||
# Type=btrfs | |||
# Mount options to use when mounting. This takes | |||
# a comma-separated list of options. This setting | |||
# is optional. Note that the usual specifier | |||
# expansion is applied to this setting, literal | |||
# percent characters should hence be written as "%%". | |||
#Options= | |||
# If true, parsing of the options specified in | |||
# Options= is relaxed, and unknown mount | |||
# options are tolerated. | |||
#SloppyOptions=false | |||
# If true, detach the filesystem from the | |||
# filesystem hierarchy at time of the unmount | |||
# operation, and clean up all references to the | |||
# filesystem as soon as they are not busy anymore. | |||
# This corresponds with umount(8)'s -l switch. | |||
#LazyUnmount=false | |||
# If true, force an unmount (in case of an | |||
# unreachable NFS system). This corresponds with | |||
# umount(8)'s -f switch. | |||
#ForceUnmount=false | |||
# Directories of mount points (and any parent | |||
# directories) are automatically created if needed. | |||
# This option specifies the file system access mode | |||
# used when creating these directories. Takes an | |||
# access mode in octal notation. | |||
#DirectoryMode=0755 | |||
# Configures the time to wait for the mount command | |||
# to finish. If a command does not exit within the | |||
# configured time, the mount will be considered failed | |||
# and be shut down again. All commands still running | |||
# will be terminated forcibly via SIGTERM, and after | |||
# another delay of this time with SIGKILL. (See | |||
# KillMode= in systemd.kill(5).) Takes a unit-less | |||
# value in seconds, or a time span value such as | |||
# "5min 20s". Pass 0 to disable the timeout logic. | |||
#TimeoutSec=20s | |||
[Install] | |||
WantedBy=multi-user.target |
@@ -0,0 +1,13 @@ | |||
[Unit] | |||
Description=Start Unit When Path Exists | |||
[Path] | |||
PathExists=/path/to/watch | |||
#PathExistsGlob= | |||
#PathChanged= | |||
#PathModified= | |||
#DirectoryNotEmpty= | |||
Unit=service_to_start.service | |||
[Install] | |||
WantedBy=paths.target |
@@ -0,0 +1,16 @@ | |||
[Unit] | |||
Description=Service Description | |||
ConditionPathExists=/path/that/must/exist/to/run/service | |||
[Service] | |||
Type=Simple | |||
ExecStartPre=/absolute/path/to/executable --before --ExecStart | |||
ExecStart=/absolute/path/to/executable --arg1 | |||
ExecStartPost=/absolute/path/to/executable --after --ExecStart | |||
ExecReload=/absolute/path/to/config_test | |||
ExecReload=/absolute/path/to/executable --reload | |||
Restart=always | |||
RestartSec=30s | |||
[Install] | |||
WantedBy=multi-user.target |
@@ -0,0 +1,39 @@ | |||
[Unit] | |||
Description=Run A Service on a Timer | |||
[Timer] | |||
#OnActiveSec= | |||
OnBootSec=5m | |||
#OnStartupSec= | |||
OnUnitActiveSec=1h | |||
#OnUnitInactiveSec= | |||
# OnCalendar Valid Time Specs | |||
# https://www.freedesktop.org/software/systemd/man/systemd.time.html# | |||
#OnCalendar= | |||
# Delay the timer by a randomly selected, evenly distributed | |||
# amount of time between 0 and the specified time value. | |||
#RandomizedDelaySec= | |||
Unit=service_to_start.service | |||
# If true, the time when the service unit was last triggered | |||
# is stored on disk. When the timer is activated, the service | |||
# unit is triggered immediately if it would have been | |||
# triggered at least once during the time when the timer was | |||
# inactive. This is useful to catch up on missed runs of the | |||
# service when the machine was off. Note that this setting only | |||
# has an effect on timers configured with OnCalendar=. | |||
#Persistent=false | |||
# If true, an elapsing timer will cause the system to resume | |||
# from suspend, should it be suspended and if the system | |||
# supports this. Note that this option will only make sure the | |||
# system resumes on the appropriate times, it will not take | |||
# care of suspending it again after any work that is to be | |||
# done is finished. | |||
#WakeSystem=false | |||
[Install] | |||
WantedBy=timers.target |