#!/usr/bin/env bash #=============================================================================== # # DIRECTORY: # --- # # FILE: # ./configuration_plugin.sh # # USAGE: # . configuration_plugin.sh # OR # source configuration_plugin.sh # # DESCRIPTION: # Configuration plugin (library) to generate content with simple template engine. # # BUGS: # --- # # TESTS: # - shellcheck -s bash -e 2034 ./configuration_plugin.sh # - shellcheck -s ksh -e 2034 ./configuration_plugin.sh # - shellcheck -s dash -e 2034 ./configuration_plugin.sh # # AUTHOR: # Patrick Neumann, patrick@neumannsland.de # # COAUTHOR(S): # Odin Heitmann, odin.heitmann@gmail.com # # COMPANY: # (privately) # # VERSION: # 1.0 # # LINK TO THE MOST CURRENT VERSION: # (Sorry, we bet, I'm not allowed to publish it over GitHub!) # # CREATED: # 2018-06-01 # # COPYRIGHT (C): # 2018 - Patrick Neumann & Odin Heitmann # # LICENSE: # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # WARRANTY: # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # NOTES: # --- # # TODO: # --- # # HISTORY: # 1.0 - P. N. & O. H. - Initial (for the trainers eyes only) release # #=============================================================================== #------------------------------------------------------------------------------- # Check if functions library is loaded first. #------------------------------------------------------------------------------- if [ "${FUNCTIONS_LOADED}" != "true" ] ; then printf "\\n\\033[01;31;40mERROR: functions library not loaded... EXIT!!!\\033[00m\\n\\n" exit 200 fi #------------------------------------------------------------------------------- # Check if temblate engine library is loaded first. #------------------------------------------------------------------------------- if [ "${TEMPLATE_ENGINE_LOADED}" != "true" ] ; then error_exit "template_engine.sh not loaded" 200 fi #=== CONFIGURATION (static) ==================================================== #assign_binary "xyz" # (un)common #=== FUNCTION ================================================================== # NAME: get_configuration_info # DESCRIPTION: "Grep" information and store into vars. # PARAMETERS: none (global vars will be used.) #=============================================================================== get_configuration_info () { # NOT in iTunes Backup! # There are two data_ark.plist: # - mobile/Library/mad/data_ark.plist # - root/Library/Lockdown/data_ark.plist readonly DATA_ARK_PLIST="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -path "*Lockdown/data_ark.plist" )" if [ -z "${DATA_ARK_PLIST}" ] ; then readonly DATA_ARK_SOURCE="data_ark.plist not found" error "data_ark.plist not found" readonly DEVICE_NAME="unknown" readonly TIME_ZONE="unknown" readonly LOCALE="unknown" else readonly DATA_ARK_SOURCE="${DATA_ARK_PLIST/${IOS_BACKUP}/\/private\/var}" plist_bin2xml "${DATA_ARK_PLIST}" "${FOLDER}/data_ark.plist" readonly DEVICE_NAME="$( ${BIN_GREP} --fixed-strings --after-context=1 "DeviceName" "${FOLDER}/data_ark.plist" \ | ${BIN_TAIL} -n 1 \ | ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*||g' )" readonly TIME_ZONE="$( ${BIN_GREP} --fixed-strings --after-context=1 "TimeZone" "${FOLDER}/data_ark.plist" \ | ${BIN_TAIL} -n 1 \ | ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*||g' )" readonly LOCALE="$( ${BIN_GREP} --fixed-strings --after-context=1 "com.apple.international-Locale" "${FOLDER}/data_ark.plist" \ | ${BIN_TAIL} -n 1 \ | ${BIN_SED} "${SED_EXT_REGEXP}" 's|[[:space:]]*||g' )" fi #--- next source --- # "7ddb1ea8c09e5baae5e2d2ecac604a4e4e3087de" in iTunes Backup. LOCK_BACKGROUND="$( ${BIN_FIND} "${IOS_BACKUP}" -type f -name "LockBackgroundThumbnail.jpg" )" # <- could be modified later! if [ -z "${LOCK_BACKGROUND}" ] ; then readonly LOCK_BACKGROUND="LockBackgroundThumbnail.jpg not found" readonly LOCK_BACKGROUND_SOURCE="${LOCK_BACKGROUND}" error "LockBackgroundThumbnail.jpg not found" else readonly LOCK_BACKGROUND_SOURCE="${LOCK_BACKGROUND/${IOS_BACKUP}/\/private\/var}" ${BIN_CP} "${LOCK_BACKGROUND}" "${FOLDER}/" if [ "${DEBUG}" = "on" ] ; then ${BIN_PRINTF} "INFO: LockBackgroundThumbnail.jpg copied\\n" 1>&2 fi fi if [ "${DEBUG}" = "on" ] ; then ${BIN_PRINTF} "DEVICE_NAME: %s\\n" "${DEVICE_NAME}" 1>&2 ${BIN_PRINTF} "TIME_ZONE: %s\\n" "${TIME_ZONE}" 1>&2 ${BIN_PRINTF} "LOCALE: %s\\n" "${LOCALE}" 1>&2 fi } #------------------------------------------------------------------------------- # Partial template for hardware information for the simple template engine. #------------------------------------------------------------------------------- # SC2034: all "unused" vars are verified! CONFIGURATION_INFORMATION=$( ${BIN_CAT} <<'EOF'

Configuration

Sources

  • ${DATA_ARK_SOURCE}
  • ${LOCK_BACKGROUND_SOURCE}

Information

Device Name: ${DEVICE_NAME}
Time Zone: ${TIME_ZONE}
Locale: ${LOCALE}

Background

${LOCK_BACKGROUND}
EOF ) readonly CONFIGURATION_PLUGIN_LOADED="true" if [ "${DEBUG}" = "on" ] ; then ${BIN_PRINTF} "INFO: configuration_plugin.sh loaded.\\n" 1>&2 fi # Do not use "exit" at the end of a sourced library!