| #!/bin/bash |
| # |
| # config - for tod |
| # |
| # Copyright 2019 Luigi Santivetti <luigi.santivetti@gmail.com> |
| |
| # Permission is hereby granted, free of charge, to any person obtaining a |
| # copy of this software and associated documentation files (the "Software"), |
| # to deal in the Software without restriction, including without limitation |
| # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| # and/or sell copies of the Software, and to permit persons to whom the |
| # Software is furnished to do so, subject to the following conditions: |
| |
| # The above copyright notice and this permission notice (including the next |
| # paragraph) shall be included in all copies or substantial portions of the |
| # Software. |
| |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| # ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| |
| # Absolute path to where this script lives |
| declare -rg script_dir="$(get_script_dir)" |
| |
| # Runtime timestamp of when this script was executed |
| declare -rg script_now="$(get_script_now)" |
| |
| # Version file name |
| declare -rg __version="version" |
| |
| # Module staging area name |
| declare -rg staging="staging" |
| |
| # Name of this host's instance, it defaults to localhost |
| declare -rg def_hostname="localhost" |
| declare -rg host_name="${HOST_NAME:-$def_hostname}" |
| |
| # Switch for enabling debug features, it defaults to debug |
| declare -rg release="release" |
| declare -rg debug="debug" |
| declare -rg instance_mode="${INSTANCE_MODE:-$debug}" |
| |
| # Force to use also blacklisted modules |
| declare -rgi modall="${MODALL:-0}" |
| |
| # Default answer instead of waiting for user input |
| declare -rg answer=${DEFANS:-} |
| |
| # Runtime enabled list of modules |
| declare -ag MODULES=( ) |
| |
| # Blacklist modules |
| declare -arg BLMODULES=( "test1" "test2" ) |
| |
| # Runtime running option |
| declare -Ag OPTIONS=( \ |
| [check]=0 [watch]=0 [fetch]=0 [doall]=0 [doins]=0 \ |
| [upins]=0 [upmod]=0 [upall]=0 [clmod]=0 [clins]=0 \ |
| ) |
| |
| # Instance tree |
| declare -rg def_instance_d="$script_dir/$host_name" |
| declare -rg instance_d="${INSTANCE_DIR:-$def_instance_d}" |
| declare -rg docker_d="$instance_d/docker" |
| declare -rg rootfs_d="$instance_d/rootfs" |
| |
| # Module tree |
| declare -rg module_d="$script_dir/module" |
| declare -rg scheme_sh="scheme.sh" |
| declare -rg holder_sh="holder.sh" |
| declare -rg module_sh="module.sh" |
| |
| # Runtime password file |
| declare -rg passwd_sh="${PASSWD_F:-}" |
| |
| # Module common files |
| declare -rg common_sh="$module_d/common.sh" |
| declare -rg manifest_f="$script_dir/MANIFEST" |
| declare -rg uninstall_f="$instance_d/uninstall.sh" |
| |
| # Set of regular expressions for accomplishing module validation |
| declare -rg rex_legal_holder_token="_([0-9]|[A-Z])+" |
| declare -rg rex_legal_holder_variable="($rex_legal_holder_token)+_" |
| declare -rg rex_legal_holder_assignment_op="[\+]?=" |
| declare -rg rex_legal_holder_assignment_lhs=\ |
| "$rex_legal_holder_variable$rex_legal_holder_assignment_op\"" |
| declare -rg rex_illegal_holder_assignment_rhs=".+[^\\]\".+" |
| declare -rg dynamic_typedef="local -r" |
| declare -rg rex_legal_dynamic_typedef="local[[:space:]]\-r" |
| declare -rg rex_legal_dynamic_assignment_lhs=\ |
| "$rex_legal_dynamic_typedef $rex_legal_holder_assignment_lhs" |
| declare -rg head_tag=">>>>>" |
| declare -rg foot_tag="<<<<<" |
| declare -rg rex_legal_file_header_tag="#[[:space:]]$head_tag[[:space:]].*" |
| declare -rg rex_legal_file_footer_tag="#[[:space:]]$foot_tag[[:space:]].*" |
| declare -rg rex_legal_manifest_hook_begin="@@MIRROR_BEGIN@@" |
| declare -rg rex_legal_manifest_hook_ended="@@MIRROR_ENDED@@" |
| |
| # Credits |
| declare -rg credits_year="2019" |
| declare -rg credits_author="Luigi Santivetti" |
| declare -rg credits_email="luigi.santivetti@gmail.com" |
| declare -rg credits_vers="1.0 beta" |
| |
| declare -rg license="\ |
| # Copyright ${credits_year} ${credits_author} <${credits_email}> |
| |
| # Permission is hereby granted, free of charge, to any person obtaining a |
| # copy of this software and associated documentation files (the \"Software\"), |
| # to deal in the Software without restriction, including without limitation |
| # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| # and/or sell copies of the Software, and to permit persons to whom the |
| # Software is furnished to do so, subject to the following conditions: |
| |
| # The above copyright notice and this permission notice (including the next |
| # paragraph) shall be included in all copies or substantial portions of the |
| # Software. |
| |
| # THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| # ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| |
| # This file is autogenerated with tod ${credits_vers} and manual edit can break |
| # your instance. Update this file using tod instead, check tod --help." |
| |
| # Logging and debug |
| declare -irg LOG_D="${LOG_D:-0}" |
| declare -irg LOG_I="${LOG_I:-1}" |
| declare -irg LOG_W="${LOG_W:-1}" |
| declare -irg LOG_X="${LOG_X:-1}" |
| |
| # Return codes |
| declare -ir s_ok=0 |
| declare -ir s_err=1 |
| declare -ir s_unbound=2 |
| declare -ir s_maybe_unbound=3 |
| declare -ir s_bound=4 |
| declare -ir s_null=5 |
| declare -ir s_unk_stdout=6 |
| declare -ir s_unk_stderr=7 |
| declare -ir s_inv_lhs=8 |
| declare -ir s_err2=9 |
| declare -ir s_err3=10 |
| declare -ir s_err4=11 |
| declare -ir s_err5=12 |
| declare -ir s_err6=13 |
| declare -ir s_err7=14 |
| declare -ir s_err8=15 |
| declare -ir s_err9=16 |
| declare -ir s_disabled=17 |
| declare -ir s_off_broken=18 |
| declare -ir s_off_usable=19 |
| declare -ir s_maybe_bound=20 |