#!/usr/bin/tclsh package require helga 1.0 if { [info vars ::ADMINSQLPASS] == "" } { puts "Error: you must have administrator access to MySQL to run this script." exit 1 } set db [::mysql::connect -user helgaAdmin -password $::ADMINSQLPASS] set dbNames [::mysql::info $db databases] if { [lsearch $dbNames $::SQLDB] == -1 } { if { [catch "exec mysql -u helgaAdmin --password=$::ADMINSQLPASS -e \"CREATE DATABASE `$::SQLDB`\"" out] } { puts $out } puts -nonewline "Populating database structure..." set dirName [lrange [file split $argv0] 0 end-1] set fileName $dirName/initial.sql if { [catch "::helga::db::batch $fileName helgaAdmin $::ADMINSQLPASS" batchOut] } { puts "Error: $batchOut" exit 1 } puts "done" } else { puts "Database already exists." }