Skip to content

Instantly share code, notes, and snippets.

View XIIIVI's full-sized avatar

Fabrice TX XIIIVI

View GitHub Profile
#!/bin/bash
kas-docker build kas/poky.yml:kas/tftp.yml
#!/bin/bash
# In case of issue running Docker, please add your user to the docker's group
#
# sudo usermod -aG docker ${USER}
#
# then, logout and log in
git clone https://github.com/siemens/kas
#
# check_if_file_contains_string
# - param1: file containing the text
# - param2: string to find
# - param3: message for success
# - param4: message for failure
#
check_if_file_contains_string() {
#!/bin/bash -e
# INSERT COLOR SECTION HERE
# INSERT "RUN AS ROOT" SECTION HERE
# INSERT DISPLAY HELP FUNCTION HERE
# INSERT BANNER HERE
# Patch the script 20-networking.sh as there is an issue due to the use of /etc
sudo sed -i 's#\" \> /etc/wpa_supplicant#\" \> \$\{ETC_DIR\}/wpa_supplicant#g' ./bootstrap.d/20-networking.sh
# The condition is wrong
sudo sed -i 's/if \[ -z \"\$NET_WIFI_SSID\" \] \&\& \[ -z \"\$NET_WIFI_PSK\" \] \; then/if \[ \! -z \"\$NET_WIFI_SSID\" \] \&\& \[ \! -z \"\$NET_WIFI_PSK\" \] \; then/g' ./bootstrap.d/20-networking.sh
# The variables are not the right ones
sudo sed -i "s#NET_SSID#NET_WIFI_SSID#g" ./bootstrap.d/20-networking.sh
sudo sed -i "s#NET_WPAPSK#NET_WIFI_PSK#g" ./bootstrap.d/20-networking.sh
#
# analyze_test_result
#
analyze_test_result() {
if [ ${TEST_COUNT} -eq ${PASSED_TEST_COUNT} ]; then
banner "SUCCESS"
echo -e "${GREEN}${TEST_COUNT} tests passed${RESET_COLOR}"
exit 0
else
#
# is_file_included
# - param1: original file
# - param2: contained file
#
is_file_included() {
local ORIGINAL_FILE=${WORKDIR}/file1
local CONTAINED_FILE=${WORKDIR}/file2
#
# check_installed_packages
#
check_installed_packages(){
local PACKAGE_LIST=("$@") # Rebuild the array with rest of arguments
for index in "${PACKAGE_LIST[@]}";
do
TEST_COUNT=$((TEST_COUNT + 1))
#
# check_if_file_exists: test if the file exist and is not empty
# - param1: full qualified filename
# - param2: file type (script, configuration file, ...)
#
check_if_file_exists() {
local FILENAME=${1}
local FILE_TYPE=${2}
#
# test_failed
# - param1: the message to display
#
test_failed() {
local MESSAGE=${1}
echo -e "${TEST_RESULT_KO} ${MESSAGE}"
}