#!/bin/sh #----------------------------------------------------------------------------- # /var/install/bin/eisportal-tools-remotehost-add [Remotehost-IP] # # Creation: 28.09.2006 ys # Last Update: $Id$ # # Copyright (c) 2005-2006 Yves Schumann # # This program 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 2 of the License, or # (at your option) any later version. #----------------------------------------------------------------------------- #include eislib . /var/install/include/eislib . /etc/config.d/eisportal mysql_data_dir=/var/lib/mysql mysql_base_dir=/usr/local/mysql if [ $# -lt 1 ] then mecho "" mecho -info "Usage: $0 REMOTEHOST" mecho "" anykey exit 1 fi remotehost=$1 ### ------------------------------------------------------------------------- ### check for mysql ### ------------------------------------------------------------------------- if [ ! -f /var/run/mysql.pid ] then mecho -error "Error! Cannot connect to MySQL server." else ### ------------------------------------------------------------------------- ### get backup password ### ------------------------------------------------------------------------- mysql_pass=`grep passwd= ${mysql_data_dir}/backup.pwd | sed "s/passwd=//g"` user="backup" ### ------------------------------------------------------------------------- ### Create Remote Host ### ------------------------------------------------------------------------- # check if user exists show_eisportal_user=`${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "SELECT user FROM user WHERE user='${EISPORTAL_DB_ADMIN_USER}' AND host='${remotehost}';"` if [ -z "${show_eisportal_user}" ] then # create user mecho -n "Creating DB admin user for remotehost '${remotehost}'... " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , INDEX , ALTER ON ${EISPORTAL_DB_NAME}.* TO ${EISPORTAL_DB_ADMIN_USER}@${remotehost} identified by '${EISPORTAL_DB_ADMIN_PASS}'; flush privileges; " mecho "Done." mecho "" mecho -info "If you changed the admin user, the old admin user is still" mecho -info "existing! EisPortal does not know, if the old admin user is" mecho -info "in use by another program." mecho -info "To remove the old admin user, use 'Remove Admin User'" mecho -info "from EisPortal Administration -> 4. Administrative Tools." mecho -info "To change the password use only the setup tool!" mecho "" else mecho -n "DB admin user for remotehost ${remotehost} exists, updating password..." ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "SET PASSWORD FOR ${EISPORTAL_DB_ADMIN_USER}@${remotehost} = PASSWORD('${EISPORTAL_DB_ADMIN_PASS}')" mecho "Done." fi fi