#!/bin/sh #----------------------------------------------------------------------------- # /var/install/bin/eisportal-tools-remotehost-remove [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" ### ------------------------------------------------------------------------- ### Remove Remote Host ### ------------------------------------------------------------------------- # yesRemoveRemoteHost=`/var/install/bin/ask "Remove remote host $1?" "y"` # if [ "${yesRemoveRemoteHost}" = "yes" ] # then # 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 mecho "DB admin user for remotehost ${remotehost} not existing, nothing to remove" else mecho -info -n "Removing remote user privileges for host ${remotehost}... " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON * . * FROM ${EISPORTAL_DB_ADMIN_USER}@${remotehost}; " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON ${EISPORTAL_DB_NAME} . * FROM ${EISPORTAL_DB_ADMIN_USER}@${remotehost}; " mecho -info "Done." mecho -info -n "Removing remote user for host ${remotehost}... " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "DROP USER ${EISPORTAL_DB_ADMIN_USER}@${remotehost}; " mecho -info "Done." fi # fi fi