Blame view

baleine.sh 1.63 KB
3e470988   hmalti   First commit
1
2
3
4
5
6
7
8
9
  
  #!/bin/bash
  
  #Ce code est le point d'entrée de l'application, c'est lui qui est apellé quand on écrit ./balaine container create
  
  #Ici on fait un switch par rapport à la valeur de $1 (le premier argument) selon qu'il vaille container, network ou image on apelle un autre
  #script qui va traiter ces cas, on garde les fichiers courts mais simples
  
  
b1087939   hmalti   Ajout commandes
10
11
12
  export PATH_BALEINE="/var/lib/baleine"
  export PATH_MANIFEST="$PATH_BALEINE/manifest"
  
3e470988   hmalti   First commit
13
14
15
16
17
18
19
  
  if [ $# -lt 1 ]; then
      printf "Baleine est un outil simple de gestion de conteneur.\n"
      printf "Utilisation: \n \n"
      printf "\t \t baleine <commande> [arguments]\n"
      printf "Les commandes sont :\n \n"
      printf "\t \t %-10s %-10s \n" "container"  "Lance ou stoppe un contenneur."
b1087939   hmalti   Ajout commandes
20
      printf "\t \t %-10s %-10s \n" "bridge" "Créée ou supprime des commutateurs linux virtuels."
3e470988   hmalti   First commit
21
22
23
24
25
26
27
28
29
      printf "\t \t %-10s %-10s \n \n" "image" "Créer ou supprime des images de contenneurs."
      printf "Utilisez baleine <commande> help pour plus d'informations à propos d'une commande.\n"
  fi
  
  case "$1" in
      "container")
          #Si on a apelé ./baleine.sh container create par exemple, on va apeller le script container.sh qui va traiter les
          #opérations sur les containers, et $@ permet de lui passer tous les arguments qu'on a passé à baleine.sh
          #autrement dit, ./baleine.sh container create apellera le script container.sh avec les arguments $1=container et $2=create
5721892d   hmalti   Avancées
30
          bash container.sh "${@:2}"
3e470988   hmalti   First commit
31
      ;;
3e470988   hmalti   First commit
32
      "image")
5161dfdb   hmalti   Améliorations scr...
33
          bash image.sh "${@:2}"
3e470988   hmalti   First commit
34
35
      ;;
      "bridge")
5721892d   hmalti   Avancées
36
          bash bridge.sh "${@:2}"
3e470988   hmalti   First commit
37
38
      ;;
       "help")
5721892d   hmalti   Avancées
39
          bash help.sh
3e470988   hmalti   First commit
40
      ;;
b1087939   hmalti   Ajout commandes
41
      "test")
5721892d   hmalti   Avancées
42
          bash test.sh "${@:2}"
b1087939   hmalti   Ajout commandes
43
      ;;
3e470988   hmalti   First commit
44
  esac