Subversion Repositories se3

Compare Revisions

Ignore whitespace Rev 6623 → Rev 6624

/branches/2.1/se3-clonage/sources/debian/postinst
21,27 → 21,16
case "$1" in
install|configure)
 
. /usr/share/se3/includes/config.inc.sh -lmd
 
mysqlrequest="mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N"
 
### on suppose que l'on est sous debian ####
WWWPATH="/var/www"
## recuperation des variables necessaires pour interoger mysql ###
if [ -e $WWWPATH/se3/includes/config.inc.php ]; then
dbhost=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbhost=" | cut -d = -f2 | cut -d \" -f2`
dbname=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbname=" | cut -d = -f 2 |cut -d \" -f 2`
dbuser=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbuser=" | cut -d = -f 2 | cut -d \" -f 2`
dbpass=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbpass=" | cut -d = -f 2 | cut -d \" -f 2`
else
echo "Fichier de configuration inaccessible, le script ne peut se poursuivre."
exit 1
fi
test_exist=`echo "SELECT value FROM params WHERE name='clonage'" | $mysqlrequest`
if [ "X$test_exist" = "X" ]; then # if empty
echo "INSERT INTO params VALUES ('', 'clonage', '0', 0, 'Activation du serveur de boot pxe - udpcast / unattented', 6)" |$mysqlrequest
fi
 
test_exist=`echo "SELECT value FROM params WHERE name='clonage'" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N`
if [ "X$test_exist" = "X" ]; then # if empty
echo "INSERT INTO params VALUES ('', 'clonage', '0', 0, 'Activation du serveur de boot pxe - udpcast / unattented', 6)" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N
fi
 
echo "CREATE TABLE IF NOT EXISTS se3_tftp_action (
echo "CREATE TABLE IF NOT EXISTS se3_tftp_action (
id INT(11),
mac VARCHAR(255),
name VARCHAR(255),
49,9 → 38,9
type VARCHAR(255),
num_op INT(11),
infos VARCHAR(255)
);" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N
);" |$mysqlrequest
 
echo "CREATE TABLE IF NOT EXISTS se3_tftp_sauvegardes (
echo "CREATE TABLE IF NOT EXISTS se3_tftp_sauvegardes (
id INT( 11 ) NOT NULL ,
name VARCHAR( 255 ) NOT NULL ,
mac VARCHAR( 255 ) NOT NULL ,
63,7 → 52,7
partitionnement TEXT NOT NULL,
identifiant int(11) NOT NULL auto_increment,
PRIMARY KEY (identifiant)
);" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N
);" |$mysqlrequest
 
 
echo "CREATE TABLE IF NOT EXISTS se3_tftp_rapports (
76,7 → 65,7
descriptif TEXT NOT NULL,
identifiant int(11) NOT NULL auto_increment,
PRIMARY KEY (identifiant)
);" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N
);" |$mysqlrequest
 
 
echo "CREATE TABLE IF NOT EXISTS se3_tftp_infos (
87,7 → 76,7
valeur VARCHAR( 255 ) NOT NULL ,
identifiant int(11) NOT NULL auto_increment,
PRIMARY KEY (identifiant)
);" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N
);" |$mysqlrequest
 
#==============================================================================
 
104,6 → 93,19
 
#==============================================================================
 
 
# Ajout d'un droit pour que des personnes auxquelles un parc est delegue 'manage' puissent sauvegarder, restaurer, cloner,... sur ce parc
t=$(ldapsearch -xLLL -b ${rightsRdn},${ldap_base_dn} cn=parc_can_clone)
if [ -z "$t" ]; then
echo "dn: cn=parc_can_clone,${rightsRdn},${ldap_base_dn}
objectClass: groupOfNames
cn: parc_can_clone
member: uid=admin,${peopleRdn},${ldap_base_dn}
" | ldapadd -x -D ${adminRdn},${ldap_base_dn} -w ${adminPw}
fi
 
#==============================================================================
 
##### ADD good line in /etc/sudoers.conf if necessary and restart sudo
TEMOIN_CHGT_SUDO="n"
# TEST=$(grep "NOPASSWD:SE3CLONAGE" /etc/sudoers)
160,10 → 162,11
 
