-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from kalehmann/feature/service-templates
Added support for template service units
- Loading branch information
Showing
1 changed file
with
8 additions
and
4 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 |
---|---|---|
|
@@ -145,13 +145,17 @@ add_systemd_unit_X() { | |
# and other unit files will be discovered and added. | ||
# $1: service unit candidate: either symlink to a unit or a real unit file | ||
|
||
local unit_task="" unit_name="" unit_path="" unit_target="" | ||
local unit_task="" unit_name="" unit_path="" unit_target="" symlink_name="" | ||
|
||
# absolute path to the unit candidate | ||
unit_task="$1" | ||
|
||
# simple service unit name | ||
unit_name=$(basename "$unit_task") | ||
# Extract the basename of the symlink. This may be an instanciated service | ||
# with an argument, e.g. [email protected]. | ||
symlink_name=$(basename "$unit_task") | ||
# Extract the name of the service template, e.g. [email protected] | ||
# becomes [email protected]. | ||
unit_name=$(sed 's/@.\+\./@\./g' <<< "$symlink_name") | ||
|
||
quiet "processing systemd unit $unit_name" | ||
|
||
|
@@ -359,7 +363,7 @@ add_systemd_unit_X() { | |
# this_unit/[Install]/WantedBy= other_unit -> enable -> /other.unit.wants/ this_unit | ||
# this_unit/[Install]/RequiredBy=other_unit -> enable -> /other.unit.requires/this_unit | ||
local unit_reverse="" | ||
for unit_reverse in {/etc,/usr/lib}/systemd/system/*{.wants,.requires}/"$unit_name" ; do | ||
for unit_reverse in {/etc,/usr/lib}/systemd/system/*{.wants,.requires}/"$symlink_name" ; do | ||
if [[ -L "$unit_reverse" ]] ; then | ||
add_symlink "$unit_reverse" | ||
fi | ||
|