#!/bin/sh #----------------------------------------------------------------------------- # /var/install/bin/eisportal-tools-userlist # # Creation: 28.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. #----------------------------------------------------------------------------- #include eislib . /var/install/include/eislib . /etc/config.d/eisportal mysql_data_dir=/var/lib/mysql mysql_base_dir=/usr/local/mysql required_mysql_version_for_cui="1.2.14" # ab dieser Version sind die # benötigten Funktionen verfügbar ### ------------------------------------------------------------------------- ### use list-mysql.cui tool ### ------------------------------------------------------------------------- # check if use cui version . /etc/config.d/setup ### ------------------------------------------------------------------------- ### Check for MySQL-Version to use Curses-Funktions ### ------------------------------------------------------------------------- check=`/var/install/bin/check-version mysql ${required_mysql_version_for_cui}` case ${check} in not-installed) useCui="no" # dieser Fall sollte eigentlich nie eintreten ;; new) useCui="no" ;; old) useCui="yes" ;; installed) useCui="yes" ;; esac if [ "$MENU" = "/var/install/bin/show-menu.cui" -a "${useCui}" = "yes" ] then ${mysql_base_dir}/bin/list-mysql.cui --title="Show EisPortal users:" \ --database=${EISPORTAL_DB_NAME} \ --server=${EISPORTAL_DB_HOST} \ --user=${EISPORTAL_DB_ADMIN_USER} \ --pass=${EISPORTAL_DB_ADMIN_PASS} \ --column="Login,Firstname,Lastname,Role" \ --query="SELECT name, fname, lname, ELT(role+1,'No rights','User','-','Portaladmin') FROM eisportal_user" \ --helpfile=/var/install/help/eisportal \ --helpname=EISPORTAL_MENU_USERLIST exit 0 fi #----------------------------------------------------------------------------- # check for mysql #----------------------------------------------------------------------------- if [ ! -f /var/run/mysql.pid ] then mecho "" mecho -error "MySQL Server not running" mecho "" exit 1 fi # clear screen after mysql check clrhome #----------------------------------------------------------------------------- # get user data #----------------------------------------------------------------------------- userData=`${mysql_base_dir}/bin/mysql --skip-column-names -h ${EISPORTAL_DB_HOST} -D${EISPORTAL_DB_NAME} -u${EISPORTAL_DB_ADMIN_USER} -p${EISPORTAL_DB_ADMIN_PASS} -e"SELECT name, fname, lname, ELT(role+1,'No_rights','User','-','Portaladmin') FROM eisportal_user ;"` if [ ! -z "${userData}" ] # is any user existing? then # -> yes #----------------------------------------------------------------------------- # Extract user data #----------------------------------------------------------------------------- oldName=( `echo "${userData}" | cut -s -f1 | xargs -n1 echo -n " "` ) oldFName=( `echo "${userData}" | cut -s -f2 | xargs -n1 echo -n " "` ) oldLName=( `echo "${userData}" | cut -s -f3 | xargs -n1 echo -n " "` ) oldRole=( `echo "${userData}" | cut -s -f4` ) mecho "" mecho -info "Show EisPortal users" mecho "" techo begin 20 20 20 10 techo row "Username" "First name" "Last name" "Role" techo row "--------------------" "--------------------" "--------------------" "----------" for (( i = 0 ; i < ${#oldName[@]} ; i++ )) do techo row "${oldName[$i]}" "${oldFName[$i]}" "${oldLName[$i]}" "${oldRole[$i]}" done techo end else mecho -warn "No users in database." fi mecho "" anykey exit 0 #----------------------------------------------------------------------------- # end #-----------------------------------------------------------------------------