#==============================================================================
# Configuration des scripts dans /tftpboot d'apres les enregistrements en cours
tftp_aff_menu_pxe=$(echo "SELECT value FROM params WHERE name='tftp_aff_menu_pxe';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
tftp_pass_menu_pxe=$(echo "SELECT value FROM params WHERE name='tftp_pass_menu_pxe';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
tftp_slitaz_cmdline=$(echo "SELECT value FROM params WHERE name='tftp_slitaz_cmdline';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# tftp_aff_menu_pxe=$(echo "SELECT value FROM params WHERE name='tftp_aff_menu_pxe';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# tftp_pass_menu_pxe=$(echo "SELECT value FROM params WHERE name='tftp_pass_menu_pxe';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# tftp_slitaz_cmdline=$(echo "SELECT value FROM params WHERE name='tftp_slitaz_cmdline';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
 
 
if [ "${tftp_aff_menu_pxe}" != "y" ]; then
/usr/share/se3/scripts/se3_pxe_menu_ou_pas.sh 'standard'
else
193,24 → 196,25
 
# Pour renseigner le fichier param.ini du paquet post-clonage
if [ -e /var/se3/Progs/install/paquet_post-clonage/temp/clone/param.ini -a -z "$(grep 'Ne pas modifier' /var/se3/Progs/install/paquet_post-clonage/temp/clone/param.ini)" ]; then
dhcp_iface=$(echo "SELECT value FROM params WHERE name='dhcp_iface';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
netmask=$(/sbin/ifconfig $dhcp_iface |/bin/grep 'inet ' |/usr/bin/cut -d":" -f4 |/usr/bin/cut -d' ' -f1)
dhcp_gateway=$(echo "SELECT value FROM params WHERE name='dhcp_gateway';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
dhcp_dns_server_prim=$(echo "SELECT value FROM params WHERE name='dhcp_dns_server_prim';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
dhcp_wins=$(echo "SELECT value FROM params WHERE name='dhcp_wins';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
se3_domain=$(echo "SELECT value FROM params WHERE name='se3_domain';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
se3ip=$(echo "SELECT value FROM params WHERE name='se3ip';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
if [ -n "$dhcp_iface" -a -n "$netmask" -a -n "$dhcp_gateway" -a -n "$dhcp_dns_server_prim" -a -n "$dhcp_wins" -a -n "$se3_domain" -a -n "$se3ip" ]; then
# dhcp_iface=$(echo "SELECT value FROM params WHERE name='dhcp_iface';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# netmask=$(/sbin/ifconfig $dhcp_iface |/bin/grep 'inet ' |/usr/bin/cut -d":" -f4 |/usr/bin/cut -d' ' -f1)
# dhcp_gateway=$(echo "SELECT value FROM params WHERE name='dhcp_gateway';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# dhcp_dns_server_prim=$(echo "SELECT value FROM params WHERE name='dhcp_dns_server_prim';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# dhcp_wins=$(echo "SELECT value FROM params WHERE name='dhcp_wins';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# se3_domain=$(echo "SELECT value FROM params WHERE name='se3_domain';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
# se3ip=$(echo "SELECT value FROM params WHERE name='se3ip';" | mysql -h $dbhost $dbname -u $dbuser -p$dbpass -N)
#
 
if [ -n "$dhcp_iface" -a -n "$se3mask" -a -n "$dhcp_gateway" -a -n "$dhcp_dns_server_prim" -a -n "$dhcp_wins" -a -n "$se3_domain" -a -n "$se3ip" ]; then
cp /var/se3/Progs/install/paquet_post-clonage/temp/clone/param.ini /var/se3/Progs/install/paquet_post-clonage/temp/clone/param.ini.$(date +%Y%m%d%%H%M%S)
 
prefip=$(echo "$se3ip" | cut -d'.' -f1)
 
octet=$(echo "$netmask" | cut -d'.' -f2)
octet=$(echo "$se3mask" | cut -d'.' -f2)
if [ "$octet" = "255" ]; then
prefip="$prefip."$(echo "$se3ip" | cut -d'.' -f2)
 
octet=$(echo "$netmask" | cut -d'.' -f3)
octet=$(echo "$se3mask" | cut -d'.' -f3)
if [ "$octet" = "255" ]; then
prefip="$prefip."$(echo "$se3ip" | cut -d'.' -f3)
fi
218,7 → 222,7
prefip="$prefip."
 
echo "GW=$dhcp_gateway
MASK=$netmask
MASK=$se3mask
DNS=$dhcp_dns_server_prim
WINS=$dhcp_wins
PREFIP=$prefip