1
1
#! /usr/bin/env bash
2
2
3
+ exit () {
4
+ aueb
5
+ builtin exit ${1:- 0}
6
+ }
7
+
3
8
aueb () {
4
9
cat << EOM
5
10
-----------------------
@@ -24,7 +29,7 @@ usage: aueb option suboption
24
29
notes:
25
30
a) if your wireless interface is not 'wlan0' then
26
31
set the IFACE variable to your interface name, eg;
27
- IFACE="ath0" aueb wifi up
32
+ sudo IFACE="ath0" ./ aueb wifi up
28
33
b) you may need to turn off any running network
29
34
managers to let wifi work.
30
35
EOM
@@ -34,17 +39,17 @@ detect_dist() {
34
39
printf " ** %s\n" " Detecting distribution .."
35
40
dist=" $( head -1 -q /etc/* release | sed ' s/.*"\(.\+\)".*/\1/' \
36
41
| tr [[:upper:]] [[:lower:]]) "
37
- confirm_dist $dist && return 0
42
+ confirm_dist && return 0
38
43
39
44
type lsb_release & > /dev/null && dist=" $( lsb_release -i \
40
45
| awk -F' :\t' ' { print $2 }' | tr [[:upper:]] [[:lower:]]) "
41
- confirm_dist $dist && return 0 \
46
+ confirm_dist && return 0 \
42
47
|| printf " \n ** %s\n" " Couldn't detect distribution" && return 1
43
48
}
44
49
45
50
confirm_dist () {
46
51
local answer
47
- printf " Is this your distribution: %s (Y/n)? " " $1 " && read answer
52
+ printf " Is this your distribution: %s (Y/n)? " " $dist " && read answer
48
53
[[ -z $answer || $answer =~ ^[yY]$ ]] && return 0 || return 1
49
54
}
50
55
@@ -65,8 +70,7 @@ choose_dist() {
65
70
break
66
71
;;
67
72
0)
68
- aueb
69
- exit 0
73
+ exit
70
74
;;
71
75
* )
72
76
printf " --> Unknown choice: %s. Please try again.\n" " $choice "
@@ -75,7 +79,48 @@ choose_dist() {
75
79
done
76
80
}
77
81
78
- create_profile () {
82
+ install_extra () {
83
+ # FIXME
84
+ echo " Install Extra"
85
+ case $dist in
86
+ arch)
87
+ # TODO:
88
+ # download package from AUR
89
+ # unpack && makepkg
90
+ # pacman -U
91
+ ;;
92
+ ubuntu)
93
+ for pkg in ${packages["extra-${dist}"]} ; do
94
+ # FIXME or create .deb packages ~ similar to arch/AUR
95
+ make install $pkg
96
+ done
97
+ ;;
98
+ esac
99
+ for pkg in ${packages["extra-both"]} ; do
100
+ # FIXME
101
+ make install $pkg
102
+ done
103
+ }
104
+
105
+ uninstall_extra () {
106
+ case $dist in
107
+ arch)
108
+ ${uninstaller["$dist"]} ${packages["extra-${dist}"]}
109
+ ;;
110
+ ubuntu)
111
+ for pkg in ${packages["extra-${dist}"]} ; do
112
+ # FIXME or remove .deb ~ similar to arch/AUR
113
+ make uninstall $pkg
114
+ done
115
+ ;;
116
+ esac
117
+ for pkg in ${packages["extra-both"]} ; do
118
+ # FIXME
119
+ make uninstall $pkg
120
+ done
121
+ }
122
+
123
+ create_wifi_profile () {
79
124
[[ -e $wificonf ]] && return
80
125
cat > " $wificonf " << EOF
81
126
ctrl_interface=${PREFIX} /wpa_aueb
@@ -94,7 +139,10 @@ network={
94
139
EOF
95
140
}
96
141
97
- (( UID )) && printf " --> %s\n" " You must have root priviledges to run this script" && aueb && exit 1
142
+ # TODO: uncomment on deploy
143
+ # (( UID )) && printf " --> %s\n" "You must have root priviledges to run this script" >&2 && exit 1
144
+
145
+ dist=
98
146
99
147
case $1 in
100
148
packages)
@@ -108,26 +156,28 @@ case $1 in
108
156
)
109
157
declare -A packages
110
158
packages=( [common]=" netbeans geany nmap scilab tcsh wireshark"
111
- [ubuntu]=" openjdk-6-jdk build-essential wireless-tools wpasupplicant"
112
159
[arch]=" openjdk6 base-devel wireless_tools wpa_supplicant"
160
+ [extra-arch]=" nessus omnetpp4 xampp" # # AUR
161
+ [ubuntu]=" openjdk-6-jdk build-essential wireless-tools wpasupplicant nessus"
162
+ [extra-ubuntu]=" omnetpp xampp"
163
+ [extra-both]=" quartus"
113
164
)
114
- dist=
115
165
116
166
case $2 in
117
167
install)
118
168
detect_dist || choose_dist
119
- printf " ** Running: %s\n" " ${installer["$dist"]} ${packages["common"]} ${packages["$dist"]} " \
120
- && { printf " ==> %s\n" " Software ready to use" ; aueb ; exit 0 ; } \
121
- || { printf " --> %s\n" " Failed to install packages. Check with your package manager." ; aueb ; exit 1; }
169
+ printf " ** Running: %s\n" " ${installer["$dist"]} ${packages["common"]} ${packages["$dist"]} " \
170
+ && install_extra && printf " ==> %s\n" " Software ready to use" \
171
+ || { printf " --> %s\n" " Failed to install packages. Check with your package manager." >&2 ; exit 1; }
122
172
;;
123
173
remove)
124
174
detect_dist || choose_dist
125
175
printf " ** Running: %s\n" " ${uninstaller["$dist"]} ${packages["common"]} ${packages["$dist"]} " \
126
- && { printf " ==> %s\n" " Software removed" ; aueb ; exit 0 ; } \
127
- || { printf " --> %s\n" " Failed to uninstall packages. Check with your package manager." ; aueb ; exit 1; }
176
+ && uninstall_extra && printf " ==> %s\n" " Software removed" \
177
+ || { printf " --> %s\n" " Failed to uninstall packages. Check with your package manager." >&2 ; exit 1; }
128
178
;;
129
179
* )
130
- printf " --> Unknown option: %s\n" " $2 "
180
+ printf " --> Unknown option: %s\n" " $2 " >&2
131
181
exit 1
132
182
;;
133
183
esac
@@ -140,34 +190,33 @@ case $1 in
140
190
141
191
case $2 in
142
192
up)
143
- create_profile
144
- printf " ** Running: %s\n" " wpa_supplicant -Dwext -i${IFACE} -c${wificonf} " \
145
- && printf " ==> %s\n" " Connected to aueb wireless network" \
146
- || printf " --> %s\n" " Couldn't connect to wireless network"
193
+ create_wifi_profile
194
+ printf " ** Running: %s\n" " wpa_supplicant -Dwext -i${IFACE} -c${wificonf} " \
195
+ && printf " ==> %s\n" " Connected to aueb wireless network" \
196
+ || printf " --> %s\n" " Couldn't connect to wireless network" >&2
147
197
;;
148
198
down)
149
199
printf " ** Running: %s\n" " ifconfig ${IFACE} down"
150
200
printf " ==> %s\n" " Disconnected wireless connection"
151
201
;;
152
202
* )
153
- printf " --> Unknown option: %s\n" " $2 "
203
+ printf " --> Unknown option: %s\n" " $2 " >&2
154
204
exit 1
155
205
;;
156
206
esac
157
207
;;
158
208
help)
159
209
usage
160
- exit 0
161
210
;;
162
211
* )
163
- printf " --> Unknown option: %s\n" " $1 "
212
+ printf " --> Unknown option: %s\n" " $1 " >&2
164
213
exit 1
165
214
;;
166
215
esac
216
+ exit
167
217
168
218
# TODO:
169
- # -- install/remove --
170
- # custom packages for: omnet spim xampp quartus nessus
171
- # -- wifi_toggle --
172
- # follow output and react <- tailf?
219
+ # custom packages: omnet xampp quartus nessus
220
+ # test wpa_supplicant
173
221
222
+ # vim: nospell
0 commit comments