[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 #!/bin/sh 2 # postinst script for se3-ocs 3 # 4 # see: dh_installdeb(1) 5 6 set -e 7 8 # summary of how this script can be called: 9 # * <postinst> `configure' <most-recently-configured-version> 10 # * <old-postinst> `abort-upgrade' <new version> 11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package> 12 # <new-version> 13 # * <postinst> `abort-remove' 14 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' 15 # <failed-install-package> <version> `removing' 16 # <conflicting-package> <version> 17 # for details, see http://www.debian.org/doc/debian-policy/ or 18 # the debian-policy package 19 20 21 case "$1" in 22 install|configure) 23 24 25 26 ### on suppose que l'on est sous debian :D #### 27 WWWPATH="/var/www" 28 ## recuperation des variables necessaires pour interoger mysql ### 29 if [ -e $WWWPATH/se3/includes/config.inc.php ]; then 30 dbhost=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbhost=" | cut -d = -f2 | cut -d \" -f2` 31 dbname=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbname=" | cut -d = -f 2 |cut -d \" -f 2` 32 dbuser=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbuser=" | cut -d = -f 2 | cut -d \" -f 2` 33 dbpass=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbpass=" | cut -d = -f 2 | cut -d \" -f 2` 34 else 35 echo "Fichier de configuration inaccessible, le script ne peut se poursuivre." 36 exit 1 37 fi 38 39 test_exist=`echo "SELECT id FROM params WHERE name='inventaire'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N` 40 if [ "X$test_exist" = "X" ]; then # if empty 41 echo "INSERT INTO params VALUES ('', 'inventaire', '0', 0, 'Activation de l\'inventaire', 6)" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N 42 fi 43 44 45 # On teste si la base existe deja et si on a le mot de passe (version etch) 46 if [ -e $WWWPATH/se3/includes/dbconfig.inc.php ] 47 then 48 MAJ_OCS=1 49 fi 50 51 # Creation du mdp 52 mdp=`date|md5sum|cut -c 3-9` 53 54 55 ### recup pass root mysql 56 if [ ! -e /root/.my.cnf ]; then 57 echo "Lecture du pass root mysql impossible, /root/.my.cnf inexistant" 58 exit 1 59 fi 60 # password=$(cat /root/.my.cnf | grep password | cut -d= -f2) 61 62 # Si la base n'existe pas deja on la cree et la remplie 63 # Si elle existe on l'a met a jour 64 if [ -e /usr/share/ocsinventory-server/ocsreports/files/ocsbase.sql ]; then 65 mysql --force ocsweb < /usr/share/ocsinventory-server/ocsreports/files/ocsbase.sql 2>/dev/null 66 else 67 mysql --force < /var/cache/se3_install/ocsbase.sql 2>/dev/null 68 fi 69 70 mysql --force ocsweb < /var/cache/se3_install/ocsbase-se3.sql 2>/dev/null 71 72 73 74 # mysql -h localhost -u root -p$password --force < /var/cache/se3_install/ocsbase-se3.sql 2>/dev/null 75 76 mysql -e "GRANT ALL PRIVILEGES ON ocsweb.* TO ocs IDENTIFIED BY '$mdp'"; 77 mysql -e "GRANT ALL PRIVILEGES ON ocsweb.* TO ocs@localhost IDENTIFIED BY '$mdp'"; 78 79 # Creation de la conf 80 echo "<?php 81 \$_SESSION[\"SERVEUR_SQL\"]=\"localhost\"; 82 \$_SESSION[\"COMPTE_BASE\"]=\"ocs\"; 83 \$_SESSION[\"PSWD_BASE\"]=\"$mdp\"; 84 ?>" > /var/www/se3/includes/dbconfig.inc.php 85 86 # On supprime l'ancienne version si elle existe 87 if [ -e /etc/apache2se/conf.d/ocsinventory.conf ] 88 then 89 rm -f /etc/apache2se/conf.d/ocsinventory.conf 90 fi 91 92 ln -s /etc/ocsinventory/ocsinventory.conf /etc/apache2se/conf.d/ocsinventory.conf 93 94 if [ -e /etc/apache2/conf.d/ocsinventory.conf ] 95 then 96 rm -f /etc/apache2/conf.d/ocsinventory.conf 97 fi 98 99 perl -pi -e "s/.*OCS_DB_PWD.*/PerlSetVar OCS_DB_PWD $mdp/" /etc/ocsinventory/ocsinventory.conf 100 101 if [ -x /usr/share/se3/sbin/permse3 ] 102 then 103 /usr/share/se3/sbin/permse3 104 else 105 if [ -x /usr/share/se3/scripts/permse3 ] 106 then 107 /usr/share/se3/scripts/permse3 108 fi 109 fi 110 111 # Reloadind apache2se 112 /etc/init.d/apache2se reload 113 114 ;; 115 abort-upgrade|abort-remove|abort-deconfigure) 116 ;; 117 *) 118 echo "postinst called with unknown argument \`$1'" >&2 119 exit 1 120 ;; 121 esac 122 123 124 125 exit 0 126
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |