-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfossPrj_tui
executable file
·86 lines (77 loc) · 1.72 KB
/
fossPrj_tui
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
which fossPrj 1> /dev/null
if [ $? -ne 0 ]; then
echo "fossPrj not installed"
exit 1
else
cmd=fossPrj
fi
HOST=localhost
PORT=1234
FILE=/tmp/fossPrj-$$
ERROR=/tmp/fossPrj-err-$$
closePrg() {
rm -f $FILE $ERROR
exit 0
}
end () {
exit
}
while true;
do
if [ `basename $0` = "fossPrj_tui" ]; then
read -p "Enter channel number to change to: " pattern
elif [ `basename $0` = "fossPrj_gui" ]; then
which gdialog 1> /dev/null && DIALOG=gdialog || DIALOG=dialog 1> /dev/null
cmd=($DIALOG --keep-tite --menu "Select channel :" 11 30 16)
options=(1 "Unencrypted"
2 "Encrypted")
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
if [ $? -eq 1 ]
then
end
fi
for choice in $choices
do
for choice in $choices
do
case $choice in
[1-2])
mode="Encrypted"
if [ $choice -eq 1 ]
then
mode="Encryption disabled"
fi
echo $choice | fossPrj 1> /tmp/hello
val=`cat /tmp/hello`
if [ $val -gt 199 -a $val -lt 300 ]
then
display="Changed to channel : $mode. Would you like to continue? \n"
else
display="Couldn\'t contact server. Please try again later\n"
fi
$DIALOG --yesno "$display" 10 25 || end
;;
esac
done
done
elif [ `basename $0` = "fossPrj_net" ]; then
read -p "Switch to: " ACTION
CMD="nc $HOST $PORT"
fi
case ${pattern} in
*[!1-2]* )
printf " Please enter a number between 0 and 2 \n 1 - Unencrypted \n 2 - Encrypted \n ctrl + c to exit \n"
;;
*[1-2]* )
echo $pattern | fossPrj 1> /tmp/hello
val=`cat /tmp/hello`
if [ $val -gt 199 -a $val -lt 300 ]
then
printf "Changed to channel : $pattern \n"
else
printf "Couldn\'t contact server. Please try again later\n"
fi
;;
esac
done