Adding self installation command for fabrica
This commit is contained in:
51
.packer/provisioning/common.sh
Normal file
51
.packer/provisioning/common.sh
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# downloadArchive
|
||||
# ${1} : The download url
|
||||
# ${2} : the checksum
|
||||
# ${3} : the filename of download target
|
||||
# ${4} : the checksum command to use (default sha256sum)
|
||||
#
|
||||
downloadArchive(){
|
||||
url=${1}
|
||||
sum=${2}
|
||||
archive=${3}
|
||||
if [ -n ${4} ]
|
||||
then
|
||||
checkCmd=${4}
|
||||
else
|
||||
checkCmd="sha256sum"
|
||||
fi
|
||||
|
||||
wget -q ${url}
|
||||
set +e
|
||||
echo "${sum} ${archive}" | ${checkCmd} -cs
|
||||
if [ ${?} ]
|
||||
then
|
||||
set -e
|
||||
return 0
|
||||
else
|
||||
set -e
|
||||
return 2
|
||||
fi
|
||||
}
|
||||
|
||||
extractArchiveXZ(){
|
||||
source=${1}
|
||||
destination=${2}
|
||||
cmd="tar xzvf"
|
||||
|
||||
if [ ! -d ${destination} ]
|
||||
then
|
||||
mkdir -p ${destination}
|
||||
fi
|
||||
${cmd} ${source} -C ${destination}
|
||||
return ${?}
|
||||
}
|
||||
|
||||
cleanUpImage(){
|
||||
rm -rf /var/cache/apk/*
|
||||
rm -rf /tmp/*
|
||||
rm -rf /root/.ssh
|
||||
}
|
Reference in New Issue
Block a user