forked from Arachni/build-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_all_and_push.sh
executable file
·104 lines (77 loc) · 2.32 KB
/
build_all_and_push.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
#!/usr/bin/env bash
#
# Copyright 2010-2017 Sarosys LLC <http://www.sarosys.com>
source `dirname $0`/lib/setenv.sh
targets=`ls "$(dirname "$(readlink_f "${0}")")"/targets/*.sh`
root="$(dirname "$(readlink_f "${0}")")"
mkdir -p `build_dir`
cd `build_dir`
if ls *.lock > /dev/null 2>&1; then
echo "Found a lock file, another build process is in progress or the dir is dirty.";
exit 1
fi
if ls *.pid > /dev/null 2>&1; then
echo "Found a pid file, another build process is in progress or the dir is dirty.";
exit 1
fi
# Make sure the local Git repository of the Arachni Framework is up to date.
if [ -d $(framework_repository_path) ]; then
echo "Updating local Git repo: $(framework_repository_path)"
cd $(framework_repository_path)
git pull --all
cd - > /dev/null 2>&1
echo
fi
rm -f $(package_patterns)
rm -f *.log
echo "Building packages, this can take a while; to monitor the progress of the:"
for target in $targets; do
name=$(basename ${target%.sh})
logfile="$name.log"
rm -f $logfile
echo " * $name build: tail -f `readlink_f $logfile`"
done
echo
echo 'You better go grab some coffee now...'
# start building for the targets
for target in $targets; do
name=$(basename ${target%.sh})
logfile="$name.log"
bash -c "touch ${name}_build.lock && \
bash $root/build_target.sh $name 2>> $logfile 1>> $logfile ;\
rm ${name}_build.lock" &
echo $! > $name.pid
done
# wait for the processes to start
for target in $targets; do
name=$(basename ${target%.sh})
while [ ! -e "${name}_build.lock" ]; do sleep 0.1; done
done
# and now wait for them to finish
for target in $targets; do
name=$(basename ${target%.sh})
while [ -e "${name}_build.lock" ]; do sleep 0.1; done
echo " * $name package ready"
done
echo
echo -n 'Removing PID files'
rm *.pid
echo ' - done.'
echo
echo 'Pushing to server, this can also take a while...'
MAX_RETRIES=50
i=0
# Set the initial return value to failure
false
while [ $? -ne 0 -a $i -lt $MAX_RETRIES ]; do
sleep 5
i=$(($i+1))
rsync -v --archive --human-readable --progress --partial \
--executability --compress --stats --timeout=60 \
$(package_patterns) $(rsync_destination)
done
if [ $i -eq $MAX_RETRIES ]; then
echo "Hit maximum number of retries, giving up."
fi
echo
echo 'All done.'