#!/usr/bin/env bash # # firebee_setup_script.sh # # Version : 0.01 # Author : Bernd Mueller # define some colors. Looks nicer :) RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' RESET='\033[0m' # make cursor blink and not blink. Not supported by MacOS BLINK_ON="\e[?12h" BLINK_OFF="\e[?12l" # some definitions INST_TEMP="./tmp" fb_installer_usage() { # clear screen before output clear # welcome user and ask for lang. to install echo "" echo -e " ${RED}**${RESET} ${YELLOW}FireBee Setup Script${RESET} ${RED}**${RESET}" echo -e " ${YELLOW}==========================${RESET}" echo "" echo " This script will create a new setup for your FireBee." echo " When it's finished, you can copy the content of DEST/* to you CompactFlash-Card" echo "" echo " This script relies on a working internet connection. So make sure you have" echo " it working in first place." echo "" echo " What language do you want to install?" echo -e "${BLINK_ON}" read -p " Languages are: en, de, fr, es, it, nl, ru, cs : " LANG echo -e "${BLINK_OFF}" echo # give user a feedback which lang. is used if [[ ${LANG} == "" ]]; then echo "You didn't give any language. Going default with English" elif [ ${LANG} == "en" ]; then echo "Okay, using English" elif [[ ${LANG} == "de" ]]; then echo "Okay, using German" elif [[ ${LANG} == "fr" ]]; then echo "Okay, using French" elif [[ ${LANG} == "es" ]]; then echo "Okay, using Spanish" elif [[ ${LANG} == "it" ]]; then echo "Okay, using Italian" elif [[ ${LANG} == "nl" ]]; then echo "Okay, using Dutch" elif [[ ${LANG} == "ru" ]]; then echo "Okay, using Russian" elif [[ ${LANG} == "cs" ]]; then echo "Okay, using Czech" else echo -e "I'm sorry, Dave. I'm afraid I can't do \"${LANG}\"!" fi } fb_installer_test_mainloop() { fb_installer_check_tmp } fb_installer_check_tmp() { # check if there is a tmp dir to install and is it # writeable by user? # make dir if not exists if [ ! -d "$INST_TEMP" ]; then mkdir -p "$INST_TEMP" # check if mkdir was successful if [ $? -ne 0 ]; then echo "${RED}Error${RESET}: Could not create Install-Dir '${INST_TEMP}'!" return 1 fi fi # check if it is writable if [ -w "$INST_TEMP" ]; then # check if the directory is not empty if [ "$(ls -A "$INST_TEMP")" ]; then rm -rf "${INST_TEMP:?}/"* fi fb_installer_check_bin else echo "${RED}Error${RESET}: '${INST_TEMP}' is not writeable!" return 1 fi } fb_installer_check_bin() { # list of binaries we need as array bin_needed=("wget" "git" "cp" "rm" "mv" "sed" "cut" "grep" "unzip" "install") # Flag, bin_avail=true # empty list for binaries who are not available missing_bin=() # check if binary is available for prog in "${bin_needed[@]}"; do if which "$prog" &>/dev/null; then # just continue, no output continue else bin_avail=false missing_bin+=("$prog") # add missing binary to a list fi done # when every binary is there, continue to download if ${bin_avail}; then fb_installer_download else echo -e "${RED}Error${RESET}: Missing ${missing_bin[@]}! Please install it first" exit 1 fi } fb_installer_download() { # first cd into INSTALL-DIR cd ${INST_TEMP} # clone setup repo echo "Cloning git repo" git clone https://codeberg.org/firebee/FireBee_Setup.git &>/dev/null # download latest freemint # download bootable mint build and decompress it wget https://tho-otto.de/snapshots/freemint/bootable/freemint-latest-col-firebee.zip &>/dev/null unzip -d freemint freemint-latest-col-firebee.zip &>/dev/null rm freemint-latest-col-firebee.zip &>/dev/null } fb_installer_install_mint() { echo "install mint" } fb_installer_hidden_gems() { # download a pre-packed nvdi, fvdi or both # # note: since we don't ship it by default, # this can be enabled by adding an argument # to the scriptname so it's kind of hidden # and will not packed when the arguments # are omitted echo "none" } fb_installer_usage fb_installer_test_mainloop