Skip to content
Snippets Groups Projects
Commit 13f7b996 authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci
Browse files

build-install-package: Improved/added some comments, messages and the code

parent e4902a3f
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA. # USA.
AGENT_FILES="./agent-files" AGENT_FILES="./agent-files"
BOOTSTRAP="bootstrap-install" BOOTSTRAP="bootstrap-install"
INEP=$1 INEP=$1
...@@ -37,15 +36,18 @@ test "$3" = '""' || PPORT=$3 ...@@ -37,15 +36,18 @@ test "$3" = '""' || PPORT=$3
test "$4" = '""' || PUID=$4 test "$4" = '""' || PUID=$4
test "$5" = '""' || PPASSWD=$5 test "$5" = '""' || PPASSWD=$5
# Check the INEP value # Check if $INEP is empty
if test -z ${INEP}; then if test -z "${INEP}"; then
echo "error: invalid INEP." printf "ERROR: Empty INEP.\n"
exit 1 exit 1
fi fi
# Start the tree creation process # -----------------------------------------------------------------------------
# Start the tree creation process, removing any possible garbage before
# creating the INEP specific temporary directory
printf "Creating tree... " printf "Creating tree... "
rm -Rf "/tmp/${INEP}"
rm -rf "/tmp/${INEP}"
mkdir -p "/tmp/${INEP}" mkdir -p "/tmp/${INEP}"
# Copy the agent files to the temporary directory where the installation package # Copy the agent files to the temporary directory where the installation package
...@@ -55,18 +57,20 @@ if ! cp -r "${AGENT_FILES}/SEED2-run" "/tmp/${INEP}/SEED2"; then ...@@ -55,18 +57,20 @@ if ! cp -r "${AGENT_FILES}/SEED2-run" "/tmp/${INEP}/SEED2"; then
exit 2 exit 2
fi fi
# Create client conf directory and the inep file with the school INEP
mkdir -p "/tmp/${INEP}/SEED2/client/conf" mkdir -p "/tmp/${INEP}/SEED2/client/conf"
echo "${INEP}" > "/tmp/${INEP}/SEED2/client/conf/inep" echo "${INEP}" > "/tmp/${INEP}/SEED2/client/conf/inep"
# Create the md5 files of inep and inep backup
FILE="/tmp/${INEP}/SEED2/client/conf/inep" FILE="/tmp/${INEP}/SEED2/client/conf/inep"
md5sum "${FILE}" |cut -d' ' -f1 > \ md5sum "${FILE}" |cut -d' ' -f1 > \
"/tmp/${INEP}/SEED2/.md5sum/client/conf/inep" "/tmp/${INEP}/SEED2/.md5sum/client/conf/inep"
cp -a "${FILE}" "/tmp/${INEP}/SEED2/.backup/client/conf/inep" cp -a "${FILE}" "/tmp/${INEP}/SEED2/.backup/client/conf/inep"
FILE="/tmp/${INEP}/SEED2/.backup/client/conf/inep" FILE="/tmp/${INEP}/SEED2/.backup/client/conf/inep"
md5sum "${FILE}" |cut -d' ' -f1 > \ md5sum "${FILE}" |cut -d' ' -f1 > \
"/tmp/${INEP}/SEED2/.md5sum/.backup/client/conf/inep" "/tmp/${INEP}/SEED2/.md5sum/.backup/client/conf/inep"
# Create the proxy file with all necessary proxy information, and its md5
echo "phost=$PHOST" > "/tmp/${INEP}/SEED2/client/conf/proxy" echo "phost=$PHOST" > "/tmp/${INEP}/SEED2/client/conf/proxy"
echo "pport=$PPORT" >> "/tmp/${INEP}/SEED2/client/conf/proxy" echo "pport=$PPORT" >> "/tmp/${INEP}/SEED2/client/conf/proxy"
echo "puid=$PUID" >> "/tmp/${INEP}/SEED2/client/conf/proxy" echo "puid=$PUID" >> "/tmp/${INEP}/SEED2/client/conf/proxy"
...@@ -75,6 +79,7 @@ FILE="/tmp/${INEP}/SEED2/client/conf/proxy" ...@@ -75,6 +79,7 @@ FILE="/tmp/${INEP}/SEED2/client/conf/proxy"
md5sum "${FILE}" |cut -d' ' -f1 > \ md5sum "${FILE}" |cut -d' ' -f1 > \
"/tmp/${INEP}/SEED2/.md5sum/client/conf/proxy" "/tmp/${INEP}/SEED2/.md5sum/client/conf/proxy"
# Create the backup proxy file and its md5
cp -a "${FILE}" "/tmp/${INEP}/SEED2/.backup/client/conf/proxy" cp -a "${FILE}" "/tmp/${INEP}/SEED2/.backup/client/conf/proxy"
FILE="/tmp/${INEP}/SEED2/.backup/client/conf/proxy" FILE="/tmp/${INEP}/SEED2/.backup/client/conf/proxy"
md5sum "${FILE}" |cut -d' ' -f1 > \ md5sum "${FILE}" |cut -d' ' -f1 > \
...@@ -88,7 +93,9 @@ if ! cp -r "${AGENT_FILES}/${BOOTSTRAP}" "/tmp/${INEP}"; then ...@@ -88,7 +93,9 @@ if ! cp -r "${AGENT_FILES}/${BOOTSTRAP}" "/tmp/${INEP}"; then
fi fi
printf "done.\n" printf "done.\n"
# End of tree creation process
# -----------------------------------------------------------------------------
# The tree is ready, we need to compress it now (tar+gz) # The tree is ready, we need to compress it now (tar+gz)
printf "Packaging... " printf "Packaging... "
...@@ -100,23 +107,28 @@ fi ...@@ -100,23 +107,28 @@ fi
# Create the tar md5 and compute the bootstrap lines # Create the tar md5 and compute the bootstrap lines
MD5_CHECK=$(md5sum SEED2.tgz | awk '{print $1}') MD5_CHECK=$(md5sum SEED2.tgz | awk '{print $1}')
LINENUM=$(( $(wc -l "bootstrap-install" | cut -d' ' -f1) + 1 )) LINENUM=$(( $(wc -l "${BOOTSTRAP}" | cut -d' ' -f1) + 1 ))
# Edit the bootstrap and start the real package # Edit the bootstrap and start the real package
sed "s/BOOTSTRAP_LINES=/BOOTSTRAP_LINES=${LINENUM}/g; \ sed "s/BOOTSTRAP_LINES=/BOOTSTRAP_LINES=${LINENUM}/g; \
s/MD5_CHECK=/MD5_CHECK=\"${MD5_CHECK}\"/g" \ s/MD5_CHECK=/MD5_CHECK=\"${MD5_CHECK}\"/g" \
"bootstrap-install" > agent_${INEP}.run "${BOOTSTRAP}" > agent_${INEP}.run
# Insert the tar on the package and finish # Insert the tar on the package and finish
cat "SEED2.tgz" >> "agent_${INEP}.run" cat "SEED2.tgz" >> "agent_${INEP}.run"
mv "agent_${INEP}.run" "/tmp" mv "agent_${INEP}.run" "/tmp"
printf "done.\n"
printf "done.\n"
# End of packaging step
# -----------------------------------------------------------------------------
# Remove temporary files # Remove temporary files
printf "Removing temporary files... " printf "Removing temporary files... "
cd .. cd ..
rm -rf "${INEP}" 2> /dev/null rm -rf "${INEP}" 2> /dev/null
printf "done.\n" printf "done.\n"
# End of temporary files removal
echo "All done" printf "\nAll done.\n"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment