summaryrefslogtreecommitdiff
path: root/pcr/initify/trim_path_from_service_name.patch
blob: f1aef74bda5963b302f0992e45fa2c27e015004e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/initify.pl b/initify.pl
index 7cec3d2..3d8b1bd 100755
--- a/initify.pl
+++ b/initify.pl
@@ -14,7 +14,8 @@ my @cmds_start = ();
 my @cmds_stop = ();
 my $pidfile = "";
 my $desc = "";
-(my $service=$ARGV[0])=~s/\.service//;
+(my $service  = $ARGV[0]) =~ s/\.service//;
+(my $svc_name = $ARGV[0]) =~ s|(.*/)?([^/.]*)\.service|$2|;
 
 my %opt;
 GetOptions(\%opt,
@@ -23,7 +24,7 @@ GetOptions(\%opt,
 
 pod2usage() if ($opt{help});
 
-$service = $opt{name} if (length $opt{name});
+$svc_name = $opt{name} if (length $opt{name});
 
 while(<>) {
     #s/\s*|\s*$//g; # Trim whitespace
@@ -77,7 +78,7 @@ command=$cmd_path[0]
 command_args="$cmd_argl[0]"
 pidfile=$pidfile
 
-name="$service"
+name="$svc_name"
 description="$desc"
 EOF