Skip to content

Commit e9d2b4e

Browse files
authored
Merge pull request #21 from elreydetoda/develop
closed #11 and releasing v0.0.1
2 parents 90aa4e5 + eeb67a7 commit e9d2b4e

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![CodeFactor](https://www.codefactor.io/repository/github/elreydetoda/packer-kali_linux/badge)](https://www.codefactor.io/repository/github/elreydetoda/packer-kali_linux)
55
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/17c18e4c56b4477d8a21d10abbd94837)](https://app.codacy.com/app/unc741/packer-kali_linux?utm_source=github.com&utm_medium=referral&utm_content=elreydetoda/packer-kali_linux&utm_campaign=Badge_Grade_Dashboard)
66

7-
If the build status if failing please checkout [pinned issues](https://github.com/elreydetoda/packer-kali_linux/issues), and if there are no pinned issues then please file a detailed bug issue (template comming soon)
7+
If the build status if failing please checkout [pinned issues](https://github.com/elreydetoda/packer-kali_linux/issues), and if there are no pinned issues then please file a detailed bug issue (template comming soon).
88

99
## Presentation
1010

ci/packer_build.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env bash
22

3-
set -euo pipefail
3+
# normal mode
4+
# set -euo pipefail
5+
# debug mode
6+
set -exuo pipefail
47

58
curl="curl -sSL"
69

@@ -123,8 +126,10 @@ retrieve(){
123126
if ssh "${2}" -t "[ -f \"${1}\" ]" ; then
124127
scp "${2}":"${1}" ${ARTIFACTS_DIR}
125128
else
126-
printf "Couldn't find: %s\n" "${1}"
129+
# msg="Couldn't find: ${1}"
130+
# printf '%s\n' "${1}"
127131
delete_server
132+
# echo "exiting"
128133
exit 1
129134
fi
130135
}
@@ -137,6 +142,9 @@ send_text(){
137142
--data-urlencode phone="${PERSONAL_NUM}" \
138143
--data-urlencode message="${1}" \
139144
-d key="${TEXTBELT_KEY}"
145+
# putting echo here so there is a new line appended to output to allow
146+
# for easier readability for commands that follow
147+
echo
140148
fi
141149
}
142150

@@ -147,6 +155,9 @@ wait_to_finish(){
147155
status_file="${project_folder}/status.txt"
148156
# TODO: check if glob works for scp
149157
logs="${project_folder}/packer.log"
158+
output_dir="${project_folder}"
159+
outputs=("red-virtualbox.box")
160+
150161
too_much_time=120
151162

152163
if [[ $# -eq 3 ]] ; then
@@ -170,7 +181,6 @@ wait_to_finish(){
170181
if [[ ${minutes_passed} -ge ${too_much_time} ]] ; then
171182
msg="It took too long...so it failed...specifically: ${minutes_passed}"
172183
echo "$msg"
173-
send_text "${msg}"
174184
delete_server
175185
exit 1
176186
fi
@@ -181,6 +191,13 @@ wait_to_finish(){
181191
msg='Build succeeded!'
182192
echo "${msg}"
183193
send_text "${msg}"
194+
195+
for outputz in "${outputs[@]}" ; do
196+
current_vagrant_box="${output_dir}/${outputz}"
197+
# print 'Getting %s' "${current_vagrant_box}"
198+
retrieve "${current_vagrant_box}" "${ssh_args}"
199+
done
200+
184201
delete_server
185202
exit 0
186203
else
@@ -238,7 +255,9 @@ check_post(){
238255
}
239256

240257
delete_server(){
241-
echo "Deleting server: ${PACKET_SERVER_ID}"
258+
msg="Deleting server: ${PACKET_SERVER_ID}"
259+
echo "$msg"
260+
send_text "$msg"
242261
$curl -X DELETE \
243262
"${packet_base_url}/devices/${PACKET_SERVER_ID}" \
244263
-H 'Content-Type: application/json' \
@@ -307,7 +326,7 @@ main(){
307326
# start_build ${SERVER_IP} 'virtualbox'
308327

309328
echo "Ready for delete"
310-
# delete_server ${PACKET_SERVER_ID}
329+
delete_server ${PACKET_SERVER_ID}
311330

312331
}
313332

0 commit comments

Comments
 (0)