This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# test_succeeded | |
# - param1: the message to display | |
# | |
test_succeeded() { | |
local MESSAGE=${1} | |
echo -e "${TEST_RESULT_OK} ${MESSAGE}" | |
PASSED_TEST_COUNT=$((PASSED_TEST_COUNT + 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# check_bash_syntax | |
# - param1: shell to check | |
# | |
check_bash_syntax() { | |
local SCRIPT=${1} | |
TEST_COUNT=$((TEST_COUNT + 1)) | |
STATUS=$(shellcheck ${SCRIPT} | grep problems | wc -l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# check_if_users_belong_to_docker_group | |
# - param 1: list of users | |
# - param 2: targetted group | |
# | |
# WARNING: this function uses the global variable FILE_ETC_GROUP | |
# | |
check_if_users_belong_to_group() { | |
local USER_LIST=("$@") # Rebuild the array with rest of arguments | |
local TARGETTED_GROUP="${2}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# display_file_content | |
# - param1: the file whose content will be displayed | |
# | |
display_file_content() { | |
local FILE_TO_CAT=${1} | |
echo -e "${YELLOW}__________________________________ ${FILE_TO_CAT} (Start) __________________________________${RESET_COLOR}" | |
cat ${FILE_TO_CAT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# install_required_softwares | |
# | |
install_required_softwares() { | |
echo -e "${YELLOW}Installing the required software${RESET_COLOR}" | |
# Install the required packages if needed | |
if ! [ -x "$(command -v kpartx)" ]; then | |
echo -e "${YELLOW}Installing kpartx${RESET_COLOR}" | |
eval $CMD_APT_GET_INSTALL kpartx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# Parses the parameters | |
while (( "$#" )); do | |
case "${1}" in | |
--enable-wifi) | |
ENABLE_WIFI="true" | |
shift # past argument | |
;; | |
-h|--help) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# Parses the parameters | |
while (( "$#" )); do | |
case "${1}" in | |
# Handle flags | |
--flag1) | |
FLAG1="true" | |
shift # past argument | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# Define the APT commands | |
CMD_APT_GET_UPDATE="DEBIAN_FRONTEND=noninteractive apt-get -qq -o Dpkg::Use-Pty=0 update" | |
CMD_APT_GET_INSTALL="DEBIAN_FRONTEND=noninteractive apt-get -qq -o Dpkg::Use-Pty=0 install" | |
CMD_APT_GET_AUTOREMOVE="DEBIAN_FRONTEND=noninteractive apt-get -qq -o Dpkg::Use-Pty=0 --purge autoremove" | |
CMD_APT_GET_CLEAN="DEBIAN_FRONTEND=noninteractive apt-get -qq -o Dpkg::Use-Pty=0 clean" | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
# | |
# display_help | |
# | |
display_help() { | |
echo "Usage: ${0}.sh --param1 <This is the first parameter>" | |
echo " --param2 <This is the second parameter>" | |
echo " --flag1" | |
echo " [--flag2|flag3 (Default)]" |