This file is indexed.

/usr/sbin/autosupport is in asterisk 1:13.14.1~dfsg-2+deb9u4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
#!/bin/sh
#
# Autosupport Version 2.1.3
# Collect support information
#
# Copyright (C) 2005-2016, Digium, Inc.
#
# Written by John Bigelow (support@digium.com)
#            Charles Moye (cmoye@digium.com)
#            Trey Blancher (trey@digium.com)
#
# Distributed under the terms of the GNU General Public
# License
#
# usage:
# autosupport [prefix]
# ARGUMENTS:
# prefix - Prefix to tarball. (Referenced as $1)
#      Example: autosupport <Your Digium Technical Support Ticket number>

# Ensure the PATH variable includes '/usr/sbin' and '/sbin'
PATH=/usr/sbin:/sbin:${PATH}

DATE_STAMP=$(date +%F)
OUTPUT_FILE=digiuminfo.txt
TARBALL_OUTPUT_FILE="digium-info_${DATE_STAMP}.tar"
VAR_LIB_LIST_FILE="list-of-varlibasterisk.txt"
FILE_PREFIX=
FOLDER_PREFIX="${HOME}/"
files="n";
NONINTERACTIVE=0


# If a prefix is specified on command-line, add it.
if (set -u; : $1) 2> /dev/null
then
  case "$1" in
  -h | --help)
    echo
    echo "Digium autosupport script"
    echo "Copyright (C) 2005-2016, Digium, Inc."
    echo "Licensed under the terms of the GNU General Public License"
    echo
    echo "usage: autosupport [prefix]"
    echo "Valid Options:"
    echo "   [prefix]			Prefix to apply to output files"
    echo "				May be your existing Digium Technical Support Ticket ID"
    echo "   -n, --non-interactive	Run without requiring user input"
    echo "   -h, --help			Show help about options"
    echo
    echo "Example:"
    echo "    autosupport XXXXXXXX"
    echo "Generates:"
    echo "    XXXXXXXX_${OUTPUT_FILE}"
    echo "    XXXXXXXX_${TARBALL_OUTPUT_FILE}"
    echo
    exit
    ;;
  -n | --non-interactive)
    FILE_PREFIX=
    NONINTERACTIVE=1
    ;;
  *)
    FILE_PREFIX="${FILE_PREFIX}${1}_";
    ;;
  esac
fi

MYUID=$(id -u);

if [ $MYUID -ne  0 ]; then
  echo "You must be root to run this."
  exit 1
fi

SUPPORTED_MODULES="wcb4xxp wct4xxp wctc4xxp wctdm wctdm24xxp wcte11xp wcte12xp"
RELATED_MODULES="$SUPPORTED_MODULES dahdi_dummy dahdi_transcode dahdi_vpmadt032_loader";

OUTPUT_FILE="${FILE_PREFIX}${OUTPUT_FILE}"
TARBALL_OUTPUT_FILE="${FILE_PREFIX}${TARBALL_OUTPUT_FILE}"
VAR_LIB_LIST_FILE="${FILE_PREFIX}${VAR_LIB_LIST_FILE}"

OUTPUT="${FOLDER_PREFIX}${OUTPUT_FILE}"
TARBALL_OUTPUT="${FOLDER_PREFIX}${TARBALL_OUTPUT_FILE}"
VAR_LIB_LIST="${FOLDER_PREFIX}${VAR_LIB_LIST_FILE}"

# Done with setup, now start gathering information.

# function not implemented yet
determine_paths()
{
  ASTERISK_PROCESS=$(ps -o cmd -C asterisk | grep asterisk 2> /dev/null)
echo "detected process: $ASTERISK_PROCESS";
  # split on whitespace? or use sed/awk to parse
  # get first arg which will be path to Asterisk binary - add this to PATH
  # look for a '-C' if that is present, get the arg after it, and make the tarball collect that directory
  ## in addition to /etc/asterisk/ or instead of it?
}

