-
Notifications
You must be signed in to change notification settings - Fork 2
/
modify-globalblacklist.sh
executable file
·79 lines (72 loc) · 2.52 KB
/
modify-globalblacklist.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
#!/bin/bash
# Write Build Number into globalblacklist.conf
# Created by: https://github.com/mitchellkrogza ([email protected])
# Copyright: Mitchell Krog - https://github.com/mitchellkrogza
# Start time of script generation
start=$(date +%s.%N)
versionyear=$(date +%Y)
versionmonth=$(date +%m)
#MY_GIT_TAG=V2.2017.07.$TRAVIS_BUILD_NUMBER
MY_GIT_TAG=V3.$versionyear.$versionmonth.$TRAVIS_BUILD_NUMBER
# Temporary database files we create
_inputdbA=/tmp/lastupdated.db
_inputdbB=/tmp/gentime.db
# Declare Nginx template and temp variables
_nginx=/home/travis/build/mitchellkrogza/Travis-CI-Nginx-for-Testing-Nginx-Configuration/globalblacklist.conf
_tmpnginxA=tmpnginxA
_tmpnginxB=tmpnginxB
# Start and End Strings to Search for to do inserts into template
_startmarker="### Version Information #"
_endmarker="### Version Information ##"
#_startgen="### Generated in"
#_endgen="### End Generated in"
# PRINT VERSION INFORMATION INTO GLOBALBLACKLIST FILE
# ***************************************************
LASTUPDATEIFS=$IFS
IFS=$'\n'
now="$(date)"
end=$(date +%s.%N)
echo $_startmarker >> $_tmpnginxA
runtime=$(python -c "print(${end} - ${start})")
printf "############################################\n### Version: "$MY_GIT_TAG"\n### Updated: "$now"\n### Generated In: "$runtime" seconds\n############################################\n" >> $_tmpnginxA
echo $_endmarker >> $_tmpnginxA
IFS=$LASTUPDATEIFS
mv $_tmpnginxA $_inputdbA
ed -s $_inputdbA<<\IN
1,/### Version Information #/d
/### Version Information ##/,$d
,d
.r /home/travis/build/mitchellkrogza/Travis-CI-Nginx-for-Testing-Nginx-Configuration/globalblacklist.conf
/### Version Information #/x
.t.
.,/### Version Information ##/-d
#,p
#,p used to print output replaced with w below to write
w /home/travis/build/mitchellkrogza/Travis-CI-Nginx-for-Testing-Nginx-Configuration/globalblacklist.conf
q
IN
rm $_inputdbA
# End time of script generation
# *****************************
#GENTIME=$IFS
#IFS=$'\n'
#end=$(date +%s.%N)
#runtime=$(python -c "print(${end} - ${start})")
#echo $_startgen >> $_tmpnginxB
#printf "### "$runtime" seconds\n" >> $_tmpnginxB
#echo $_endgen >> $_tmpnginxB
#IFS=$GENTIME
#mv $_tmpnginxB $_inputdbB
#ed -s $_inputdbB<<\IN
#1,/### Generated in/d
#/### End Generated in/,$d
#,d
#.r /home/travis/build/mitchellkrogza/Travis-CI-Nginx-for-Testing-Nginx-Configuration/globalblacklist.conf
#/### Generated in/x
#.t.
#.,/### End Generated in/-d
#w /home/travis/build/mitchellkrogza/Travis-CI-Nginx-for-Testing-Nginx-Configuration/globalblacklist.conf
#q
#IN
#rm $_inputdbB
exit 0