Skip to content

Commit

Permalink
Merge pull request #101 from kalehmann/feature/service-templates
Browse files Browse the repository at this point in the history
Added support for template service units
  • Loading branch information
Andrei-Pozolotin authored Oct 1, 2023
2 parents 0362aeb + a8912a9 commit 18ff3cd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/mkinitcpio-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 18ff3cd

Please sign in to comment.