script sh for create database with zmconfig.txt

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
User avatar
chaapaï
Posts: 19
Joined: Fri Aug 13, 2004 2:26 pm
Location: France

script sh for create database with zmconfig.txt

Post by chaapaï »

Code: Select all

#!/bin/sh
# create-database.sh
# Script to create Database with zmconfig.txt
# Date 12 Oct 2004

cat < zmconfig.txt | while true
do
 read ligne
 if [ "$ligne" = "Name: ZM_DB_SERVER" ]
 then
     read ligne
     Script_DB_Server=`echo $ligne | cut -f2 -d" "`
     echo "Server Name : $Script_DB_Server"
 fi
 if [ "$ligne" = "Name: ZM_DB_NAME" ]
 then
     read ligne
     Script_DB_Name=`echo $ligne | cut -f2 -d" "`
     echo "Database Name : $Script_DB_Name"
     echo
 fi
 if [ "$ligne" = "Name: ZM_DB_USERA" ]
 then
     read ligne
     Script_DB_Usera=`echo $ligne | cut -f2 -d" "`
     echo "Admin Name : $Script_DB_Usera"
     
 fi
 if [ "$ligne" = "Name: ZM_DB_PASSA" ]
 then
     read ligne
     Script_DB_Passa=`echo $ligne | cut -f2 -d" "`
     echo "Admin Passwd : $Script_DB_Passa"
     echo
 fi
 if [ "$ligne" = "Name: ZM_DB_USERB" ]
 then
     read ligne
     Script_DB_Userb=`echo $ligne | cut -f2 -d" "`
     echo "User Passwd : $Script_DB_Userb"
     
 fi
 if [ "$ligne" = "Name: ZM_DB_PASSB" ]
 then
     read ligne
     Script_DB_Passb=`echo $ligne | cut -f2 -d" "`
     echo "User Passwd : $Script_DB_Passb"
     echo
 fi
 if [ "$ligne" = "Name: ZM_WEB_P_REFRESH_IMAGE"	]
 then
     echo " Create Database ..."
     cd db
     mysql mysql<zmschema.sql
     echo "GRANT SELECT,INSERT,UPDATE,DELETE ON $Script_DB_Name.* TO $Script_DB_Usera@$Script_DB_Server IDENTIFIED BY '$Script_DB_Passa' ; " | mysql
     echo "GRANT SELECT ON $Script_DB_Name.* TO $Script_DB_Userb@$Script_DB_Server IDENTIFIED BY '$Script_DB_Passb' ; " | mysql
     echo "FLUSH PRIVILEGES ; " | mysql
     mysqladmin reload
     break;
 fi
done
:D just tape

Code: Select all

[a@a]# sh create-database.sh
or

Code: Select all

[a@a]# chmod +x create-database.sh
[a@a]# ./create-database.sh
Post Reply