1 | #!/bin/sh |
---|
2 | # $File: /home/chris/PRes/Postes_Rackables/ipsec_client1/ipsec_client.sh $ |
---|
3 | # $MD5: 66b54fe2372ec1bc50f1cb698a9614b1 $ |
---|
4 | # $By Christophe Alladoum <christophe[dot]alladoum[at]gmail[dot]com>$ |
---|
5 | # $Last-Modified: Fri Apr 20 19:49:55 2007$ |
---|
6 | |
---|
7 | # This program is free software; you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation; either version 2 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | |
---|
12 | # This program is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with this program; if not, write to the Free Software |
---|
19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
20 | |
---|
21 | # Variables |
---|
22 | ## executables |
---|
23 | EXEC_SETKEY="/sbin/setkey" |
---|
24 | EXEC_RACOON="/usr/local/sbin/racoon" |
---|
25 | |
---|
26 | ## fichiers conf. |
---|
27 | CONF_PSK="/root/ipsec_client1/psk.txt" |
---|
28 | CONF_RACOON="/root/ipsec_client1/racoon.conf" |
---|
29 | CONF_IPSEC="/root/ipsec_client1/ipsec.conf" |
---|
30 | |
---|
31 | ## fichiers log. |
---|
32 | LOG_RACOON="/var/log/racoon.log" |
---|
33 | |
---|
34 | ## fichiers PID |
---|
35 | PID_RACOON="/root/ipsec_client1/racoon.pid" |
---|
36 | |
---|
37 | #### Lancement du script #### |
---|
38 | kill -9 $(ps aux | grep racoon | grep -v grep | awk '{print $2}') |
---|
39 | rm -rf $(cat $PID_RACOON) |
---|
40 | $EXEC_SETKEY -F |
---|
41 | |
---|
42 | echo 'Etablissement des droits de '$CONF_PSK |
---|
43 | chmod 600 $CONF_PSK |
---|
44 | chown root:wheel $CONF_PSK |
---|
45 | |
---|
46 | echo -n 'Lancement de Racoon' |
---|
47 | if $EXEC_RACOON -l $LOG_RACOON -f $CONF_RACOON ; then |
---|
48 | echo '[Succes]' |
---|
49 | else |
---|
50 | echo '[Echec]' |
---|
51 | exit 1 |
---|
52 | fi |
---|
53 | |
---|
54 | echo -n 'Lancement de SetKey' |
---|
55 | if $EXEC_SETKEY -f $CONF_IPSEC ; then |
---|
56 | echo '[Succes]' |
---|
57 | else |
---|
58 | echo '[Echec]' |
---|
59 | exit 2 |
---|
60 | fi |
---|
61 | |
---|
62 | echo 'Flux IPSec etabli' |
---|
63 | |
---|
64 | exit 0 |
---|