OpenVPN CLI in multi-user environment


I will add to this later. Assumes configurations stored in /etc/openvpn/username

#! /usr/bin/perl -w

my $configDirs = '/etc/openvpn';

my $user =  getlogin || getpwuid($<) || "";

my $destination = shift;
die "You must pass the name of the destination on the command line\n" unless $destination;
die "Could not locate configuration file in [$configDirs/$user/$destination]\n" 
   unless -d "$configDirs/$user/$destination";
chdir( "$configDirs/$user/$destination" );
if ( -f "$destination.ovpn" ) {
   exec( "openvpn $destination.ovpn");
} else {
   die "Could not open '$destination.ovpn' in directory '$configDirs/$destination'\n";
}
1;
Tags: cli, linux, multiuser, openvpn
Last update:
2015-03-06 00:50
Author:
Rod
Revision:
1.0
Average rating:0 (0 Votes)

You can comment this FAQ

Chuck Norris has counted to infinity. Twice.