2014-10-19 23:36:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# vim: set ts=4 sw=4 sts=4 et :
|
|
|
|
|
2014-11-04 04:59:48 +00:00
|
|
|
set -e
|
|
|
|
|
2014-11-07 04:56:57 +00:00
|
|
|
VERBOSE=${VERBOSE:-1}
|
|
|
|
DEBUG=${DEBUG:-0}
|
|
|
|
|
2015-01-30 03:10:43 +00:00
|
|
|
. ./functions-name.sh
|
|
|
|
|
2014-10-16 16:03:05 +00:00
|
|
|
################################################################################
|
|
|
|
# Global functions
|
|
|
|
################################################################################
|
2015-02-10 15:04:56 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2015-02-10 15:03:27 +00:00
|
|
|
# Set xtrace verbose mode (-x or)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
XTRACE=
|
|
|
|
function setVerboseMode() {
|
|
|
|
# Cache xtrace current status so it can be restored on exit
|
|
|
|
[[ ${-/x} != $- ]] && XTRACE=0 || XTRACE=1
|
|
|
|
|
|
|
|
if [ "${VERBOSE}" -ge 2 -o "${DEBUG}" -ge 2 ]; then
|
|
|
|
set -x
|
|
|
|
else
|
|
|
|
set +x
|
|
|
|
fi
|
|
|
|
}
|
2014-10-16 16:03:05 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Define colors
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
colors() {
|
|
|
|
## Thanks to:
|
|
|
|
## http://mywiki.wooledge.org/BashFAQ/037
|
|
|
|
## Variables for terminal requests.
|
|
|
|
[[ -t 2 ]] && {
|
|
|
|
export alt=$( tput smcup || tput ti ) # Start alt display
|
|
|
|
export ealt=$( tput rmcup || tput te ) # End alt display
|
|
|
|
export hide=$( tput civis || tput vi ) # Hide cursor
|
|
|
|
export show=$( tput cnorm || tput ve ) # Show cursor
|
|
|
|
export save=$( tput sc ) # Save cursor
|
|
|
|
export load=$( tput rc ) # Load cursor
|
|
|
|
export bold=$( tput bold || tput md ) # Start bold
|
|
|
|
export stout=$( tput smso || tput so ) # Start stand-out
|
|
|
|
export estout=$( tput rmso || tput se ) # End stand-out
|
|
|
|
export under=$( tput smul || tput us ) # Start underline
|
|
|
|
export eunder=$( tput rmul || tput ue ) # End underline
|
|
|
|
export reset=$( tput sgr0 || tput me ) # Reset cursor
|
|
|
|
export blink=$( tput blink || tput mb ) # Start blinking
|
|
|
|
export italic=$( tput sitm || tput ZH ) # Start italic
|
|
|
|
export eitalic=$( tput ritm || tput ZR ) # End italic
|
2014-10-28 08:09:55 +00:00
|
|
|
[[ ${TERM} != *-m ]] && {
|
2014-10-16 16:03:05 +00:00
|
|
|
export red=$( tput setaf 1|| tput AF 1 )
|
|
|
|
export green=$( tput setaf 2|| tput AF 2 )
|
|
|
|
export yellow=$( tput setaf 3|| tput AF 3 )
|
|
|
|
export blue=$( tput setaf 4|| tput AF 4 )
|
|
|
|
export magenta=$( tput setaf 5|| tput AF 5 )
|
|
|
|
export cyan=$( tput setaf 6|| tput AF 6 )
|
|
|
|
}
|
|
|
|
export white=$( tput setaf 7|| tput AF 7 )
|
|
|
|
export default=$( tput op )
|
|
|
|
export eed=$( tput ed || tput cd ) # Erase to end of display
|
|
|
|
export eel=$( tput el || tput ce ) # Erase to end of line
|
|
|
|
export ebl=$( tput el1 || tput cb ) # Erase to beginning of line
|
|
|
|
export ewl=$eel$ebl # Erase whole line
|
|
|
|
export draw=$( tput -S <<< ' enacs
|
|
|
|
smacs
|
|
|
|
acsc
|
|
|
|
rmacs' || { \
|
|
|
|
tput eA; tput as;
|
|
|
|
tput ac; tput ae; } ) # Drawing characters
|
|
|
|
export back=$'\b'
|
|
|
|
} 2>/dev/null ||:
|
|
|
|
|
|
|
|
export build_already_defined_colors="true"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ ! "$build_already_defined_colors" = "true" ]; then
|
|
|
|
colors
|
|
|
|
fi
|
|
|
|
|
2014-10-28 08:09:55 +00:00
|
|
|
if [ "${VERBOSE}" -ge 2 -o "${DEBUG}" == "1" ]; then
|
2014-10-18 03:34:01 +00:00
|
|
|
chroot() {
|
|
|
|
local retval
|
|
|
|
true ${blue}
|
2015-02-10 15:03:27 +00:00
|
|
|
if [ "${SYSTEMD_NSPAWN_ENABLE}" == "1" ]; then
|
|
|
|
systemd-nspawn $systemd_bind -D "${INSTALLDIR}" -M "${DIST}" "$@" && { retval=$?; true; } || { retval=$?; true; }
|
|
|
|
else
|
|
|
|
/usr/sbin/chroot "${INSTALLDIR}" "$@" && { retval=$?; true; } || { retval=$?; true; }
|
|
|
|
fi
|
2014-10-18 03:34:01 +00:00
|
|
|
true ${reset}
|
|
|
|
return $retval
|
|
|
|
}
|
2015-02-19 03:07:51 +00:00
|
|
|
else
|
|
|
|
chroot() {
|
|
|
|
/usr/sbin/chroot "${INSTALLDIR}" "$@"
|
|
|
|
}
|
2014-10-18 03:34:01 +00:00
|
|
|
fi
|
2014-10-16 16:03:05 +00:00
|
|
|
|
2015-02-10 15:03:27 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Return xtrace's current mode
|
|
|
|
# 0 is enables (-x); 1 is disables (+x)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
getXtrace() {
|
|
|
|
[[ ${-/x} != $- ]] && echo 0 || echo 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Return xtrace to desired state
|
|
|
|
# 0 is enables (-x); 1 is disables (+x)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
setXtrace() {
|
|
|
|
[[ "${1}" -eq 0 ]] && set -x || set +x
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:03:05 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Display messages in color
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-11-04 04:59:48 +00:00
|
|
|
# Only output text under certain conditions
|
|
|
|
output() {
|
2014-11-04 07:44:05 +00:00
|
|
|
if [ "${VERBOSE}" -ge 1 ]; then
|
|
|
|
# Don't echo if -x is set since it will already be displayed via true
|
2015-02-10 15:03:27 +00:00
|
|
|
[[ ${-/x} != $- ]] || echo -e ""$@""
|
2014-11-04 07:44:05 +00:00
|
|
|
fi
|
2014-11-04 04:59:48 +00:00
|
|
|
}
|
|
|
|
|
2015-02-10 15:03:27 +00:00
|
|
|
outputc() {
|
|
|
|
color=${1}
|
|
|
|
shift
|
|
|
|
output "${!color}"$@"${reset}" || :
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:03:05 +00:00
|
|
|
info() {
|
2015-02-10 15:03:27 +00:00
|
|
|
output "${bold}${blue}INFO: "$@"${reset}" || :
|
2014-10-16 16:03:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
debug() {
|
2015-02-10 15:03:27 +00:00
|
|
|
output "${bold}${green}DEBUG: "$@"${reset}" || :
|
2014-10-16 16:03:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
warn() {
|
2015-02-10 15:03:27 +00:00
|
|
|
output "${stout}${yellow}WARNING: "$@"${reset}" || :
|
2014-10-16 16:03:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
error() {
|
2015-02-10 15:03:27 +00:00
|
|
|
output "${bold}${red}ERROR: "$@"${reset}" || :
|
2014-10-16 16:03:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Takes an array and exports it a global variable
|
|
|
|
#
|
|
|
|
# $1: Array to export
|
|
|
|
# $2: Global variable name to use for export
|
|
|
|
#
|
|
|
|
# http://ihaveabackup.net/2012/01/29/a-workaround-for-passing-arrays-in-bash/
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
setArrayAsGlobal() {
|
|
|
|
local array="$1"
|
|
|
|
local export_as="$2"
|
|
|
|
local code=$(declare -p "$array")
|
|
|
|
local replaced="${code/$array/$export_as}"
|
|
|
|
eval ${replaced/declare -/declare -g}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Spilts the path and returns an array of parts
|
|
|
|
#
|
|
|
|
# $1: Full path of file to split
|
|
|
|
# $2: Global variable name to use for export
|
|
|
|
# Returns:
|
|
|
|
# ([full]='original name' [dir]='directory' [base]='filename' [ext]='extension')
|
|
|
|
#
|
|
|
|
# Original concept path split from:
|
|
|
|
# https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
splitPath() {
|
|
|
|
|
|
|
|
local return_global_var=$2
|
|
|
|
local filename="${1##*/}" # Strip longest match of */ from start
|
|
|
|
local dir="${1:0:${#1} - ${#filename}}" # Substring from 0 thru pos of filename
|
|
|
|
local base="${filename%.[^.]*}" # Strip shortest match of . plus at least one non-dot char from end
|
|
|
|
local ext="${filename:${#base} + 1}" # Substring from len of base thru end
|
|
|
|
if [ "$ext" ]; then
|
|
|
|
local dotext=".$ext"
|
|
|
|
else
|
|
|
|
local dotext=""
|
|
|
|
fi
|
|
|
|
if [[ -z "$base" && -n "$ext" ]]; then # If we have an extension and no base, it's really the base
|
|
|
|
base=".$ext"
|
|
|
|
ext=""
|
|
|
|
dotext=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
declare -A PARTS=([full]="$1" [dir]="$dir" [base]="$base" [ext]="$ext" [dotext]="$dotext")
|
|
|
|
setArrayAsGlobal PARTS $return_global_var
|
|
|
|
}
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
templateDir() {
|
2015-01-30 03:10:43 +00:00
|
|
|
local template_flavor=${1-${TEMPLATE_FLAVOR}}
|
2014-10-24 10:48:11 +00:00
|
|
|
|
2014-10-27 03:55:21 +00:00
|
|
|
# If TEMPLATE_FLAVOR_DIR is not already an array, make it one
|
|
|
|
if ! [[ "$(declare -p TEMPLATE_FLAVOR_DIR 2>/dev/null)" =~ ^declare\ -a.* ]] ; then
|
|
|
|
TEMPLATE_FLAVOR_DIR=( ${TEMPLATE_FLAVOR_DIR} )
|
|
|
|
fi
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
for element in "${TEMPLATE_FLAVOR_DIR[@]}"
|
|
|
|
do
|
2014-10-24 10:48:11 +00:00
|
|
|
# (wheezy+whonix-gateway / wheezy+whonix-gateway+gnome[+++] / wheezy+gnome )
|
2014-10-24 20:17:29 +00:00
|
|
|
if [ "${element%:*}" == "$(templateName ${template_flavor})" ]; then
|
2015-02-10 15:03:27 +00:00
|
|
|
eval echo -e "${element#*:}"
|
2014-10-24 10:48:11 +00:00
|
|
|
return
|
|
|
|
# Very short name compare (+proxy)
|
|
|
|
elif [ "${element:0:1}" == "+" -a "${element%:*}" == "+${template_flavor}" ]; then
|
2015-02-10 15:03:27 +00:00
|
|
|
eval echo -e "${element#*:}"
|
2014-10-22 20:37:26 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
2014-10-21 13:12:05 +00:00
|
|
|
|
2015-02-10 15:03:27 +00:00
|
|
|
local template_flavor_prefix="$(templateFlavorPrefix ${template_flavor})"
|
|
|
|
if [ -n "${template_flavor}" -a "${template_flavor}" == "+" ]; then
|
|
|
|
local dir="${SCRIPTSDIR}/${template_flavor_prefix}"
|
|
|
|
elif [ -n "${template_flavor}" ]; then
|
2014-10-22 20:37:26 +00:00
|
|
|
local dir="${SCRIPTSDIR}/${template_flavor_prefix}${template_flavor}"
|
2014-10-16 16:03:05 +00:00
|
|
|
else
|
2014-10-22 20:37:26 +00:00
|
|
|
local dir="${SCRIPTSDIR}"
|
2014-10-16 16:03:05 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
echo "${dir}"
|
|
|
|
}
|
|
|
|
|
|
|
|
templateFile() {
|
|
|
|
local file="$1"
|
|
|
|
local suffix="$2"
|
|
|
|
local template_flavor="$3"
|
2014-11-04 04:59:48 +00:00
|
|
|
local template_dir="$(templateDir "${template_flavor}")"
|
2014-10-22 20:37:26 +00:00
|
|
|
|
|
|
|
splitPath "${file}" path_parts
|
|
|
|
|
|
|
|
# Append suffix to filename (before extension)
|
|
|
|
if [ "${suffix}" ]; then
|
|
|
|
file="${template_dir}/${path_parts[base]}_${suffix}${path_parts[dotext]}"
|
2014-10-16 16:03:05 +00:00
|
|
|
else
|
2014-10-22 20:37:26 +00:00
|
|
|
file="${template_dir}/${path_parts[base]}${path_parts[dotext]}"
|
2014-10-16 16:03:05 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
if [ -f "${file}" ]; then
|
|
|
|
echo "${file}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
buildStepExec() {
|
|
|
|
local filename="$1"
|
|
|
|
local suffix="$2"
|
|
|
|
local template_flavor="$3"
|
|
|
|
|
|
|
|
script="$(templateFile "${filename}" "${suffix}" "${template_flavor}")"
|
|
|
|
|
2014-11-04 04:59:48 +00:00
|
|
|
if [ -f "${script}" ] && [ ! ${GLOBAL_CACHE[$script]+_} ]; then
|
2014-11-04 07:44:05 +00:00
|
|
|
|
2014-11-04 04:59:48 +00:00
|
|
|
# Test module expects raw output back only used to asser test results
|
|
|
|
if [[ -n ${TEST} ]]; then
|
|
|
|
echo "${script}"
|
|
|
|
else
|
|
|
|
output "${bold}${under}INFO: Currently running script: ${script}${reset}"
|
|
|
|
fi
|
2014-10-24 10:48:11 +00:00
|
|
|
|
2014-11-04 04:59:48 +00:00
|
|
|
# Cache $script
|
|
|
|
GLOBAL_CACHE[$script]=1
|
2015-02-10 15:03:27 +00:00
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
# Execute $script
|
|
|
|
"${script}"
|
2014-10-16 16:03:05 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
copyTreeExec() {
|
2014-10-26 18:48:09 +00:00
|
|
|
local source_dir="$1"
|
2014-10-21 13:12:05 +00:00
|
|
|
local dir="$2"
|
|
|
|
local template_flavor="$3"
|
2014-10-26 18:48:09 +00:00
|
|
|
local target_dir="$4"
|
2014-10-19 23:36:59 +00:00
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
local template_dir="$(templateDir ${template_flavor})"
|
2014-10-26 18:48:09 +00:00
|
|
|
local source_dir="$(readlink -m ${source_dir:-${template_dir}}/${dir})"
|
|
|
|
local target_dir="$(readlink -m ${target_dir:-${INSTALLDIR}})"
|
2014-10-16 16:03:05 +00:00
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
if ! [ -d "${source_dir}" ]; then
|
2014-10-19 23:36:59 +00:00
|
|
|
debug "No extra files to copy for ${dir}"
|
2014-10-22 20:37:26 +00:00
|
|
|
return 0
|
2014-10-19 23:36:59 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-26 18:48:09 +00:00
|
|
|
debug "Copying ${source_dir}/* ${target_dir}"
|
2014-10-29 12:16:46 +00:00
|
|
|
cp -rp "${source_dir}/." "${target_dir}"
|
2014-10-19 23:36:59 +00:00
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
if [ -f "${source_dir}/.facl" ]; then
|
2014-10-19 23:36:59 +00:00
|
|
|
debug "Restoring file permissions..."
|
2014-10-26 18:48:09 +00:00
|
|
|
pushd "${target_dir}"
|
2014-10-19 23:36:59 +00:00
|
|
|
{
|
2014-10-22 20:37:26 +00:00
|
|
|
setfacl --restore="${source_dir}/.facl" 2>/dev/null ||:
|
2014-11-04 04:59:48 +00:00
|
|
|
rm -f .facl
|
2014-10-19 23:36:59 +00:00
|
|
|
}
|
|
|
|
popd
|
2014-10-16 16:03:05 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
callTemplateFunction() {
|
2014-11-04 04:59:48 +00:00
|
|
|
# Reset Cache
|
|
|
|
unset GLOBAL_CACHE
|
|
|
|
declare -A -g GLOBAL_CACHE
|
|
|
|
|
2014-10-21 13:12:05 +00:00
|
|
|
local calling_script="$1"
|
2014-10-22 20:37:26 +00:00
|
|
|
local calling_arg="$2"
|
2014-10-21 13:12:05 +00:00
|
|
|
local functionExec="$3"
|
2015-01-30 03:10:43 +00:00
|
|
|
local template_flavor="${TEMPLATE_FLAVOR}"
|
2015-02-10 15:03:27 +00:00
|
|
|
|
2014-10-21 13:12:05 +00:00
|
|
|
${functionExec} "${calling_script}" \
|
2014-10-22 20:37:26 +00:00
|
|
|
"${calling_arg}" \
|
|
|
|
"${template_flavor}"
|
2014-10-21 13:12:05 +00:00
|
|
|
|
2015-02-10 15:03:27 +00:00
|
|
|
# Find a $DIST sub-directory
|
|
|
|
${functionExec} "${calling_script}" \
|
|
|
|
"${calling_arg}" \
|
|
|
|
"+"
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
for option in ${TEMPLATE_OPTIONS[@]}
|
2014-10-21 13:12:05 +00:00
|
|
|
do
|
2014-10-24 10:48:11 +00:00
|
|
|
# Long name (wheezy+whonix-gateway+proxy)
|
2014-10-21 13:12:05 +00:00
|
|
|
${functionExec} "${calling_script}" \
|
2014-10-22 20:37:26 +00:00
|
|
|
"${calling_arg}" \
|
2015-01-30 03:10:43 +00:00
|
|
|
"${TEMPLATE_FLAVOR}+${option}"
|
2014-10-24 10:48:11 +00:00
|
|
|
|
|
|
|
# Short name (wheezy+proxy)
|
|
|
|
${functionExec} "${calling_script}" \
|
|
|
|
"${calling_arg}" \
|
|
|
|
"${option}"
|
2014-10-21 13:12:05 +00:00
|
|
|
done
|
2014-11-04 04:59:48 +00:00
|
|
|
|
|
|
|
# If template_flavor exists, also check on base distro
|
|
|
|
if [ -n "${template_flavor}" ]; then
|
|
|
|
${functionExec} "${calling_script}" \
|
|
|
|
"${calling_arg}"
|
|
|
|
fi
|
2014-10-21 13:12:05 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2015-02-10 15:03:27 +00:00
|
|
|
# Will return all files that match pattern of suffix
|
|
|
|
# Example:
|
|
|
|
# filename = packages.list
|
|
|
|
# suffix = ${DIST} (wheezy)
|
|
|
|
#
|
|
|
|
# Will look for a file name packages_wheezy.list in:
|
|
|
|
# the $SCRIPTSDIR; beside original
|
|
|
|
# the $SCRIPTSDIR/$DIST (wheezy) directory
|
|
|
|
# any included template module directories ($SCRIPTSDIR/gnome)
|
|
|
|
#
|
|
|
|
# All matches are returned and each will be able to be used
|
2014-10-22 20:37:26 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
getFileLocations() {
|
|
|
|
local return_global_var=$1
|
|
|
|
local filename="$2"
|
|
|
|
local suffix="$3"
|
|
|
|
local function="templateFile"
|
|
|
|
|
2014-11-04 04:59:48 +00:00
|
|
|
files="$(callTemplateFunction "${filename}" "${suffix}" "${function}")"
|
2014-10-27 03:55:21 +00:00
|
|
|
|
2014-10-22 20:37:26 +00:00
|
|
|
IFS_orig="${IFS}}"; IFS=$'\n'
|
2014-10-27 03:55:21 +00:00
|
|
|
files=( "${files}" )
|
2014-10-22 20:37:26 +00:00
|
|
|
setArrayAsGlobal files $return_global_var
|
|
|
|
|
|
|
|
IFS="${IFS_orig}"
|
|
|
|
}
|
|
|
|
|
2014-10-21 13:12:05 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Executes any additional optional configuration steps if the configuration
|
|
|
|
# scripts exist
|
2015-02-10 15:03:27 +00:00
|
|
|
#
|
|
|
|
# Will find all scripts with
|
|
|
|
# Example:
|
|
|
|
# filename = 04_install_qubes.sh
|
|
|
|
# suffix = post
|
|
|
|
#
|
|
|
|
# Will look for a file name 04_install_qubes_post in:
|
|
|
|
# the $SCRIPTSDIR; beside original
|
|
|
|
# the $SCRIPTSDIR/$DIST (wheezy) directory
|
|
|
|
# any included template module directories ($SCRIPTSDIR/gnome)
|
|
|
|
#
|
|
|
|
# All matches are executed
|
2014-10-21 13:12:05 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-22 20:37:26 +00:00
|
|
|
buildStep() {
|
|
|
|
local filename="$1"
|
|
|
|
local suffix="$2"
|
|
|
|
local function="buildStepExec"
|
|
|
|
|
|
|
|
callTemplateFunction "${filename}" "${suffix}" "${function}"
|
2014-10-21 13:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-28 08:09:55 +00:00
|
|
|
# Copy extra file tree to ${INSTALLDIR}
|
2014-10-21 13:12:05 +00:00
|
|
|
# TODO: Allow copy per step (04_install_qubes.sh-files)
|
|
|
|
#
|
|
|
|
# To set file permissions is a PITA since git won't save them and will
|
|
|
|
# complain heavily if they are set to root only read, so this is the procdure:
|
|
|
|
#
|
|
|
|
# 1. Change to the directory that you want to have file permissions retained
|
|
|
|
# 2. Change all the file permissions / ownership as you want
|
|
|
|
# 3. Change back to the root of the exta directory (IE: extra-qubes-files)
|
2014-10-23 02:38:07 +00:00
|
|
|
# 4. Manually restore facl's: setfacl --restore=.facl
|
|
|
|
# 5. Manually create facl backup used after copying: getfacl -R . > .facl
|
|
|
|
# 6. If git complains; reset file ownership back to user. The .facl file stored
|
2014-10-21 13:12:05 +00:00
|
|
|
# the file permissions and will be used to reset the file permissions after
|
2014-10-28 08:09:55 +00:00
|
|
|
# they get copied over to ${INSTALLDIR}
|
2014-10-21 13:12:05 +00:00
|
|
|
# NOTE: Don't forget to redo this process if you add -OR- remove files
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-22 20:37:26 +00:00
|
|
|
copyTree() {
|
|
|
|
local dir="$1"
|
2014-10-26 18:48:09 +00:00
|
|
|
local source_dir="$2"
|
|
|
|
local target_dir="$3"
|
2014-10-22 20:37:26 +00:00
|
|
|
local function="copyTreeExec"
|
|
|
|
|
2014-10-26 18:48:09 +00:00
|
|
|
if [ "x${source_dir}" == "x" ]; then
|
|
|
|
callTemplateFunction "" "${dir}" "${function}"
|
|
|
|
else
|
|
|
|
copyTreeExec "${source_dir}" "${dir}" "" "${target_dir}"
|
|
|
|
fi
|
2014-10-21 13:12:05 +00:00
|
|
|
}
|
|
|
|
|
2014-10-16 16:03:05 +00:00
|
|
|
# $0 is module that sourced vars.sh
|
2014-11-04 04:59:48 +00:00
|
|
|
output "${bold}${under}INFO: Currently running script: ${0}${reset}"
|