]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/scripts/convert-ovpn
backup: Convert backups with old CCD files.
[people/teissler/ipfire-2.x.git] / src / scripts / convert-ovpn
1 #!/usr/bin/perl
2
3 ###############################################################################
4 # #
5 # IPFire.org - A linux based firewall #
6 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
7 # #
8 # This program is free software: you can redistribute it and/or modify #
9 # it under the terms of the GNU General Public License as published by #
10 # the Free Software Foundation, either version 3 of the License, or #
11 # (at your option) any later version. #
12 # #
13 # This program is distributed in the hope that it will be useful, #
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16 # GNU General Public License for more details. #
17 # #
18 # You should have received a copy of the GNU General Public License #
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 # #
21 ###############################################################################
22 # #
23 # This script converts old openvpn ccd files with underscore #
24 # to files with spaces to make them working with openvpn 2.3 again #
25 # STEP1: read ovpnconfig and verify cert names #
26 # STEP2: if neccessary convert ccd file #
27 # #
28 ###############################################################################
29
30 my %configovpn=();
31 my $ccdpath="/var/ipfire/ovpn/ccd/";
32 my $ovpnconfig="/var/ipfire/ovpn/ovpnconfig";
33 require '/var/ipfire/general-functions.pl';
34
35 &General::readhasharray ($ovpnconfig,\%configovpn);
36
37 &check_config;
38
39
40 sub check_config
41 {
42 print "\n";
43 foreach my $key (sort keys %configovpn){
44 if ($configovpn{$key}[3] eq 'host' && $configovpn{$key}[2]=~" "){
45 my $ccdname=$configovpn{$key}[2];
46 $ccdname =~ tr/ /_/;
47 chdir($ccdpath);
48 rename($ccdname,$configovpn{$key}[2]);
49 }
50 }
51 }