source: lliurex-cssh/trunk/fuentes/install/usr/sbin/lliurex-admin-clients @ 471

Last change on this file since 471 was 471, checked in by mabarracus, 4 years ago

Copy trusty code

  • Property svn:executable set to *
File size: 2.0 KB
Line 
1#! /bin/bash
2
3set -e
4set +x
5export TEXTDOMAIN="lliurex-cssh"
6PATH="/usr/sbin:/usr/bin:/sbin:/bin"
7
8MSG_LOGIN_USER=$(gettext "User's login to connect the clients")
9MSG_USER=$(gettext "User:")
10MSG_ERROR_NAME_USER=$(gettext "Login field empty")
11MSG_CHECK_MACHINES=$(gettext "Checking online clients")
12MSG_WAITING=$(gettext "Wait please...")
13MSG_NO_CLIENTS_ONLINE=$(gettext "No clients online")
14MSG_CLIENTS_ONLINE_PART1=$(gettext "We have ")
15MSG_CLIENTS_ONLINE_PART2=$(gettext " computers online ")
16MSG_CONTINUE=$(gettext "Do you want to continue?")
17#LANG="es_ES.UTF-8"
18tcos_port="22"
19num_clientes=1
20clients_file="clientes"
21eval $(n4d-vars getvalues INTERNAL_NETWORK)
22eval $(n4d-vars getvalues INTERNAL_MASK)
23eval $(n4d-vars getvalues SRV_IP)
24
25#Ask for a user to connect with
26usuario=$(zenity --width="500" --entry --title="$MSG_LOGIN_USER" --text="$MSG_USER")
27#If the user is empty we finish
28        if [ -z $usuario ]
29        then
30                echo "$MSG_ERROR_NAME_USER"
31                exit 1
32        fi
33
34#Obtain registrered active clients
35if [ true ]; then
36        echo "1"
37        nmap -sS -p$tcos_port -oG $clients_file $INTERNAL_NETWORK"/"$INTERNAL_MASK
38        cat $clients_file| grep open|cut -d " " -f2>clients.tmp
39        cat clients.tmp | sed -e 's/^/'$usuario'@/g'>$clients_file
40        rm clients.tmp
41        echo "2"
42        #remove the server IP
43        cat $clients_file| grep -v $(echo $SRV_IP | cut -d "=" -f2|cut -d "'" -f2)>$clients_file
44fi |zenity --progress --pulsate --width="300" --auto-close --title="$MSG_CHECK_MACHINES" --text="$MSG_WAITING" --percentage=0
45
46#Check if there are any client connected
47if [ ! -f $clients_file ]
48then
49        echo "$MSG_NO_CLIENTS_ONLINE"
50else
51        #Show a list with the connected clients
52        zenity --question --text="$MSG_CLIENTS_ONLINE_PART1"$(wc -l < $clients_file)"$MSG_CLIENTS_ONLINE_PART2"$(echo $network|cut -d "/" -f1)": \n"$(cat $clients_file|cut -d "." -f4|tr -s "\n" ",")" \n$MSG_CONTINUE"
53        if [ $? -eq 0 ]
54        then
55                echo "adeu"
56                #Connect to all clients in the list
57                cssh $(cat $clients_file) #2> /dev/null
58                #rm $clients_file
59        else
60                exit 1
61        fi
62fi
Note: See TracBrowser for help on using the repository browser.