Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use env variable CONTAINER to choose the docker container #644

Merged
merged 10 commits into from
Jun 15, 2023
11 changes: 9 additions & 2 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ echo ""
echo -e "==> ""$GREEN""Imported ""$INSTALLER_COUNT"" installer module files""$NC"
echo ""

if [ "$#" -ne 1 ]; then
if [[ "$#" -le 1 ]] && [[ "$#" -gt 2 ]]; then
echo -e "$RED""$BOLD""Invalid number of arguments""$NC"
echo -e "\n\n------------------------------------------------------------------"
echo -e "If you are going to install EMBA in default mode you can use:"
Expand All @@ -94,7 +94,7 @@ if [ "$#" -ne 1 ]; then
exit 1
fi

while getopts cCdDFghlr OPT ; do
while getopts CdDFghlrc: OPT ; do
case $OPT in
d)
export DOCKER_SETUP=1
Expand Down Expand Up @@ -134,6 +134,9 @@ while getopts cCdDFghlr OPT ; do
export REMOVE=1
echo -e "$GREEN""$BOLD""Remove EMBA from the system""$NC"
;;
c)
export CONTAINER="$OPTARG"
;;
*)
echo -e "$RED""$BOLD""Invalid option""$NC"
print_help
Expand All @@ -142,6 +145,10 @@ while getopts cCdDFghlr OPT ; do
esac
done

if ! [[ -v CONTAINER ]]; then
CONTAINER="embeddedanalyzer/emba"
fi

if [[ "$LIST_DEP" -eq 1 ]]; then
echo -e "\n${ORANGE}WARNING: This feature is deprecated and not maintained anymore.$NC"
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
Expand Down
6 changes: 4 additions & 2 deletions installer/I05_emba_docker_image_dl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ I05_emba_docker_image_dl() {
echo -e "Description: EMBA docker images used for firmware analysis."

if command -v docker > /dev/null; then
f="$(docker manifest inspect embeddedanalyzer/emba:latest | grep "size" | sed -e 's/[^0-9 ]//g')"
f="$(docker manifest inspect "${CONTAINER}" | grep "size" | sed -e 's/[^0-9 ]//g')"
echo "Download-Size : ""$(("$(( "${f//$'\n'/+}" ))"/1048576))"" MB"
fi

Expand All @@ -48,7 +48,9 @@ I05_emba_docker_image_dl() {
if command -v docker > /dev/null ; then
export DOCKER_CLI_EXPERIMENTAL=enabled
echo -e "$ORANGE""EMBA docker image will be downloaded.""$NC"
docker pull embeddedanalyzer/emba
echo -e "$ORANGE""CONTAINER VARIABLE SET TO ""$CONTAINER""$NC"
docker pull "${CONTAINER}"
sed -i "/image:/c\ image: ${CONTAINER}" docker-compose.yml
export DOCKER_CLI_EXPERIMENTAL=disabled
docker-compose up --no-start
else
Expand Down
1 change: 1 addition & 0 deletions installer/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ print_help()
echo -e "$CYAN""-h""$NC"" Print this help message"
echo -e "$CYAN""-l""$NC"" List all dependencies of EMBA (deprecated)"
echo -e "$CYAN""-r""$NC"" Remove a default installation of EMBA"
echo -e "$CYAN""-c {x}""$NC"" Choose docker image to install (replace {x} with the name)"
echo
}

Expand Down