-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·58 lines (56 loc) · 1.51 KB
/
setup.sh
File metadata and controls
executable file
·58 lines (56 loc) · 1.51 KB
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
#!/bin/bash
BASEDIR=$(dirname $0)
read ussdsport ussdrport < ~/.ussd-conf
function welcome(){
ACTION=`zenity --width=450 --height=200 --list --radiolist \
--text="What do you want to do?" \
--title="Balance checker" \
--column "Choice" --column "Action" \
FALSE "List modem devices" \
TRUE "Set modem device"`
if [ -n "${ACTION}" ]; then
case $ACTION in
"List modem devices")
listdevices
;;
"Set modem device")
setmodem
;;
*)
exit
;;
esac
fi
}
function listdevices(){
# --title="List devices"
listofdevice=`dmesg -T |grep modem|grep -E 'ttyUSB[0-9]{1,2}'`
listofdevice2=`nmcli dev|grep -E 'ttyUSB[0-9]{1,2}'`
if [ -n "$listofdevice" ]
then
zenity --info --text="This is the list of your modem devices:\n\n$listofdevice\n\nAnd this is device found by network manager:\n$listofdevice2"
else
zenity --error --text="No device found"
fi
welcome
}
function setmodem(){
read ussdsport ussdrport < ~/.ussd-conf
ussdsport=`zenity --entry --title="Set modem device" \
--text="Enter device to send command to. Leave empty for default (/dev/ttyUSB2):" \
--entry-text "$ussdsport"`
if [ -z "$ussdsport" ]
then
ussdsport="/dev/ttyUSB2"
fi
ussdrport=`zenity --entry --title="Set modem device" \
--text="Enter device to read from. Leave empty for the same as device for sending command:" \
--entry-text "$ussdrport"`
if [ -z "$ussdrport" ]
then
ussdrport="$ussdsport"
fi
echo "$ussdsport $ussdrport" > ~/.ussd-conf
welcome
}
welcome