9 if [ -f $ZM_CONFIG ]; then
12 echo "ERROR: $ZM_CONFIG not found."
18 /etc
/rc.d
/mysqld restart ||
(echo "mysql is not availible" && exit 1 )
22 echo "Enter MySQL Administrator username"
23 echo "(Default: root and password is blank)"
24 echo -n "MySQL Admin: "
28 if [ "X$MYPASS" != "X" ]; then MYPASS
="-p$MYPASS"; fi
29 echo "\q" |mysql
-u $MYADMIN $MYPASS ||
exit 0
35 # Check database exisits and version
36 exists
=$
(echo "show databases" |mysql
-u $MYADMIN "$MYPASS" |
grep zm
)
37 if [ "$exists" = "zm" ]; then
38 OLD_VERSION
=$
(echo "select Value from Config where Name = 'ZM_DYN_DB_VERSION';" | mysql
-u $MYADMIN $MYPASS zm |
grep -v '^Value')
42 echo "A zm database exists, but the version is unknown"
43 echo "Updating is unlikely to succeed"
46 echo "The zm database appears to be up to date"
47 echo "If this is incorrect, edit $ZM_CONFIG to reflect the current version"
50 echo "A database fron zm-$OLD_VERSION exists already"
56 echo "Choose one of the following options:"
57 echo "[U]pdate the database"
58 echo "[D]rop the old database and reinitialize"
59 echo "[E]xit and do nothing"
67 echo "drop database zm;"|mysql
-u $MYADMIN $MYPASS
79 for n
in ZM_DB_HOST ZM_DB_NAME ZM_DB_USER ZM_DB_PASS
; do
81 if [ "$val" = "" ]; then
82 echo "ERROR($ZM_CONFIG): $n should not be empty."
83 echo "Enter a $n for ZM to use the Database."
84 if [ "$n" = "ZM_DB_PASS" ]; then
85 echo -n "Will not echo on screen $n : "
86 stty
-echo # Turns off screen echo.
88 stty
echo # Restores screen echo.
90 ### The following can be used to generate a random password
96 cp $ZM_CONFIG /tmp
/$$
&&
97 sed 's/^'$n='.*$/'$n=$newval'/g' /tmp
/$$
>$ZM_CONFIG
102 if [ "$ZM_DB_HOST" = "localhost" ]; then
105 ClientHost
=`hostname`
118 echo "CREATE DATABASE $ZM_DB_NAME;" >>$sql
119 echo "USE $ZM_DB_NAME;" >>$sql
121 echo "GRANT all on $ZM_DB_NAME.* TO '$ZM_DB_USER'@'$ClientHost' IDENTIFIED BY '$ZM_DB_PASS';" >>$sql
123 cat $sql | mysql
-B -h $ZM_DB_HOST -u $MYADMIN $MYPASS
126 cat $ZM_PATH_UPDATE/zm_create.sql | mysql
-h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME
127 ( cd $ZM_PATH_UPDATE; perl
$ZM_PATH_BIN/zmupdate.pl
-f )
129 $ZM_PATH_UPDATE/customdb
$ZM_DB_HOST $ZM_DB_NAME $ZM_DB_USER $ZM_DB_PASS