Blame view

create_bridge.sh 811 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
17
  
  
  #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
  ip link add $NOM_BRIDGE type bridge
5721892d   hmalti   Avancées
18
19
  
  #attribution d'une adresse ip au bridge
3e470988   hmalti   First commit
20
  ip a add dev $NOM_BRIDGE $ADDR_IPV4
5721892d   hmalti   Avancées
21
22
  
  #demarrage du bridge
3e470988   hmalti   First commit
23
24
  ip link set $NOM_BRIDGE down
  ip link set $NOM_BRIDGE up
5721892d   hmalti   Avancées
25
26
27
  
  MANIFEST=$NOM_BRIDGE.manifest
  echo "nom_bridge:$NOM_BRIDGE" >> $MANIFEST #nom du bridge
3e470988   hmalti   First commit
28
29
  
  #condition de bordure pour le dossier Bridges
b1087939   hmalti   Ajout commandes
30
31
  if [[ ! -d "$PATH_MANIFEST/bridges" ]]; then 
    mkdir -p $PATH_MANIFEST/bridges #&& mv FILE $PATH_MANIFEST/bridges
3e470988   hmalti   First commit
32
  fi
5721892d   hmalti   Avancées
33
34
  
  mv $MANIFEST $PATH_MANIFEST/bridges