[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/sbin/ -> restoreinvent.sh (source)

   1  #!/bin/bash
   2  
   3  
   4  
   5  
   6  #
   7  # Olivier Lécluse
   8  #
   9  # distribué sous licence GPL
  10  #
  11  ##### Permet de recréer l'inventaire en cas d'effacement accidentel ou en cas de problème... ##### 
  12  ##$Id: restoreinvent.sh 7744 2013-03-31 23:47:51Z keyser $##
  13  #
  14  
  15  if [ "$1" = "--help" -o "$1" = "-h" ]
  16  then
  17      echo "Permet de recréer l'inventaire en cas d'effacement accidentel ou en cas de problème... " 
  18      echo "Usage : aucune option"
  19      exit
  20  fi    
  21  
  22  # Création de la base inventaire et des comptes d'acces
  23  mysqladmin drop Inventory -f 2&> /dev/null
  24  mysqladmin create Inventory
  25  PASSOCS="5289992"
  26  ADMINPW="wawa"
  27  mysql -D mysql -e  "DELETE FROM user WHERE User = 'ocsro'"
  28  mysql -D mysql -e  "DELETE FROM user WHERE User = 'ocsadmin'"
  29  mysql -D mysql -e  "DELETE FROM db WHERE User = 'ocsro'"
  30  mysql -D mysql -e  "DELETE FROM db WHERE User = 'ocsadmin'"
  31  # On crée le user ocsadmin de la table mysql.db , mysql.user
  32  mysql -D mysql -e "INSERT INTO user (Host,User,Password,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv) VALUES ('localhost','ocsadmin',PASSWORD('$PASSOCS'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N')"
  33  mysql -D mysql -e  "INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv) VALUES ('localhost','Inventory','ocsadmin','Y','Y','Y','Y','Y','N','N','N','N','N')"
  34  
  35  # On crée le user ocsro de la table mysql.db , mysql.user et mysql.table_priv avec droit select et mdp admin LDAP
  36  mysql -D mysql -e "INSERT INTO user (Host,User,Password,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Reload_priv,Shutdown_priv,Process_priv,File_priv,Grant_priv,References_priv,Index_priv,Alter_priv) VALUES ('localhost','ocsro',PASSWORD('$ADMINPW'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N')"
  37  mysql -D mysql -e  "INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv) VALUES ('localhost','Inventory','ocsro','N','N','N','N','N','N','N','N','N','N')"
  38  mysql -D mysql -e "DELETE FROM  tables_priv where Host = 'localhost' AND Db= 'Inventory' AND User = 'ocsro' "
  39  for TBL in BIOS CONTROLLERS DRIVES HARDWARE INPUTS MEMORIES MODEMS MONITORS NETWORKS PORTS PRINTERS SLOTS SOUNDS STORAGES VIDEOS
  40  do
  41          mysql -D mysql -e "INSERT INTO tables_priv VALUES ('localhost', 'Inventory', 'ocsro', '$TBL', '', 20050331011228, 'Select', '')" 2&>/dev/null
  42      done
  43      mysqladmin reload
  44  
  45  # On crée le user ocsro de la table mysql.db , mysql.user et mysql.table_priv avec droit select et mdp admin LDAP
  46  for TBL in BIOS CONTROLLERS DRIVES HARDWARE INPUTS MEMORIES MODEMS MONITORS NETWORKS PORTS PRINTERS SLOTS SOUNDS STORAGES VIDEOS
  47  do
  48      mysql -D mysql -e "INSERT INTO tables_priv VALUES ('localhost', 'Inventory', 'ocsro', '$TBL', '', 20050331011228, 'Select', '')" 2&>/dev/null
  49  done
  50  mysqladmin reload
  51  
  52  # Remplissage de la base Inventory
  53  mysql Inventory < /var/cache/se3_install/ocs/Inventory.sql
  54  
  55  # Installation des scripts OCS
  56  rm -r /var/se3/Progs/rw/inventaire
  57  if [ ! -d /var/se3/Progs/rw/inventaire ]; then
  58      mkdir -p /var/se3/Progs/rw/inventaire
  59  fi
  60  tar -zxf /var/cache/se3_install/ocs/APPocs.tar.gz -C /var/se3/Progs/rw/inventaire
  61  cp /var/cache/se3_install/ocs/Config.csv /var/se3/Progs/rw/inventaire/Application
  62  cp /var/cache/se3_install/ocs/startocs.vbs /var/se3/Progs/ro
  63  chmod 755 /var/se3/Progs/ro/startocs.vbs
  64  chmod 666 /var/se3/Progs/rw/inventaire/Application/Config.csv
  65  # Patchage du fichier de conf inventaire
  66  cat /var/cache/se3_install/conf/conf_invent.inc.php.in | sed -e "s/#OCSADMPASS#/$PASSOCS/g" | sed -e "s/#OCSROPASS#/$ADMINPW/g" > /var/www/se3/inventaire/conf_invent.inc.php
  67  chown www-se3 /var/www/se3/inventaire/conf_invent.inc.php
  68  chmod 400 /var/www/se3/inventaire/conf_invent.inc.php
  69  
  70  cp /var/cache/se3_install/ocs/OCSInventory.bmp /var/se3/Progs/rw/inventaire/Application
  71  for EXTENSION in exe dll bmp
  72  do
  73          setfacl -m m::rx /var/se3/Progs/rw/inventaire/Application/*.$EXTENSION
  74  done


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1