Realisations/2006-2007/Projet/IpsecImplementation: ipsec_client.sh

File ipsec_client.sh, 1.8 KB (added by alladoum, 18 years ago)

Script de lancement du flux IPSec

Line 
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
23EXEC_SETKEY="/sbin/setkey"
24EXEC_RACOON="/usr/local/sbin/racoon"
25
26## fichiers conf.
27CONF_PSK="/root/ipsec_client1/psk.txt"
28CONF_RACOON="/root/ipsec_client1/racoon.conf"
29CONF_IPSEC="/root/ipsec_client1/ipsec.conf"
30
31## fichiers log.
32LOG_RACOON="/var/log/racoon.log"
33
34## fichiers PID
35PID_RACOON="/root/ipsec_client1/racoon.pid"
36
37#### Lancement du script ####
38kill -9 $(ps aux | grep racoon | grep -v grep | awk '{print $2}')
39rm -rf $(cat $PID_RACOON)
40$EXEC_SETKEY -F
41
42echo 'Etablissement des droits de '$CONF_PSK
43chmod 600 $CONF_PSK
44chown root:wheel $CONF_PSK
45
46echo -n 'Lancement de Racoon'
47if $EXEC_RACOON -l $LOG_RACOON -f $CONF_RACOON ; then
48    echo '[Succes]'
49else
50    echo '[Echec]'
51    exit 1
52fi
53
54echo -n 'Lancement de SetKey'
55if $EXEC_SETKEY -f $CONF_IPSEC ; then   
56    echo '[Succes]'
57else
58    echo '[Echec]'
59    exit 2
60fi
61
62echo 'Flux IPSec etabli'
63
64exit 0