#!/usr/bin/tclsh # # This file is part of Helga. # # Helga is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Helga is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Helga. If not, see . # # Creates all MySQL Users set dirName [file dirname [file normalize $argv0]] source $dirName/sourceConf.tcl puts -nonewline "Enter MySQL root password: " flush stdout gets stdin sqlpass set userList [list [list helgaGuest ""] [list helgaBasic $::BASICSQLPASS] [list helgaAdvanced $::ADVANCEDSQLPASS] [list helgaAdmin $::ADMINSQLPASS]] foreach userAndPass $userList { set cmd "exec mysql --user=root --password=$sqlpass --execute=\"CREATE USER '[lindex $userAndPass 0]'@'%'" if { [lindex $userAndPass 1] != "" } { append cmd " IDENTIFIED BY '[lindex $userAndPass 1]'" } append cmd "\"" puts $cmd if { false } { if { [catch $cmd out] } { set outSplit [split $out " "] if { [lindex $outSplit 0] == "ERROR" && [lindex $outSplit 1] == "1045" } { puts $out exit 1; } } } }