#!/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 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:]]*?string>||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:]]*?string>||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:]]*?string>||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'
Device Name: | ${DEVICE_NAME} |
Time Zone: | ${TIME_ZONE} |
Locale: | ${LOCALE} |