- create and install manpage
authorheiko
Thu, 13 Nov 2008 21:19:09 +0000
changeset 5 9e64828e7d70
parent 4 74ef29e9ab00
child 6 9ff263c701ef
- create and install manpage
Makefile
sap-vpn.pl
--- a/Makefile	Thu Nov 13 21:11:42 2008 +0000
+++ b/Makefile	Thu Nov 13 21:19:09 2008 +0000
@@ -3,23 +3,24 @@
 
 prefix = /usr/local
 bindir = ${prefix}/bin
+man1dir = ${prefix}/man/man1
 DESTDIR = 
 
+SCRIPT = sap-vpn
+MANPAGE = sap-vpn.1.gz
 
-SCRIPT = sap-vpn
-CLEANFILES = $(SCRIPT)
+CLEANFILES = $(SCRIPT) $(MANPAGE)
 
 .PHONLY:	clean install
 
-all:		$(SCRIPT)
-
-clean:		
-		rm -f $(CLEANFILES)
+all:		$(SCRIPT) $(MANPAGE)
+clean:		; rm -f $(CLEANFILES)
 
 install:	all
 		install -m 0755 -d $(DESTDIR)${bindir}/
-		install -m 04555 -o `id -un` $(SCRIPT) $(DESTDIR)${bindir}/
+		install -m 04555 $(SCRIPT) $(DESTDIR)${bindir}/
+		install -m 0755 -d $(DESTDIR)${man1dir}/
+		install -m 0644 $(MANPAGE) $(DESTDIR)${man1dir}/
 
-sap-vpn:	sap-vpn.pl
-		install -m 0555 $< $@
-
+%:		%.pl; install -m 0555 $< $@
+%.1.gz:		%.pl; pod2man $< | gzip >$@
--- a/sap-vpn.pl	Thu Nov 13 21:11:42 2008 +0000
+++ b/sap-vpn.pl	Thu Nov 13 21:19:09 2008 +0000
@@ -13,7 +13,7 @@
 use English qw(-no_match_vars);
 
 ($EUID, $UID) = ($UID, $EUID);    # release ROOT, doesn't harm, if not suid
-($0) = ($0 =~ /([\w-]+)/);        # untaint $0
+($0) = ($0 =~ /([\/\w-]+)/);      # untaint $0
 
 use constant ME => basename $0;
 
@@ -220,7 +220,7 @@
 
         }
         wait;
-	die ME . ": pppd didn't return sucessfully (rc: @{[$? >> 8]})\n" if $?;
+        die ME . ": pppd didn't return sucessfully (rc: @{[$? >> 8]})\n" if $?;
     }
 
     # now executing the script
@@ -241,7 +241,8 @@
                 $GID = $EGID = $group;
             }
 
-            verbose "% executing script $opt_script with uid $UID and gid $GID\n";
+            verbose
+              "% executing script $opt_script with uid $UID and gid $GID\n";
 
             exec $opt_script
               or die ME . ": Can't exec $opt_script: $!\n";
@@ -355,6 +356,11 @@
 
 =back
 
+=head1 VERSION and SOURCE
+
+    Id:	    $Id$
+    URL:    $URL$
+
 =cut
 
 ###