diff options
Diffstat (limited to 'initify.pl')
-rw-r--r-- | initify.pl | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -1,6 +1,9 @@ +#!/usr/bin/perl # (c) goose121, 2017 # Released under the MIT license +use warnings; +#use strict; use v5.10.1; use feature "switch"; my $type = "simple"; @@ -8,6 +11,7 @@ my @cmds_start = (); my @cmds_stop = (); my $pidfile = ""; my $desc = ""; +(my $service=$ARGV[0])=~s/\.service//; while(<>) { #s/\s*|\s*$//g; # Trim whitespace @@ -38,7 +42,7 @@ while(<>) { } } if (m/^Description=(.*)/) { - $desc = $1 + $desc = $1 } } @@ -52,13 +56,17 @@ map {my @sep = split(/ /, $_, 2); push(@cmd_argl, $sep[1]); } @cmds_start; -print <<"EOF"; +open(FH, '>', "$service") || die("Cannot create $service: $!\n"); + +print FH <<"EOF"; \#!/sbin/openrc-run command=$cmd_path[0] command_args="$cmd_argl[0]" pidfile=$pidfile -name="(fill in)" +name="$service" description="$desc" EOF + +close FH; |