forked from Hurence/logisland
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-version.sh
executable file
·73 lines (53 loc) · 1.66 KB
/
update-version.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
#!/usr/bin/env bash
# update_version - A script to update the logisland version
## declare an array variable
declare -a extension=(".rst" "pom.xml" ".html" ".yml" ".txt" ".md" "SparkJobLauncher.java" "StreamProcessingRunner.java")
function usage
{
echo "usage: update_version -o old_version -n new_version -d"
}
old_version=
new_version=
dry_run=false
while [ "$1" != "" ]; do
case $1 in
-o | --old_version ) shift
old_version=$1
;;
-n | --new_version ) shift
new_version=$1
;;
-d | --dry_run ) dry_run=true
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
if [ -z "${old_version}" ]
then
echo "Please provide old version parameter"
usage
exit 1
fi
SED_REPLACE="s/$old_version/$new_version/g"
## now loop through the above array
if [ "$dry_run" = true ]; then
grep -r -n -i -l \
--exclude-dir=\*{.idea,.git,target,nltk} \
--exclude=\*{.iml,.csv,.dat,.svg,.pdf,.lock,*.log*,.json,.pcap} "$old_version" .
else
if [ -z "${new_version}" ]
then
echo "Please provide new version parameter or use dry run mode with -d"
usage
exit 1
fi
for i in `grep -r -n -i -l --exclude-dir=\*{.idea,.git,target,nltk} --exclude=\*{.iml,.csv,.dat,.svg,.pdf,.lock,*.log*,.json,.pcap} "$old_version" .` ; do
echo $i;
sed -i '' "$SED_REPLACE" $i
done
fi