Skip to content

Commit

Permalink
Merge pull request #75 from luxflux/CtrlC-Root-master
Browse files Browse the repository at this point in the history
Ability to specify a `down` script, fixes #74
  • Loading branch information
luxflux committed May 25, 2014
2 parents c94ffe6 + 26f4f7c commit 4ddaee1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
# [*up*]
# String, Script which we want to run when openvpn server starts
#
# [*down*]
# String, Script which we want to run when openvpn server stops
#
# [*username_as_common_name*]
# Boolean. If true then set username-as-common-name
# Default: false
Expand Down Expand Up @@ -305,6 +308,7 @@
$management_ip = 'localhost',
$management_port = 7505,
$up = '',
$down = '',
$username_as_common_name = false,
$ldap_enabled = false,
$ldap_server = '',
Expand Down
7 changes: 7 additions & 0 deletions spec/defines/openvpn_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
'logfile' => '/var/log/openvpn/test_server.log',
'status_log' => '/var/log/openvpn/test_server_status.log',
'dev' => 'tun1',
'up' => '/tmp/up',
'down' => '/tmp/down',
'local' => '2.3.4.5',
'ipp' => true,
'server' => '2.3.4.0 255.255.0.0',
Expand Down Expand Up @@ -155,6 +157,11 @@
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^persist-key$/) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(/^persist-tun$/) }

it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^up "/tmp/up"$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^down "/tmp/down"$}) }
it { should contain_file('/etc/openvpn/test_server.conf').with_content(%r{^script-security 2$}) }


it { should contain_file('/etc/openvpn/test_server/easy-rsa/vars').with_content(/^export CA_EXPIRE=365$/) }
it { should contain_file('/etc/openvpn/test_server/easy-rsa/vars').with_content(/^export KEY_EXPIRE=365$/) }
it { should contain_file('/etc/openvpn/test_server/easy-rsa/vars').with_content(/^export KEY_CN="yolo"$/) }
Expand Down
9 changes: 7 additions & 2 deletions templates/server.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ plugin /usr/lib/openvpn/openvpn-auth-pam.so login
<% if scope.lookupvar('management') -%>
management <%= scope.lookupvar('management_ip') %> <%= scope.lookupvar('management_port') %>
<% end -%>
<% if scope.lookupvar('up') != ''-%>
<% if scope.lookupvar('up') != '' or scope.lookupvar('down') != ''-%>
script-security 2
up <%= scope.lookupvar('up') %>
<% end -%>
<% if scope.lookupvar('up') != '' -%>
up "<%= scope.lookupvar('up') %>"
<% end -%>
<% if scope.lookupvar('down') != '' -%>
down "<%= scope.lookupvar('down') %>"
<% end -%>
<% if scope.lookupvar('username_as_common_name') -%>
username-as-common-name
Expand Down

0 comments on commit 4ddaee1

Please sign in to comment.