Moved qubes-extra-files to its own directory as a sub-template (proxy) as its only needed for proxies

Removed call from qubes_installation scripts for proxy files.  will now be added by sub-template
Renamed extra-whonix-files to files
Modifies functions.sh to allow for very short proxy names and custom directories that will be dist independent
This commit is contained in:
Jason Mehring 2014-10-24 06:48:11 -04:00
parent 6f9860fb17
commit 0b341f4fb2
46 changed files with 243 additions and 114 deletions

View File

@ -148,8 +148,8 @@ templateFlavorPrefix() {
local template_flavor=${1-$(templateFlavor)} local template_flavor=${1-$(templateFlavor)}
for element in "${TEMPLATE_FLAVOR_PREFIX[@]}" for element in "${TEMPLATE_FLAVOR_PREFIX[@]}"
do do
if [ "${element%;*}" == "${DIST}+${template_flavor}" ]; then if [ "${element%:*}" == "${DIST}+${template_flavor}" ]; then
echo ${element#*;} echo ${element#*:}
return return
fi fi
done done
@ -159,10 +159,16 @@ templateFlavorPrefix() {
templateDir() { templateDir() {
local template_flavor=${1-$(templateFlavor)} local template_flavor=${1-$(templateFlavor)}
for element in "${TEMPLATE_FLAVOR_DIR[@]}" for element in "${TEMPLATE_FLAVOR_DIR[@]}"
do do
if [ "${element%;*}" == "$(templateFlavorPrefix ${template_flavor})${template_flavor}" ]; then # (wheezy+whonix-gateway / wheezy+whonix-gateway+gnome[+++] / wheezy+gnome )
echo ${element#*;} if [ "${element%:*}" == "$(templateFlavorPrefix ${template_flavor})${template_flavor}" ]; then
eval echo -e ${element#*:}
return
# Very short name compare (+proxy)
elif [ "${element:0:1}" == "+" -a "${element%:*}" == "+${template_flavor}" ]; then
eval echo -e ${element#*:}
return return
fi fi
done done
@ -206,6 +212,7 @@ buildStepExec() {
if [ -f "${script}" ]; then if [ -f "${script}" ]; then
[[ -n $TEST ]] && echo "${script}" || echo "${bold}${under}INFO: Currently running script: ${script}${reset}" [[ -n $TEST ]] && echo "${script}" || echo "${bold}${under}INFO: Currently running script: ${script}${reset}"
# Execute $script # Execute $script
"${script}" "${script}"
fi fi
@ -250,9 +257,15 @@ callTemplateFunction() {
for option in ${TEMPLATE_OPTIONS[@]} for option in ${TEMPLATE_OPTIONS[@]}
do do
# Long name (wheezy+whonix-gateway+proxy)
${functionExec} "${calling_script}" \ ${functionExec} "${calling_script}" \
"${calling_arg}" \ "${calling_arg}" \
"$(templateFlavor)+${option}" "$(templateFlavor)+${option}"
# Short name (wheezy+proxy)
${functionExec} "${calling_script}" \
"${calling_arg}" \
"${option}"
done done
} }

View File

@ -182,15 +182,6 @@ EOF
# Need a xen log directory or xen scripts will fail # Need a xen log directory or xen scripts will fail
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
mkdir -p -m 0700 "$INSTALLDIR/var/log/xen" mkdir -p -m 0700 "$INSTALLDIR/var/log/xen"
# --------------------------------------------------------------------------
# Copy over any extra files that may be needed that are located in
# $SCRIPT_DIR/extra-qubes-files
# --------------------------------------------------------------------------
debug "Copy extra files..."
copyTree "extra-qubes-files"
touch "$INSTALLDIR/tmp/.prepared_qubes"
fi fi
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -279,7 +279,7 @@ if ! [ -f "$INSTALLDIR/tmp/.prepared_whonix" ]; then
# Copy over any extra files # Copy over any extra files
# XXX: Moved to 02_install_groups_packages_installed.sh # XXX: Moved to 02_install_groups_packages_installed.sh
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
copyTree "extra-whonix-files" copyTree "files"
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Install Whonix system # Install Whonix system

View File

@ -45,11 +45,13 @@ if [ -L "$INSTALLDIR/etc/resolv.conf" ]; then
popd popd
fi fi
# ------------------------------------------------------------------------------ # --------------------------------------------------------------------------
# Copy over any extra files # Copy over any extra files that may be needed that are located in
# XXX: Moved to 02_install_groups_packages_installed.sh # --------------------------------------------------------------------------
# ------------------------------------------------------------------------------ debug "Copy extra Qubes related files..."
#copyTree "extra-whonix-files" copyTree "extra-qubes-files"
touch "$INSTALLDIR/tmp/.prepared_qubes"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Cleanup Whonix Installation # Cleanup Whonix Installation

View File

@ -0,0 +1,4 @@
#!/bin/sh
# vim: set ts=4 sw=4 sts=4 et :
:

View File

@ -5,7 +5,7 @@ VERBOSE=2
DEBUG=1 DEBUG=1
pushd ../.. pushd ../..
export ROOT_DIR=$(readlink -m .) ROOT_DIR=$(readlink -m .)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Source external scripts # Source external scripts
@ -13,24 +13,59 @@ export ROOT_DIR=$(readlink -m .)
. ./functions.sh . ./functions.sh
. ./tests/assert/assert.sh . ./tests/assert/assert.sh
head() { header() {
echo echo
echo echo
info "------------------------------------------------------------------------------" info "------------------------------------------------------------------------------"
info "${1%%\\n*}"
if ! [ "${1%%\\n*}" == "${1#*\\n}" ]; then IFS= read -r title; info "${title}"
[[ -z $TEST ]] && echo -e "${bold}${green}${1#*\\n}${reset}" || : while IFS= read -r line; do
echo "${bold}${magenta}${line}${reset}"
done;
echo
values SCRIPTSDIR
values DIST
values DISTS_VM
values TEMPLATE_FLAVOR
values TEMPLATE_FLAVOR_PREFIX
values TEMPLATE_FLAVOR_DIR
values TEMPLATE_OPTIONS
echo
}
declare -A VALUES=(
[SCRIPTSDIR]=""
[DIST]=""
[DISTS_VM]=""
[TEMPLATE_FLAVOR]=""
[TEMPLATE_FLAVOR_DIR]=""
[TEMPLATE_FLAVOR_PREFIX]=""
[TEMPLATE_OPTIONS]=""
)
values() {
[[ -z $TEST ]] && {
label=${1}
value="${1}[@]"
value="${!value}"
if [ "${VALUES[$label]}" == "${value}" ]; then
printf " ${bold}${magenta}%-22s = ${value}${reset}\n" "${label}" || :
else
printf " ${bold}${black}%-22s = ${value}${reset}\n" "${label}" || :
fi fi
info "------------------------------------------------------------------------------" VALUES[$label]="${value}"
}
} }
info() { info() {
[[ -z $TEST ]] && echo -e "${bold}${blue}${1}${reset}" || : [[ -z $TEST ]] && echo "${bold}${blue}${1}${reset}" || :
} }
#debug() { debug() {
# [[ -z $TEST ]] && echo -e "${bold}${red}${1}${reset}" || : [[ -z $TEST ]] && echo -e "${magenta}${1}${reset}" || :
#} }
assertTest(){ assertTest(){
TEST=True TEST=True
@ -46,122 +81,187 @@ assertEnd() {
printf "${reset}" printf "${reset}"
} }
# Defaults
export SCRIPTSDIR="tests/template-flavors"
export DIST="wheezy"
export TEMPLATE_FLAVOR="whonix-gateway"
# Should be parses in functions!
export TEMPLATE_FLAVOR_PREFIX=""
# Just use error to show text in red
head "=== Globals ==="
debug 'export SCRIPTSDIR="tests/template-flavors"'
debug 'export DIST="wheezy"'
debug 'export TEMPLATE_FLAVOR="whonix-gateway"'
debug 'export TEMPLATE_FLAVOR_PREFIX=""'
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 1. With TEMPLATE_FLAVOR # 1. With TEMPLATE_FLAVOR
\n export SCRIPTSDIR=tests/template-flavors \ # ------------------------------------------------------------------------------
\n export DIST=wheezy \ SCRIPTSDIR="tests/template-flavors"
\n export TEMPLATE_FLAVOR=whonix-gateway \ DIST="wheezy"
\n export TEMPLATE_FLAVOR_PREFIX=" TEMPLATE_FLAVOR="whonix-gateway"
TEMPLATE_FLAVOR_PREFIX=""
header <<EOF
1. With TEMPLATE_FLAVOR
EOF
buildStep "$0" "pre" buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh" assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh"
assertEnd assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 2. Without TEMPLATE_FLAVOR # 2. Without TEMPLATE_FLAVOR
\n export TEMPLATE_FLAVOR= " # ------------------------------------------------------------------------------
export TEMPLATE_FLAVOR="" TEMPLATE_FLAVOR=""
header <<EOF
2. Without TEMPLATE_FLAVOR
EOF
buildStep "$0" "pre" buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/test_pre.sh" assertTest "buildStep $0 pre" "tests/template-flavors/test_pre.sh"
assertEnd assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 3. Template Options # 3. Template Options
\n DISTS_VM = wheezy+whonix-gateway+gnome \ # ------------------------------------------------------------------------------
\n DISTS_VM = <DIST>+<TEMPLATE_FLAVOR>+<TEMPLATE_OPTIONS>+<TEMPLATE_OPTIONS> \ TEMPLATE_FLAVOR="whonix-gateway"
\n Options get seperated into TEMPLATE_OPTIONS seperated by spaces" TEMPLATE_OPTIONS=('gnome' 'kde')
#
export TEMPLATE_FLAVOR="whonix-gateway" header <<EOF
export TEMPLATE_OPTIONS=('gnome' 'kde') 3. Template Options
Options get seperated into TEMPLATE_OPTIONS seperated by spaces
EOF
buildStep "$0" "pre" buildStep "$0" "pre"
debug "Not supposed to find wheezy+whonix-gateway+kde" debug "Not supposed to find wheezy+whonix-gateway+kde"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
assertEnd assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 4. Template Options with custom prefix # 4. Template Options with custom prefix
\n TEMPLATE_FLAVOR_PREFIX \ # ------------------------------------------------------------------------------
\n export TEMPLATE_FLAVOR_PREFIX=( \ TEMPLATE_FLAVOR_PREFIX=(
\n 'wheezy+whonix-gateway;debian+' \ 'wheezy+whonix-gateway:debian+'
\n 'wheezy+whonix-workstation;debian+' \ 'wheezy+whonix-workstation:debian+'
\n)"
export TEMPLATE_FLAVOR_PREFIX=(
'wheezy+whonix-gateway;debian+'
'wheezy+whonix-workstation;debian+'
) )
header <<EOF
4. Template Options with custom prefix
EOF
buildStep "$0" "pre" buildStep "$0" "pre"
debug "Not supposed to find debian+whonix-gateway+kde" debug "Not supposed to find debian+whonix-gateway+kde"
assertTest "buildStep $0 pre" "tests/template-flavors/debian+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" assertTest "buildStep $0 pre" "tests/template-flavors/debian+whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
assertEnd assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 5. Template Options with NO prefix # 5. Template Options with NO prefix
\n TEMPLATE_FLAVOR_PREFIX \ # ------------------------------------------------------------------------------
\n export TEMPLATE_FLAVOR_PREFIX=( \ TEMPLATE_FLAVOR_PREFIX=(
\n 'wheezy+whonix-gateway;' \ 'wheezy+whonix-gateway:'
\n 'wheezy+whonix-workstation;' \ 'wheezy+whonix-workstation:'
\n)"
export TEMPLATE_FLAVOR_PREFIX=(
'wheezy+whonix-gateway;'
'wheezy+whonix-workstation;'
) )
header <<EOF
5. Template Options with NO prefix
EOF
buildStep "$0" "pre" buildStep "$0" "pre"
debug "Not supposed to find whonix-gateway+kde" debug "Not supposed to find whonix-gateway+kde"
assertTest "buildStep $0 pre" "tests/template-flavors/whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh" assertTest "buildStep $0 pre" "tests/template-flavors/whonix-gateway/test_pre.sh\ntests/template-flavors/wheezy+whonix-gateway+gnome/test_pre.sh"
assertEnd assertEnd
# ------------------------------------------------------------------------------
head " 6. Custom template directory
\n unset TEMPLATE_FLAVOR_PREFIX \
\n unset TEMPLATE_OPTIONS \
\n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway;tests/template-flavors/another_location/whonix-gw"
unset TEMPLATE_FLAVOR_PREFIX
unset TEMPLATE_OPTIONS
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location/whonix-gw"
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix-gw/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 7. Custom template directory with space in name # 6. Custom template directory for options within \${SCRIPTSDIR}
\n unset TEMPLATE_FLAVOR_PREFIX \
\n unset TEMPLATE_OPTIONS \
\n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway;tests/template-flavors/another_location/whonix gw"
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location/whonix gw"
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix gw/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 8. Custom template directory for options
\n unset TEMPLATE_FLAVOR_PREFIX \
\n unset TEMPLATE_OPTIONS \
\n TEMPLATE_FLAVOR_DIR=wheezy+whonix-gateway+gnome;tests/template-flavors/another_location/whonix_gnome"
unset TEMPLATE_FLAVOR_PREFIX unset TEMPLATE_FLAVOR_PREFIX
export TEMPLATE_OPTIONS=('gnome') TEMPLATE_OPTIONS=('gnome')
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway+gnome;tests/template-flavors/another_location/whonix_gnome" TEMPLATE_FLAVOR_DIR='wheezy+whonix-gateway+gnome:${SCRIPTSDIR}/another_location/whonix_gnome'
header <<EOF
6. Custom template directory for options within \${SCRIPTSDIR}
NOTE: in config file you would need to use \$\${SCRIPTSDIR} or whatever variable
and in a bash file use single 'quotes' around string and \${SCRIPTSDIR}
EOF
buildStep "$0" "pre" buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh" assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh"
assertEnd assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head " 9. Configuration Files # 7. Custom template directory
\n Find packages.list for every template available" # ------------------------------------------------------------------------------
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway;tests/template-flavors/another_location/whonix gw" unset TEMPLATE_FLAVOR_PREFIX
unset TEMPLATE_OPTIONS
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway:tests/template-flavors/another_location/whonix-gw"
header <<EOF
7. Custom template directory
EOF
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix-gw/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------
# 8. Custom template directory with space in name
# ------------------------------------------------------------------------------
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway:tests/template-flavors/another_location/whonix gw"
header <<EOF
8. Custom template directory with space in name
EOF
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/another_location/whonix gw/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------
# 9. Custom template directory for options
# ------------------------------------------------------------------------------
unset TEMPLATE_FLAVOR_PREFIX
TEMPLATE_OPTIONS=('gnome')
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway+gnome:tests/template-flavors/another_location/whonix_gnome"
header <<EOF
9. Custom template directory for options
EOF
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/another_location/whonix_gnome/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------
# 10. Template directory for options within $SCRIPTSDIR using short name filter
# ------------------------------------------------------------------------------
unset TEMPLATE_FLAVOR_PREFIX
unset TEMPLATE_FLAVOR_DIR
TEMPLATE_OPTIONS=('proxy')
TEMPLATE_FLAVOR_DIR='wheezy+proxy:${SCRIPTSDIR}/proxy'
header <<EOF
10. Template directory for options within $SCRIPTSDIR using short name filter
EOF
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/proxy/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------
# 11. Template directory for options within using VERY short name filter (+proxy)
# ------------------------------------------------------------------------------
unset TEMPLATE_FLAVOR_PREFIX
unset TEMPLATE_FLAVOR_DIR
TEMPLATE_OPTIONS=('proxy')
TEMPLATE_FLAVOR_DIR='+proxy:${SCRIPTSDIR}/proxy'
header <<EOF
11. Template directory for options within using VERY short name filter (+proxy)
EOF
buildStep "$0" "pre"
assertTest "buildStep $0 pre" "tests/template-flavors/wheezy+whonix-gateway/test_pre.sh\ntests/template-flavors/proxy/test_pre.sh"
assertEnd
# ------------------------------------------------------------------------------
# 12. Configuration Files
# ------------------------------------------------------------------------------
TEMPLATE_FLAVOR_DIR="wheezy+whonix-gateway:tests/template-flavors/another_location/whonix gw"
TEMPLATE_OPTIONS=('gnome')
header <<EOF
12. Configuration Files
Find packages.list for every template available
EOF
getFileLocations filelist 'packages.list' getFileLocations filelist 'packages.list'
for file in "${filelist[@]}"; do for file in "${filelist[@]}"; do
echo "Configuration: ${file}" echo "Configuration: ${file}"
@ -170,11 +270,17 @@ result="$(echo $(printf "'%s' " "${filelist[@]}"))"
assertTest "echo ${result}" "tests/template-flavors/another_location/whonix gw/packages.list tests/template-flavors/wheezy+whonix-gateway+gnome/packages.list" assertTest "echo ${result}" "tests/template-flavors/another_location/whonix gw/packages.list tests/template-flavors/wheezy+whonix-gateway+gnome/packages.list"
assertEnd assertEnd
# ------------------------------------------------------------------------------
# 13. Configuration Files - No Template
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head "10. Configuration Files - No Template
\n Find packages.list for every template available"
TEMPLATE_FLAVOR= TEMPLATE_FLAVOR=
TEMPLATE_FLAVOR_DIR= TEMPLATE_FLAVOR_DIR=
header <<EOF
13. Configuration Files - No Template
Find packages.list for every template available
EOF
getFileLocations filelist 'packages.list' getFileLocations filelist 'packages.list'
for file in "${filelist[@]}"; do for file in "${filelist[@]}"; do
echo "Configuration: ${file}" echo "Configuration: ${file}"
@ -183,11 +289,17 @@ result="$(echo $(printf "'%s' " "${filelist[@]}"))"
assertTest "echo ${result}" "tests/template-flavors/packages.list" assertTest "echo ${result}" "tests/template-flavors/packages.list"
assertEnd assertEnd
# ------------------------------------------------------------------------------
# 14. Configuration Files - No Template - with suffix
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
head "11. Configuration Files - No Template - with suffix
\n Find packages.list for every template available"
TEMPLATE_FLAVOR= TEMPLATE_FLAVOR=
TEMPLATE_FLAVOR_DIR= TEMPLATE_FLAVOR_DIR=
header <<EOF
14. Configuration Files - No Template - with suffix
Find packages.list for every template available
EOF
getFileLocations filelist 'packages.list' 'wheezy' getFileLocations filelist 'packages.list' 'wheezy'
for file in "${filelist[@]}"; do for file in "${filelist[@]}"; do
echo "Configuration: ${file}" echo "Configuration: ${file}"
@ -197,17 +309,24 @@ assertTest "echo ${result}" "tests/template-flavors/packages_wheezy.list"
assertEnd assertEnd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
export INSTALLDIR="${SCRIPTSDIR}/test_copy_location" # 14. Copy files
head "12. Copy files # ------------------------------------------------------------------------------
\n Just test copying from here to ${INSTALLDIR}"
TEMPLATE_FLAVOR="whonix-gateway" TEMPLATE_FLAVOR="whonix-gateway"
TEMPLATE_FLAVOR_DIR="" TEMPLATE_FLAVOR_DIR=""
TEMPLATE_OPTIONS="" TEMPLATE_OPTIONS=""
INSTALLDIR="${SCRIPTSDIR}/test_copy_location"
header <<EOF
14. Copy files
Just test copying from here to ${INSTALLDIR}
INSTALLDIR="${SCRIPTSDIR}/test_copy_location"
EOF
rm -rf "$INSTALLDIR"/* rm -rf "$INSTALLDIR"/*
copyTree "files" copyTree "files"
ls -l "$INSTALLDIR" ls -l "$INSTALLDIR"
assertTest "ls $INSTALLDIR" "test1\ntest2\ntest3" assertTest "ls $INSTALLDIR" "test1\ntest2\ntest3"
assertEnd assertEnd
# Done # Done
popd popd