collect_digiuminfo()
{
# Delete existing OUTPUT
[ -f $OUTPUT ] && rm -rf $OUTPUT

# Sanity Checks
echo "------------------" >> $OUTPUT;
echo "Sanity" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
md5sum $0 >> $OUTPUT;
grep "Autosupport Version" $0 | head -n1 >> $OUTPUT
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "Working";

echo "------------------" >> $OUTPUT;
echo "UPTIME : uptime" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
uptime >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "MEMORY : free" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
free >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "KERNEL VERSION : uname -a" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
uname -a >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "VERSION INFO : cat /proc/version" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
cat /proc/version >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "CMDLINE INFO : cat /proc/cmdline" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
cat /proc/cmdline >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."


if [ -d /sys/module/dahdi ]; then
  echo "------------------" >> $OUTPUT
  echo "dahdi version:" >> $OUTPUT
  echo "------------------" >> $OUTPUT
  echo "/sys/module/dahdi/version: " >> $OUTPUT
  cat /sys/module/dahdi/version 2> /dev/null >> $OUTPUT
  echo "" >> $OUTPUT;
  echo -n "."
fi

echo "------------------" >> $OUTPUT;
echo "DAHDI TOOLS : dahdi_cfg --help" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
dahdi_cfg --help 2>&1 | grep "Version" >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "DAHDI HARDWARE : dahdi_hardware" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
dahdi_hardware >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;

echo "------------------" >> $OUTPUT;
echo "ASTERISK INFO : asterisk -V" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
echo "asterisk -V:" >> $OUTPUT;
asterisk -V >> $OUTPUT;
echo >> $OUTPUT;
# Add check to see if asterisk is running.
if [ -e /var/run/asterisk.ctl ] || [ -e /var/run/asterisk/asterisk.ctl ]; then
  for command in "core show version" "pri show version" "dahdi show version" \
      "pjsip show version" "pjsip show buildopts" "pjproject show buildopts" \
      "core show translation" \
      "core show uptime" "core show settings" "core show sysinfo" "core show channels" \
      "pri show spans" "dahdi show status" "dahdi show channels" "dahdi show channel 1" \
      "pjsip show endpoints" "pjsip show registrations" "pjsip list channels" \
      "sip show peers" "sip show registry" "sip show channels" "sip show subscriptions" "sip show settings" \
      "show g729" "g729 show version" "g729 show licenses" "g729 show hostid" \
      "digium_phones show version" "digium_phones show alerts" "digium_phones show applications" \
      "digium_phones show firmwares" "digium_phones show lines" "digium_phones show networks" \
      "digium_phones show phones" "digium_phones show sessions" "digium_phones show settings" \
      "digium_phones show translations" ;
  do
    echo "asterisk -rx \"$command\"" >> $OUTPUT;
    asterisk -rx "$command" >> $OUTPUT;
    echo >> $OUTPUT;
    echo -n "."
  done
  echo >> $OUTPUT;
fi


for type in alerts applications firmwares lines networks phones translations; 
do 
	echo "------------------" >> $OUTPUT; 
	echo "DIGIUM PHONE: $type " >> $OUTPUT; 
	echo "------------------" >> $OUTPUT; 
	TEMP=$(asterisk -rx "digium_phones show $type"); 
	if [ "$type" = "lines" ];
	then
		NUM=$(echo $TEMP | tail -n 1 | awk -F' ' '{print $(NF-4)}');
		if [ $NUM -gt 0 ];
		then
			for l in $(echo $TEMP | sed 's/^--- [[:alpha:]]\+ --- //; 
				s/Lines \(Un-\)\?Mapped to Phones --- //g; 
				s/ Internal//g; 
				s/---- [a-zA-Z0-9 ]\+ ----$//;
				s/--- //g');
			do
				asterisk -rx "digium_phones show line $l" >> $OUTPUT;                                                                      
				echo "--------" >> $OUTPUT;                                                                                                                         
				echo >> $OUTPUT; 
			done
		else
			echo "No configurations of type $type..." >> $OUTPUT;
			echo >> $OUTPUT;
		fi;
	elif [ "$type" = "firmwares" ];
	then
		for f in $(echo $TEMP | sed 's/--- Configured Firmware Options --- //');
		do
			asterisk -rx "digium_phones show firmware $f" >> $OUTPUT;
			echo "--------" >> $OUTPUT;                                                                                                                         
			echo >> $OUTPUT; 
		done
	elif [ "$type" = "translations" ];
	then
		for t in $(echo $TEMP | sed 's/--- Translation tables ---//');
		do
			asterisk -rx "digium_phones show translation $t" 
		done
	else
		NUM=$(echo $TEMP | tail -n 1 | awk -F' ' '{print $(NF-3)}'); 
		if [ $NUM -gt 0 ]; 
		then   
			for t in $(echo $TEMP | sed 's/^--- [[:alpha:]]\+ --- //; 
																	 s/---- [a-zA-Z0-9 ]\+ ----$//
																	 s/---- Digium Phones ---- //'); 
			do 
				asterisk -rx "digium_phones show $(echo $type | sed 's/s\b//') $t" >> $OUTPUT; 
				echo "--------" >> $OUTPUT; 
				echo >> $OUTPUT; 
			done; 
		else 
			echo "No configurations of type $type..." >> $OUTPUT;
			echo >> $OUTPUT;
		fi;
	fi;
done;
echo >> $OUTPUT;


echo "------------------" >> $OUTPUT;
echo "OTHER INFO : cat /etc/*{issue,release,version}*" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
for file in $(ls /etc/*issue* /etc/*release* /etc/*version* \
  /etc/*motd* /etc/asterisknow-version /dev/zap/ /dev/dahdi/ \
  2> /dev/null); do
  if [ -f $file ]; then
    echo "$file:" >> $OUTPUT;
    cat $file >> $OUTPUT;
    echo >> $OUTPUT;
    echo -n "."
  fi
done
echo >> $OUTPUT;

echo "------------------" >> $OUTPUT;
echo "TOP : top -bn1" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
top -bn1 >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "RUNNING PROCESSES : ps aux" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
ps aux >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "INTERRUPTS : cat /proc/interrupts" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
cat /proc/interrupts >> $OUTPUT;
echo -n "."
sleep 2;
echo "---------- sleep(2) ----------" >> $OUTPUT;
cat /proc/interrupts >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "DAHDI SCAN : dahdi_scan" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
dahdi_scan >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "----------------------------" >> $OUTPUT;
echo "CAT OF DAHDI CHANNELS : cat /proc/dahdi/" >> $OUTPUT;
echo "----------------------------" >> $OUTPUT;
if [ -d /proc/dahdi/ ]; then
  for file in $(ls /proc/dahdi/ 2> /dev/null); do
    echo "----------------------------" >> $OUTPUT;
    echo "/proc/dahdi/$file:" >> $OUTPUT;
    cat /proc/dahdi/$file >> $OUTPUT;
    echo >> $OUTPUT;
    echo -n "."
  done
fi
echo >> $OUTPUT;

echo "------------------" >> $OUTPUT;
echo "DMESG OUTPUT : dmesg" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
dmesg >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "LOADED MODULES : lsmod" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
lsmod >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

# Grab the parameters for each module
for mod in $SUPPORTED_MODULES; do
  if [ -d /sys/module/$mod ]; then
    echo "------------------" >> $OUTPUT
    echo "$mod parameters" >> $OUTPUT
    echo "------------------" >> $OUTPUT
    echo "/sys/module/$mod/parameters:" >> $OUTPUT
    for param in $(ls /sys/module/$mod/parameters/ /sys/module/$mod/ 2> /dev/null); do
      if [ -f /sys/module/$mod/parameters/$param ]; then
        echo -n "$param:  " >> $OUTPUT
        cat /sys/module/$mod/parameters/$param 2> /dev/null >> $OUTPUT
      elif [ -f /sys/module/$mod/$param ]; then
        # Handle Zaptel doing it differently
        echo -n "$param:  " >> $OUTPUT
        cat /sys/module/$mod/$param 2> /dev/null >> $OUTPUT
      fi
      echo -n "."
    done
    echo >> $OUTPUT
  fi
done

echo "------------------------" >> $OUTPUT;
echo "DAHDI MODULE INFO : modinfo" >> $OUTPUT;
echo "------------------------" >> $OUTPUT;
for file in $(ls /lib/modules/$(uname -r)/dahdi/*.ko \
  /lib/modules/$(uname -r)/dahdi/*/*.ko\
  /lib/modules/$(uname -r)/extra/*.ko \
  /lib/modules/$(uname -r)/extra/*/*.ko \
  /lib/modules/$(uname -r)/misc/*.ko \
  /lib/modules/$(uname -r)/misc/*/*.ko 2> /dev/null); do
  if [ -f $file ]; then
    echo "------------------------" >> $OUTPUT;
    modinfo $file >> $OUTPUT;
    echo >> $OUTPUT;
    echo -n "."
  fi
done
echo "------------------------" >> $OUTPUT;
echo >> $OUTPUT;

echo "------------------" >> $OUTPUT;
echo "PCI LIST : lspci -vvvb" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
lspci -vvvb >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "PCI LIST(no lookup) : lspci -vvvbn" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
lspci -vvvbn >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "CPU INFO : cat /proc/cpuinfo" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
cat /proc/cpuinfo >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "----------------------" >> $OUTPUT;
echo "VPM FIRMWARE INSTALLED : ls -la /lib/firmware" >> $OUTPUT;
echo "----------------------" >> $OUTPUT;
$(ls -la /lib/firmware 2> /dev/null >> $OUTPUT);
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "NETWORK INFO : route -n; iptables -L; ifconfig -a" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
route -n 2> /dev/null >> $OUTPUT;
echo >> $OUTPUT;
echo "------------------" >> $OUTPUT;
iptables -L 2> /dev/null >> $OUTPUT;
echo >> $OUTPUT;
echo "------------------" >> $OUTPUT;
ifconfig -a 2> /dev/null >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "DMIDECODE : dmidecode" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
dmidecode >> $OUTPUT;
echo >> $OUTPUT;
echo >> $OUTPUT;
echo -n "."

echo "------------------" >> $OUTPUT;
echo "KERNEL CONFIG : cat /path/.config" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
for file in /lib/modules/$(uname -r)/build/.config /usr/src/linux/.config; do
  if [ -f $file ]; then
    echo "------------------" >> $OUTPUT;
    echo "$file:" >> $OUTPUT;
    cat $file >> $OUTPUT;
    echo >> $OUTPUT;
    echo -n "."
  fi
done
echo >> $OUTPUT;

FIRMWARE_DIR=`grep firmware_package_directory /etc/asterisk/res_digium_phone.conf|sed 's/;.*$//;'|grep firmware|sed 's/firmware_package_directory=//;'`;
if [ `echo $FIRMWARE_DIR|egrep -v '^$'|wc -l` -eq "0" ]
then
  FIRMWARE_DIR="/var/www/firmware_package_directory"
fi
echo "------------------" >> $OUTPUT;
echo "FIRMWARE LISTING: ls -al $FIRMWARE_DIR" >> $OUTPUT;
echo "------------------" >> $OUTPUT;
ls -al $FIRMWARE_DIR >> $OUTPUT;
echo >> $OUTPUT;

FIRMWARE_URLS=`grep file_url_prefix /etc/asterisk/res_digium_phone.conf|sed 's/;.*$//;'|grep file|sed 's/file_url_prefix=//;'`;
for FIRMWARE_URL in $FIRMWARE_URLS; do
  echo "------------------" >> $OUTPUT;
  echo "REMOTE FIRMWARE LISTING: wget $FIRMWARE_URL" >> $OUTPUT;
  echo "------------------" >> $OUTPUT;
  wget "$FIRMWARE_URL" -O- 2>/dev/null >> $OUTPUT;
  echo >> $OUTPUT;
done

echo "done!"
}

collect_var_lib_list()
{
  # Delete existing VAR_LIB_LIST
  [ -f $VAR_LIB_LIST ] && rm -rf $VAR_LIB_LIST
  DIR_LISTING="/var/lib/asterisk/"
  if [ -d /var/lib/digium ]; then
    DIR_LISTING="/var/lib/digium/ ${DIR_LISTING}"
  fi
  if [ -d /usr/lib/asterisk/modules/ ]; then
    DIR_LISTING="/usr/lib/asterisk/modules/ ${DIR_LISTING}"
  fi
  echo "ls -1aAR $DIR_LISTING > $VAR_LIB_LIST"
  $(ls -1aR ${DIR_LISTING} | sed -e '/^\.\.*$/d' > $VAR_LIB_LIST);
}

collect_config_backup()
{
  collect_var_lib_list
  # Include the /etc/asterisk directory, modprobe.conf, and the modprobe.d directory
  TAR_FILES="/etc/asterisk/ /etc/modprobe.*"

  # Check if any Asterisk licenses are installed
  # G.729, Fax, ABE, Cepstral, Skype, etc.
  if [ -d /var/lib/asterisk/licenses/ ]; then
    TAR_FILES="$TAR_FILES /var/lib/asterisk/licenses/*"
  fi

  # Check if any Digium licenses are installed
  # HPEC
  if [ -d /var/lib/digium/licenses/ ]; then
    TAR_FILES="$TAR_FILES /var/lib/digium/licenses/*"
  fi

  # Check if DAHDI is installed
  if [ -d /etc/dahdi ]; then
    TAR_FILES="$TAR_FILES /etc/dahdi*"
  fi

  # Grab the dahdi init scripts, in case they have been modified
  if [ -f /etc/init.d/dahdi ]; then
    TAR_FILES="$TAR_FILES /etc/init.d/dahdi"
  fi

  # Check for fxotune.conf
  if [ -f /etc/fxotune.conf ]; then
    TAR_FILES="$TAR_FILES /etc/fxotune.conf*"
  fi

  # Check for misdn-init.conf
  if [ -f /etc/misdn-init.conf ]; then
    TAR_FILES="$TAR_FILES /etc/misdn-init.conf*"
  fi

  # Check for digiuminfo.txt
  if [ -f $HOME/$OUTPUT_FILE ]; then
    TAR_FILES="$TAR_FILES $OUTPUT_FILE"
  fi

  # Check for asterisk listing
  if [ -f $VAR_LIB_LIST ]; then
    TAR_FILES="$TAR_FILES $VAR_LIB_LIST_FILE"
  fi

  # Collect System Log Files
  if [ -f /var/log/dmesg ]; then
    TAR_FILES="$TAR_FILES /var/log/dmesg"
  fi
  if [ -f /var/log/messages ]; then
    TAR_FILES="$TAR_FILES /var/log/messages"
  fi
  if [ -f /var/log/syslog ]; then
    TAR_FILES="$TAR_FILES /var/log/syslog"
  fi

  [ -f $TARBALL_OUTPUT ] && rm -rf $TARBALL_OUTPUT
  [ -f $TARBALL_OUTPUT.gz ] && rm -rf $TARBALL_OUTPUT.gz

  echo "tarring: tar -chvf ${TARBALL_OUTPUT} $TAR_FILES"
  cd $HOME && tar -chvf $TARBALL_OUTPUT $TAR_FILES
  echo "gzipping $TARBALL_OUTPUT"
  gzip $TARBALL_OUTPUT
}

collect()
{
  echo "This may take up to half a minute to run. Please be patient."
  collect_digiuminfo;
  collect_config_backup;

  # ensure the output was written
  if [ -f $TARBALL_OUTPUT.gz ]; then
    clear;
    echo;
    echo;
    echo "Tarball has been stored to:"
    echo "$TARBALL_OUTPUT.gz"
    echo "Please send this file to an email case you already"
    echo "have open with Digium Tech Support."
  else
    echo;
    echo;
    echo "An error has occurred in capturing information."
    echo "$TARBALL_OUTPUT.gz was not found."
    echo;
    echo "Please investigate your system, and send the output"
    echo "above to your Digium Technical Support Ticket."
  fi
}

clear;

if [ $NONINTERACTIVE -eq 1 ]; then
  collect;
else
  echo
  echo "This script will try to collect the following pieces of"
  echo "information from your system."
  echo
  echo "1. Information about your system such as:"
  echo "pci listing, dmesg, running processes, and kernel version"
  echo
  echo "2. A backup of elements of your configuration such as:"
  echo "asterisk config files, license files, loaded dahdi module"
  echo "parameters, and other asterisk/dahdi related files."
  echo
  echo "Collect this information [y/n] ? "
  read files;

  if [ "$files" = "y" ] || [ "$files" = "yes" ]; then
    collect;
  else
    clear;
    echo;
    echo "User selected not to continue."
  fi
fi
exit