#!/bin/sh #--------------------------------------------------------------------------- # /var/install/bin/eisportal-remove-admin # # Creation: 26.06.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. #--------------------------------------------------------------------------- #exec 2>/public/eisportal-trace$$.log #set -x . /etc/config.d/eisportal . /var/install/include/eislib package_name=eisportal mysql_data_dir=/var/lib/mysql mysql_base_dir=/usr/local/mysql clrhome #----------------------------------------------------------------------------- # remove DB-Admin-User #----------------------------------------------------------------------------- removeAdminUser () { if [ ! -f /var/run/mysql.pid ] then mecho -error "Error! Cannot connect to MySQL server." else #----------------------------------------------------------------------------- # read settings #----------------------------------------------------------------------------- . /etc/config.d/${package_name} #----------------------------------------------------------------------------- # read the password include special chars for admin user #----------------------------------------------------------------------------- mysql_pass=`grep passwd= ${mysql_data_dir}/backup.pwd | sed "s/passwd=//g"` #----------------------------------------------------------------------------- # ask for user to remove #----------------------------------------------------------------------------- userToRemove=`/var/install/bin/ask "Enter name of db admin user to remove: " "" "*"` if [ -z ${userToRemove} ] then mecho "No username entered, exiting" anykey exit 1 fi #----------------------------------------------------------------------------- # check if user to remove == root, cancel if so #----------------------------------------------------------------------------- if [ ${userToRemove} != "backup" ] then mecho -info -n "Removing admin user privileges... " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON * . * FROM ${userToRemove}@${EISPORTAL_DB_HOST}; " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "REVOKE ALL PRIVILEGES ON ${EISPORTAL_DB_NAME} . * FROM ${userToRemove}@${EISPORTAL_DB_HOST}; " mecho -info "Done." mecho -info -n "Removing admin user... " ${mysql_base_dir}/bin/mysql -D mysql -u backup -p${mysql_pass} -e "DROP USER ${userToRemove}@${EISPORTAL_DB_HOST}; " mecho -info "Done." else mecho -warn "Removing db user 'backup' not possible!" fi fi # check for mysql } ###---------------------------------------------------------------------------- ### main ###---------------------------------------------------------------------------- if [ "${EISPORTAL_DB_LOCATION_LOCAL}" = "yes" ] then removeAdminUser else mecho -info "Removing of DB-Admin-User only on Databases running on the" mecho -info "same machine possible. If you want to remove an admin user" mecho -info "on another machine use the mysql administration there." fi anykey exit 0 ### --------------------------------------------------------------------------- ### End ###----------------------------------------------------------------------------