-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-shows.sh
executable file
·66 lines (43 loc) · 1.06 KB
/
custom-shows.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
#!/bin/bash
#Manos Kartsonakis
#Script for custom show commands
#versioning - comments to git!
#Keep starting time in a variable:
starting=`date`
startingts=`date "+%s"`
#Check for lock
tmpdir=/tmp/custom-shows
lockfile=$tmpdir/custom-shows.lock
if ! [ -d $tmpdir ]; then
/bin/mkdir $tmpdir
fi
if [ -f $lockfile ]; then
echo "ERROR lock file exists, aborting"
exit 1
else
trap "/bin/rm -f $lockfile; exit" INT TERM EXIT
echo $starting > $lockfile
fi
#Check if required directories exist and if not create them.
bckfolder="./"
if ! [ -d $bckfolder ]; then
echo "ERROR $bckfolder does not exist"
exit 1
fi
for vendor in cisco; do
if [ ! -d $bckfolder/$vendor ]; then
mkdir $bckfolder/$vendor
fi
done
echo "Parent directories OK"
#Running custom script for given devices:
#Get device list and run expects.
cat $1 | sort -u | xargs -i -P 20 ./customcase.sh {}
#Keep ending time in a variable:
ending=`date`
endingts=`date "+%s"`
#Finito...
echo "Custom-shows started at $starting"
echo "Completed at $ending"
/bin/rm -f $lockfile
trap - INT TERM EXIT