Blame view

create_bridge.sh 943 Bytes
3e470988   hmalti   First commit
1
  #!/bin/bash
5721892d   hmalti   Avancées
2
3
4
5
6
7
8
  while getopts b:a: o; do
      case $o in
          (b) NOM_BRIDGE=$OPTARG;;
          (a) ADDR_IPV4=$OPTARG;;
          
      esac
  done
3e470988   hmalti   First commit
9
10
11
12
13
14
15
16
  
  
  #condition sur le nbre d'arguments
  if [[ -z "$NOM_BRIDGE" ]]; then 
    echo "Il faut donner le nom du bridge ! Relancez la commande avec les bons arguments."
    exit
  fi
  #création du bridge
0e551703   hmalti   Corrections
17
  echo "Création du bridge $NOM_BRIDGE"
3e470988   hmalti   First commit
18
  ip link add $NOM_BRIDGE type bridge
5721892d   hmalti   Avancées
19
20
  
  #attribution d'une adresse ip au bridge
0e551703   hmalti   Corrections
21
  echo "Attribution de l'adresse ip $ADDR_IPV4 à $NOM_BRIDGE"
3e470988   hmalti   First commit
22
  ip a add dev $NOM_BRIDGE $ADDR_IPV4
5721892d   hmalti   Avancées
23
24
  
  #demarrage du bridge
0e551703   hmalti   Corrections
25
  echo "Demarrage de $NOM_BRIDGE"
3e470988   hmalti   First commit
26
27
  ip link set $NOM_BRIDGE down
  ip link set $NOM_BRIDGE up
5721892d   hmalti   Avancées
28
29
30
  
  MANIFEST=$NOM_BRIDGE.manifest
  echo "nom_bridge:$NOM_BRIDGE" >> $MANIFEST #nom du bridge
3e470988   hmalti   First commit
31
32
  
  #condition de bordure pour le dossier Bridges
b1087939   hmalti   Ajout commandes
33
34
  if [[ ! -d "$PATH_MANIFEST/bridges" ]]; then 
    mkdir -p $PATH_MANIFEST/bridges #&& mv FILE $PATH_MANIFEST/bridges
3e470988   hmalti   First commit
35
  fi
5721892d   hmalti   Avancées
36
37
  
  mv $MANIFEST $PATH_MANIFEST/bridges