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

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

Copy trusty code

  • Property svn:executable set to *
File size: 2.1 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="8998"
19num_clientes=1
20clients_file="clientes"
21network=$(n4d-vars listvars |grep INTERNAL_NETWORK|cut -d "=" -f2|cut -d "'" -f2)
22bitmask=$(n4d-vars listvars |grep INTERNAL_MASK|cut -d "=" -f2|cut -d "'" -f2)
23echo $network
24echo $bitmask
25
26#Ask for a user to connect with
27usuario=$(zenity --width="500" --entry --title="$MSG_LOGIN_USER" --text="$MSG_USER")
28#If the user is empty we finish
29        if [ -z $usuario ]
30        then
31                echo "$MSG_ERROR_NAME_USER"
32                exit 1
33        fi
34echo $usuario
35#Obtain registrered active clients
36
37if [ true ]; then
38        echo "1"
39        nmap -sS -p9779 -oG $clients_file $network"/"$bitmask
40        echo "2"
41        cat $clients_file| grep open|cut -d " " -f2>clients.tmp
42        echo "3"
43        cat clients.tmp | sed -e 's/^/'$usuario'@/g'>$clients_file
44        rm clients.tmp
45        echo "2"
46        #remove the server IP
47        cat clientes| grep -v $(n4d-vars listvars|grep ^SRV_IP | cut -d "=" -f2|cut -d "'" -f2)>clientes
48fi | zenity --progress --pulsate --width="300" --auto-close --title="$MSG_CHECK_MACHINES" --text="$MSG_WAITING" --percentage=0
49echo $clients_file
50#Check if there are any client connected
51if [ ! -f $clients_file ]
52then
53        echo "$MSG_NO_CLIENTS_ONLINE"
54else
55        #Show a list with the connected clients
56        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"
57        if [ $? -eq 0 ]
58        then
59
60                #Connect to all clients in the list
61                cssh $(cat $clients_file) #2> /dev/null
62                #rm $clients_file
63        else
64                exit 1
65        fi
66fi
Note: See TracBrowser for help on using the repository browser.