diff --git a/scripts/helperscripts/inc.helper.sh b/scripts/helperscripts/inc.helper.sh new file mode 100644 index 000000000..04cac78c8 --- /dev/null +++ b/scripts/helperscripts/inc.helper.sh @@ -0,0 +1,17 @@ +# Reads a textfile and pipes all lines as args to the given command. +# Does filter out comments. +# Arguments: +# 1 : textfile to read +# 2... : command to receive args (e.g. 'echo', 'apt-get -y install', ...) +call_with_args_from_file () { + local package_file="$1" + shift + + sed 's|#.*||g' ${package_file} | xargs "$@" +} + +# escape relevant chars for strings used in 'sed' commands. implies delimiter char '|' +escape_for_sed() { + local escaped=$(echo "$1" | sed -e 's/[\&'\''|]/\\&/g') + echo "$escaped" +} diff --git a/scripts/helperscripts/setup_autohotspot.sh b/scripts/helperscripts/setup_autohotspot.sh index 2ae9cd361..881a8e601 100644 --- a/scripts/helperscripts/setup_autohotspot.sh +++ b/scripts/helperscripts/setup_autohotspot.sh @@ -14,18 +14,6 @@ if [[ "$#" -lt 2 || ( "${AUTOHOTSPOTconfig}" != "NO" && "${AUTOHOTSPOTconfig}" ! exit 1 fi -# Reads a textfile and pipes all lines as args to the given command. -# Does filter out comments. -# Arguments: -# 1 : textfile to read -# 2... : command to receive args (e.g. 'echo', 'apt-get -y install', ...) -call_with_args_from_file () { - local package_file="$1" - shift - - sed 's/#.*//g' ${package_file} | xargs "$@" -} - _get_last_ip_segment() { local ip="$1" echo $ip | cut -d'.' -f1-3 @@ -80,6 +68,7 @@ wifi_interface=wlan0 ip_without_last_segment=$(_get_last_ip_segment $AUTOHOTSPOTip) autohotspot_profile="Phoniebox_Hotspot" +source "${JUKEBOX_HOME_DIR}"/scripts/helperscripts/inc.helper.sh source "${JUKEBOX_HOME_DIR}"/scripts/helperscripts/inc.networkHelper.sh _install_autohotspot_dhcpcd() { diff --git a/scripts/installscripts/install-jukebox.sh b/scripts/installscripts/install-jukebox.sh index bccef00a5..371ea4891 100644 --- a/scripts/installscripts/install-jukebox.sh +++ b/scripts/installscripts/install-jukebox.sh @@ -97,12 +97,6 @@ escape_for_shell() { echo "$escaped" } -# escape relevant chars for strings used in 'sed' commands. implies delimiter char '|' -escape_for_sed() { - local escaped=$(echo "$1" | sed -e 's/[\&'\''|]/\\&/g') - echo "$escaped" -} - checkPrerequisite() { #currently the user 'pi' is mandatory #https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1785 @@ -837,18 +831,6 @@ web_server_config() { sudo chmod 440 "${sudoers_wwwdata}" } -# Reads a textfile and pipes all lines as args to the given command. -# Does filter out comments. -# Arguments: -# 1 : textfile to read -# 2... : command to receive args (e.g. 'echo', 'apt-get -y install', ...) -call_with_args_from_file () { - local package_file="$1" - shift - - sed 's|#.*||g' ${package_file} | xargs "$@" -} - install_main() { local jukebox_dir="$1" local apt_get="sudo apt-get -qq --yes" @@ -929,6 +911,7 @@ install_main() { cd "${HOME_DIR}" git clone ${GIT_URL} --branch "${GIT_BRANCH}" + source "${jukebox_dir}"/scripts/helperscripts/inc.helper.sh source "${jukebox_dir}"/scripts/helperscripts/inc.networkHelper.sh