-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ksh
executable file
·54 lines (51 loc) · 2.08 KB
/
build.ksh
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
#!/usr/bin/env ksh
################################################################################
#
# PURPOSE
# Zip terraform resource code for OCI Resource Manager
# UPDATES
# v1.0 lathouwj - Initial Release
#
################################################################################
#------------------------------------------------------------------------------
# GLOBAL/DEFAULT VARS
#------------------------------------------------------------------------------
typeset -r ARCH_DIR=$(pwd)
typeset -r BUILD_NAME="${ARCH_DIR##*\/}.zip"
typeset -r BUILD_DIR=$(mktemp -d /tmp/${BUILD_NAME}-XXXXX)
typeset -i RC=0
#------------------------------------------------------------------------------
# Main
#------------------------------------------------------------------------------
print -- "#####################################################################"
print -- "# Creating ${BUILD_NAME} ${ARCH_DIR}"
print -- "#####################################################################"
# Cleanup Old Build
rm ${ARCH_DIR}/${BUILD_NAME} 2>/dev/null
print -- "--> Creating Stack in ${BUILD_DIR}"
cd ${BUILD_DIR}
print -- "--> Copying Terraform stack from ${ARCH_DIR} to ${BUILD_DIR}"
rsync --stats -apxr $ARCH_DIR/ \
--exclude=assets --exclude=README.md --exclude=sonar-project.properties \
--exclude=.git* --exclude=.terraform* --exclude=*.pem --exclude=*.zip \
--exclude=terraform.tfstate* --exclude=terraform.tfvars* .
print -- "--> Creating ZIP archive"
rm -rf ${BUILD_DIR}images
zip -r ${BUILD_DIR}/${BUILD_NAME} * --exclude build.ksh
print -- "--> Copying Build to Repository"
cp ${BUILD_DIR}/${BUILD_NAME} ${ARCH_DIR}
print -- "--> Committing the Build"
cd ${ARCH_DIR}
print -- "--> Cleaning up build directory"
rm -rf $BUILD_DIR
if [[ -f ${ARCH_DIR}/${BUILD_NAME} ]]; then
print -- "#####################################################################"
print -- "# ${ARCH_DIR}/${BUILD_NAME} Created"
print -- "#####################################################################"
#git add ${BUILD_NAME}
#git commit -m "Updating ORM Build zip"
else
print -- "Unable to create build"
RC=1
fi
exit $RC