-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathubuntuNetworkDebug.sh
658 lines (591 loc) · 28.3 KB
/
ubuntuNetworkDebug.sh
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
#!/usr/bin/env bash
#======================================================================================================================
# ▄█ █▄ ▄████████ ▄████████ ████████▄ ▄████████ ▄████████
# ███ ███ ███ ███ ███ ███ ███ ▀███ ███ ███ ███ ███
# ███ ███ ███ █▀ ███ ███ ███ ███ ███ █▀ ███ ███
# ▄███▄▄▄▄███▄▄ ▄███▄▄▄ ███ ███ ███ ███ ▄███▄▄▄ ▄███▄▄▄▄██▀
# ▀▀███▀▀▀▀███▀ ▀▀███▀▀▀ ▀███████████ ███ ███ ▀▀███▀▀▀ ▀▀███▀▀▀▀▀
# ███ ███ ███ █▄ ███ ███ ███ ███ ███ █▄ ▀███████████
# ███ ███ ███ ███ ███ ███ ███ ▄███ ███ ███ ███ ███
# ███ █▀ ██████████ ███ █▀ ████████▀ ██████████ ███ ███
#======================================================================================================================
# SYNOPSIS
# usage: <script name> -a <sample_argument> -d
# Options:
# -d Turn on debugging.
# -h Display this message.
#
# Network tool installation and debugging potential.
#
# Example usage:./ubuntuNetworkDebug.sh -d
#======================================================================================================================
#- IMPLEMENTATION
#- version 1.0
#- author christopher wood
#- copyright None
#- license GNU General Public License
#- script_id UND_001
#-
#- /usr/bin/bash -n and shellcheck used for compliance.
#- To perform a syntax check/dry run of your bash script run:
#- -bash -n myscript.sh
#- To produce a trace of every command executed run:
#- -bash -v myscripts.sh
#- To produce a trace of the expanded command use:
#- -bash -x myscript.sh
#-
#- The layers in the TCP/IP network model, in order, include:
#- Layer 5: Application
#- Layer 4: Transport
#- Layer 3: Network/Internet
#- Layer 2: Data Link
#- Layer 1: Physical
#- Reference: https://www.redhat.com/sysadmin/beginners-guide-network-troubleshooting-linux
#======================================================================================================================
# HISTORY
# 2023/03/07 - Inception
#
#======================================================================================================================
# END_OF_HEADER
#======================================================================================================================
#*** CONFIGURATION ***
############################################################################################################################################
# ▄████████ ▄██████▄ ███▄▄▄▄ ▄████████ ▄█ ▄██████▄ ███ █▄ ▄████████ ▄████████ ███ ▄█ ▄██████▄ ███▄▄▄▄
# ███ ███ ███ ███ ███▀▀▀██▄ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▀█████████▄ ███ ███ ███ ███▀▀▀██▄
# ███ █▀ ███ ███ ███ ███ ███ █▀ ███▌ ███ █▀ ███ ███ ███ ███ ███ ███ ▀███▀▀██ ███▌ ███ ███ ███ ███
# ███ ███ ███ ███ ███ ▄███▄▄▄ ███▌ ▄███ ███ ███ ▄███▄▄▄▄██▀ ███ ███ ███ ▀ ███▌ ███ ███ ███ ███
# ███ ███ ███ ███ ███ ▀▀███▀▀▀ ███▌ ▀▀███ ████▄ ███ ███ ▀▀███▀▀▀▀▀ ▀███████████ ███ ███▌ ███ ███ ███ ███
# ███ █▄ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▀███████████ ███ ███ ███ ███ ███ ███ ███ ███
# ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
# ████████▀ ▀██████▀ ▀█ █▀ ███ █▀ ████████▀ ████████▀ ███ ███ ███ █▀ ▄████▀ █▀ ▀██████▀ ▀█ █▀
############################################################################################################################################
#- trap ctrl-c and call ctrl_c()
trap ctrl_c INT
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
#set -o errexit # abort on nonzero exitstatus, add || true to commands that allow you to fail (-e).
set -o nounset # abort on unbound variable, (-u)
set -o pipefail # don\'t hide errors within pipes to catch mysqldump fails in e.g. mysqldump |gzip. The exit status of the last command that threw a non-zero exit code is returned.
#set -o xtrace # trace what gets executed, good for debugging (-x)
set -a # Automatically mark variables and functions which are modified or created for export to the environment of subsequent commands.
#*** VARIABLES ***
############################################################################################################################################
# ▄█ █▄ ▄████████ ▄████████ ▄█ ▄████████ ▀█████████▄ ▄█ ▄████████ ▄████████
# ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
# ███ ███ ███ ███ ███ ███ ███▌ ███ ███ ███ ███ ███ ███ █▀ ███ █▀
# ███ ███ ███ ███ ▄███▄▄▄▄██▀ ███▌ ███ ███ ▄███▄▄▄██▀ ███ ▄███▄▄▄ ███
# ███ ███ ▀███████████ ▀▀███▀▀▀▀▀ ███▌ ▀███████████ ▀▀███▀▀▀██▄ ███ ▀▀███▀▀▀ ▀███████████
# ███ ███ ███ ███ ▀███████████ ███ ███ ███ ███ ██▄ ███ ███ █▄ ███
# ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███▌ ▄ ███ ███ ▄█ ███
# ▀██████▀ ███ █▀ ███ ███ █▀ ███ █▀ ▄█████████▀ █████▄▄██ ██████████ ▄████████▀
############################################################################################################################################
#flow of control
readonly script_name=$(basename "${0}")
readonly script_dir=$( cd "$( dirname "${0}" )" && pwd )
execute=0;
export WORKDIR="";
WORKDIR=$(dirname $0);
#application specific
export VERSION_NAME="UND";
export VERSION_MAJOR="1";
export VERSION_MINOR="0";
export no_date_prefix=""; #used with debugging framework
export arg_incoming_argument="";
export arg_debug="0";
export target_name="www.google.com";
export target_ip="8.8.8.8";
export the_tools=( net-tools iftop vnstat iptraf hping3 dstat slum bmon nmap );
export the_network_device="eth0";
export the_hops=4;
#setup paths for executables.
export command_apt=$(which apt);
export command_ping=$(which ping);
export command_ufw=$(which ufw);
export command_ls=$(which ls);
export command_ip=$(which ip);
export command_ethtool=$(which ethtool);
export command_cat=$(which cat);
export command_traceroute=$(which traceroute);
export command_nslookup=$(which nslookup);
export command_netstat=$(which netstat);
export the_commands=( ${command_apt} ${command_ping} ${command_ufw} ${command_ls} ${command_ip} ${command_ethtool} ${command_cat} ${command_traceroute} ${command_nslookup} ${command_netstat} )
# - INCLUDES
############################################################################################################################################
# ▄█ ███▄▄▄▄ ▄████████ ▄█ ███ █▄ ████████▄ ▄████████ ▄████████
# ███ ███▀▀▀██▄ ███ ███ ███ ███ ███ ███ ▀███ ███ ███ ███ ███
# ███▌ ███ ███ ███ █▀ ███ ███ ███ ███ ███ ███ █▀ ███ █▀
# ███▌ ███ ███ ███ ███ ███ ███ ███ ███ ▄███▄▄▄ ███
# ███▌ ███ ███ ███ ███ ███ ███ ███ ███ ▀▀███▀▀▀ ▀███████████
# ███ ███ ███ ███ █▄ ███ ███ ███ ███ ███ ███ █▄ ███
# ███ ███ ███ ███ ███ ███▌ ▄ ███ ███ ███ ▄███ ███ ███ ▄█ ███
# █▀ ▀█ █▀ ████████▀ █████▄▄██ ████████▀ ████████▀ ██████████ ▄████████▀
############################################################################################################################################
#Paths for sub-functions like the logging framework.
#export function_dirs="/u/yamm/cwood/FPATH";
#if [ -d "${function_dirs}" ];
#then
# export FPATH="${function_dirs:-""}:${FPATH:-""}";
#else
# echo "${function_dirs} does not exist."
# echo "ksh can use FPATH as the source of smaller functional scripts that act as functions."
# echo "When trying to build ${function_dirs} into FPATH a problem was encountered."
# echo "This script won't function properly without pointing to where your functions are."
# exit 20; #ENOTDIR, no directory
#fi
function ctrl_c {
msg_error "CTRL+C utilized..."
msg_warning "...clean-up of temporary files and actions halted."
exit -1
}
function banner {
#================================================================
# General function to display a banner, when desired, per
# function call.
#================================================================
boundary=72
if [ ! -z $1 ];
then
output_str=$1;
output_len=$(echo "${output_str}" | wc -c);
delta=$(( boundary - output_len ));
for i in $(seq 1 "${delta}" )
do
output_str+="=";
done
msg_info "${output_str}"
else
msg_info "=======================================================================";
fi
}
function get_ISO8601 {
funct_result=$(date +'%Y%m%d')
}
function get_ISO8601_full {
funct_result=$(date +'%Y-%m-%d %H:%M:%S')
}
function get_date {
funct_result=$(date +'%Y%m%d:%H%M')
}
function msg_debug {
export spacing=8;
if [[ -n "$no_date_prefix" ]]
then
typeset d=" "
else
#typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")" "
typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")
fi
typeset prefix="${d}"
typeset type="DEBUG:"
while [[ $# != 0 ]]
do
echo "$1" | {
while read -r line
do
printf "%s%+${spacing}s %s\\n" "${prefix}" "$type" "$line" 2>&1
done
}
shift
done
}
function msg_info {
export spacing=8;
if [[ -n "$no_date_prefix" ]]
then
typeset d=" "
else
#typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")" "
typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")
fi
typeset prefix="${d}"
typeset type="INFO:"
while [[ $# != 0 ]]
do
echo "$1" | {
while read -r line
do
printf "%s%+${spacing}s %s\\n" "${prefix}" "$type" "$line" 2>&1
done
}
shift
done
}
function msg_emerg {
export error_msg="${1}"
export spacing=8;
if [[ -n "$no_date_prefix" ]]
then
typeset d=" "
else
#typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")" "
typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")
fi
typeset prefix="${d}"
typeset type="CRITICAL:"
while [[ $# != 0 ]]
do
echo "$1" | {
while read -r line
do
printf "%s%+${spacing}s %s\\n" "${prefix}" "$type" "$line" >&2
done
}
shift
done
error_exit "${error_msg}"
}
function msg_error {
export spacing=8;
if [[ -n "$no_date_prefix" ]]
then
typeset d=" "
else
#typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")" "
typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")
fi
typeset prefix="${d}"
typeset type="ERROR:"
while [[ $# != 0 ]]
do
echo "$1" | {
while read -r line
do
printf "%s%+${spacing}s %s\\n" "${prefix}" "$type" "$line" >&2
done
}
shift
done
}
function msg_warning {
export spacing=8;
if [[ -n "$no_date_prefix" ]]
then
typeset d=" "
else
#typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")" "
typeset d=$(TZ='GST-0' date +"[%Y-%m-%d %H:%M:%S]")
fi
typeset prefix="${d}"
typeset type="WARN:"
while [[ $# != 0 ]]
do
echo "$1" | {
while read -r line
do
printf "%s%+${spacing}s %s\\n" "${prefix}" "$type" "$line" 2>&1
done
}
shift
done
}
function error_exit {
echo " ============ ERROR ===========" >&2
echo " | ____| " >&2
echo " | |__ _ __ _ __ ___ _ __ " >&2
echo " | __| | '__| '__/ _ \| '__| " >&2
echo " | |____| | | | | (_) | | " >&2
echo " |______|_| |_| \___/|_| " >&2
echo " ============ ERROR ===========" >&2
echo "${the_argument}";
get_date;
exit 1
}
function usage {
cat <<@EOF
usage: <script name> -d
Options:
-d Enable debug output [DEBUG].
Example usage: ./ubuntuNetworkDebug.ksh -d
@EOF
# if [ $# -gt 0 ];
# then
# if [ $1 -eq 1 ];
# then
# exit
# fi
# fi
}
#*** FUNCTIONS ***
############################################################################################################################################
# ▄████████ ███ █▄ ███▄▄▄▄ ▄████████ ███ ▄█ ▄██████▄ ███▄▄▄▄ ▄████████
# ███ ███ ███ ███ ███▀▀▀██▄ ███ ███ ▀█████████▄ ███ ███ ███ ███▀▀▀██▄ ███ ███
# ███ █▀ ███ ███ ███ ███ ███ █▀ ▀███▀▀██ ███▌ ███ ███ ███ ███ ███ █▀
# ▄███▄▄▄ ███ ███ ███ ███ ███ ███ ▀ ███▌ ███ ███ ███ ███ ███
# ▀▀███▀▀▀ ███ ███ ███ ███ ███ ███ ███▌ ███ ███ ███ ███ ▀███████████
# ███ ███ ███ ███ ███ ███ █▄ ███ ███ ███ ███ ███ ███ ███
# ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄█ ███
# ███ ████████▀ ▀█ █▀ ████████▀ ▄████▀ █▀ ▀██████▀ ▀█ █▀ ▄████████▀
############################################################################################################################################
function validate_program {
#================================================================
# Check all CLI arguments before we start any work
# -- examples are below for purposes of how an implimentation might look
#================================================================
execute=1;
msg_info "Validating arguments.";
#make sure the script doesn't run as root (security concern)
whoami=$(id -u)
if [ "${whoami}" -eq 0 ];
then
msg_emerg "This script is not authorized to run as root."
fi
#test for existence of all commands, if one is missing ensure invoker understands this.
for the_command in ${the_commands[@]}
do
if ! [ -f ${the_command} ];
then
msg_warning "...FAILED to find ${the_command}";
fi
done
#if [[ -z $arg_incoming_argument ]];
#then
# msg_error "Cannot find an argument variable Without the argument variable no processing can occur. Aborting...";
# execute=0;
#fi
#[[ $state_proj -eq 1 && $state_mdl -eq 1 && $state_target -eq 1 && $state_output -eq 1 && $state_error_log -eq 1 ]] && execute=1;
}
function prototype {
#===============================================================================
#-- EXECUTE each function as passed in as $1 using the batch system
#===============================================================================
[[ ! -z "$arg_debug" ]] && msg_debug "Entered prototype";
export the_function="${1:-"no argument passed"}";
msg_info "Processing (argument 1) \"${the_function}\".";
#execute a comand and save it to an array
the_results=( $(ls -1 ~) );
#was the comand successful?
status=$?
if [ "${status}" -ne 0 ];
then
error_msg="The environment variable RECON_NEURAL_TRAINING_OUTPUT_DIR (${RECON_NEURAL_TRAINING_OUTPUT_DIR}) points to a directory that doesn't exist. We tried to create it for you but mkdir -p returned a status of (${Status}). Please investigate, aborting execution due to failure to specify a valid output location.";
msg_error "${error_msg}";
msg_emerg "${error_msg}";
fi
for the_result in ${the_results[@]}
do
msg_debug "This file is being processed: ${the_result}.";
done
[[ ! -z "$arg_debug" ]] && msg_debug "Exited prototype";
}
function install_network_tools {
#===============================================================================
#-- Install Network tools necessary to debug
#===============================================================================
[[ ! -z "$arg_debug" ]] && msg_debug "Entered install_network_tools";
banner "Network Tools Installation";
msg_debug "...installing minimal network debugging tools."
for the_tool in ${the_tools[@]}
do
sudo apt install "${the_tool}";
status=$?
if [ "${status}" -ne 0 ];
then
msg_debug "......successfully installed ${the_tool}";
fi
done
[[ ! -z "$arg_debug" ]] && msg_debug "Exited install_network_tools";
echo " ";
}
function layer0 {
#===============================================================================
#-- Variable display and firewall down
#===============================================================================
[[ ! -z "$arg_debug" ]] && msg_debug "Entered layer0";
banner "Variables and Firewall Down";
msg_debug "...establishing target NAME [${target_name}]";
msg_debug "...establishing target IP [${target_ip}]";
if [ -f $command_ufw ];
then
sudo $command_ufw disable;
status=$?;
if [ "${status}" -ne 0 ];
then
msg_debug "......SUCCESS disabled firewall.";
else
msg_warning "......FAIL to disable firewall.";
fi
else
msg_warning "......FAIL, could not find firewall command.";
fi
msg_debug " ";
[[ ! -z "$arg_debug" ]] && msg_debug "Exited layer0";
echo " ";
}
function layer1 {
#===============================================================================
#-- Network device information and status (hardware)
#===============================================================================
[[ ! -z "$arg_debug" ]] && msg_debug "Entered layer1";
banner "Layer1: The Physical Layer";
if [ -f $command_ip ];
then
sudo $command_ip link set "${the_network_device}" up;
sudo $command_ip addr | grep "${the_network_device}";
msg_debug "...${the_network_device} UP";
msg_debug "...${the_network_device} status";
sudo $command_ip -s link show "${the_network_device}"
else
msg_warning "......FAIL, could not find ip (network) command";
fi
if [ -f $command_ethtool ];
then
msg_debug "...${the_network_device} details";
sudo $command_ethtool "${the_network_device}";
else
msg_warning "......FAIL, could not find ethtool (network) command";
fi
[[ ! -z "$arg_debug" ]] && msg_debug "Exited layer1";
echo " ";
}
function layer2 {
#===============================================================================
#-- Data Link Layer
#===============================================================================
[[ ! -z "$arg_debug" ]] && msg_debug "Entered layer2";
banner "Layer2: The data link layer";
if [ -f $command_ip ];
then
sudo $command_ip neighbor show
else
msg_warning "......FAIL, could not find ip (network) command";
fi
[[ ! -z "$arg_debug" ]] && msg_debug "Exited layer2";
echo " ";
}
function layer3 {
#===============================================================================
#-- Routing layer
#===============================================================================
[[ ! -z "$arg_debug" ]] && msg_debug "Entered layer3";
banner "Layer 3: The network/internet layer";
if [ -f $command_ip ];
then
sudo $command_ip -br address show;
else
msg_warning "......FAIL, could not find ip (network) command";
fi
if [ -f $command_ping ];
then
msg_debug "...${command_ping} -c ${the_hops} ${target_ip}";
$command_ping -c "${the_hops}" "${target_ip}";
msg_debug "...${command_ping} -c ${the_hops} ${target_name}";
$command_ping -c "${the_hops}" "${target_name}";
else
msg_warning "......FAIL, could not find ping command";
fi
if [ -f /etc/resolv.conf ];
then
msg_debug "...DNS settings.";
$command_cat /etc/resolv.conf;
else
msg_warning "......FAIL, could not find /etc/resolv.conf";
fi
if [ -f $command_traceroute ];
then
msg_debug "...${command_traceroute} ${the_hops} ${target_ip}";
$command_traceroute -"${the_hops}" "${target_ip}";
msg_debug "...${command_traceroute} ${the_hops} ${target_name}";
$command_traceroute -"${the_hops}" "${target_name}";
else
msg_warning "......FAIL, could not find traceroute command.";
fi
if [ -f $command_ip ];
then
msg_debug "...${command_ip} route show";
sudo $command_ip route show;
else
msg_warning "......FAIL, could not find ip (network) command.";
fi
if [ -f $command_nslookup ];
then
msg_debug "...${command_nslookup} ${target_name}";
sudo $command_nslookup "${target_name}";
else
msg_warning "......FAIL, could not find nslookup command.";
fi
[[ ! -z "$arg_debug" ]] && msg_debug "Exited layer3";
echo " ";
}
function layer4 {
#===============================================================================
#-- Communications (Traffic)
#===============================================================================
[[ ! -z "$arg_debug" ]] && msg_debug "Entered layer4";
banner "Layer 4: The transport layer";
msg_debug "...show all potential data exchanges";
if [ -f $command_netstat ];
then
#sudo ss -tunlp4
sudo $command_netstat -tulnp
else
msg_warning "......FAIL, could not find netstat command.";
fi
[[ ! -z "$arg_debug" ]] && msg_debug "Exited layer4";
echo " ";
}
#*** MAIN ***
############################################################################################################################################
# ▄▄▄▄███▄▄▄▄ ▄████████ ▄█ ███▄▄▄▄
# ▄██▀▀▀███▀▀▀██▄ ███ ███ ███ ███▀▀▀██▄
# ███ ███ ███ ███ ███ ███▌ ███ ███
# ███ ███ ███ ███ ███ ███▌ ███ ███
# ███ ███ ███ ▀███████████ ███▌ ███ ███
# ███ ███ ███ ███ ███ ███ ███ ███
# ███ ███ ███ ███ ███ ███ ███ ███
# ▀█ ███ █▀ ███ █▀ █▀ ▀█ █▀
############################################################################################################################################
function main {
get_date
start_time=$(date +'%s')
msg_info "BEGIN $script_name"
#================================================================
# Argument management
#================================================================
msg_info "Processing arguments."
while getopts "hda:" opt; do
case "$opt" in
d)
arg_debug=1;
;;
#a)
# arg_incoming_argument=${OPTARG};
# ;;
h)
usage
exit 1
;;
:)
msg_debug "Option -$OPTARG requires an argument." >&2
exit 1
;;
\?)
msg_emerg "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift $((OPTIND-1))
validate_program
if [ "${execute}" -eq 1 ];
then
msg_info "${VERSION_NAME} ${VERSION_MAJOR}.${VERSION_MINOR}"
[[ ! -z "$arg_debug" ]] && msg_debug "Debugging selected and tested for."
msg_info "...priming sudo with an ls, supply your password";
the_result=$(sudo $command_ls);
#prototype "${arg_incoming_argument}"
install_network_tools
layer0
layer1
layer2
layer3
layer4
end_time=$(date +%s);
msg_info "Execution time for ${script_name} was $((end_time - start_time)) s.";
get_date;
msg_info "END ${script_name}";
else
usage
echo " "
msg_emerg "There was a problem with argument passing, an argument was not compliant. Exiting..."
fi
}
main "${@}"