-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopengear_port.sh
More file actions
executable file
·115 lines (94 loc) · 2.33 KB
/
opengear_port.sh
File metadata and controls
executable file
·115 lines (94 loc) · 2.33 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
if [ `whoami` == "root" ]
then
echo ""
echo "Cannot run as root. Configuration file stored in your home directory contains password!"
exit 0
fi
if [ ! -f ~/.opengear_port.cfg ]
then
echo "Config File not Found!"
echo "Generating..."
echo "Enter your username"
read username
echo "Enter your password"
stty -echo
read password
stty echo
echo "username=$username" > ~/.opengear_port.cfg
echo "password=$password" >> ~/.opengear_port.cfg
chmod 700 ~/.opengear_port.cfg
fi
source ~/.opengear_port.cfg
if [ "$1" != "" ]
then
sleep 0
else
echo "opengear_port.sh"
echo "Usage: opengear_port.sh [interactive (yes/no)?] [hostname] [port] [speed (96, 19, 38, 57, 115)]"
exit 0
fi
if [ "$1" == "no" ]
then
if test -z "$4"
then
exit 0
fi
opengear_hostname=$2
port_num=$3
speed_num=$4
fi
if [ "$1" == "yes" ]
then
echo ""
echo "OpenGear hostname (e.g. bil1-con02)"
read opengear_hostname
echo "Desired Port?"
read port_num
echo "Port Speed?"
echo "1) 9600"
echo "2) 19200"
echo "3) 38400"
echo "4) 57600"
echo "5) 115200"
echo ""
read speed_num
fi
if [ $speed_num == "1" ]
then
speed=9600
elif [ $speed_num == "2" ]
then
speed=19200
elif [ $speed_num == "3" ]
then
speed=38400
elif [ $speed_num == "4" ]
then
speed=57600
elif [ $speed_num == "5" ]
then
speed=115200
elif [ $speed_num == "96" ]
then
speed=9600
elif [ $speed_num == "19" ]
then
speed=19200
elif [ $speed_num == "38" ]
then
speed=38400
elif [ $speed_num == "57" ]
then
speed=57600
elif [ $speed_num == "115" ]
then
speed=115200
fi
echo ""
echo "Speed set to $speed Baud, port $port_num on $opengear_hostname"
echo ""
echo "Please wait..."
terminal=vt100
curl -s -k --user $username:$password https://$opengear_hostname --cookie-jar /tmp/cookie --cookie /tmp/cookie --data "new.port$port_num=on&edit.port=$port_num&new.label=Port+$port_num&new.speed=$speed&new.charsize=8&new.parity=None&new.stop=1&new.flowcontrol=Hardware&new.protocol=RS232&new.mode=portmanager&new.loglevel=0&new.ssh=on&new.delay=&new.escapechar=&powerType=None&outletLabel=&new.power.username=&new.power.password=&new.power.confirm=&new.username=&new.password=&new.confirm=&new.terminal=$terminal&new.bridge.address=&new.bridge.port=&new.logfacility=Default&new.logpriority=Default&apply=Apply&outletLabels=&form=serialconfig" "https://$opengear_hostname/?form=serialconfig&action=edit&ports=$port_num" > /dev/null
echo "Done."