Luigi Santivetti | 0fdd470 | 2020-06-22 19:00:32 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # config - for tod |
| 4 | # |
| 5 | # Copyright 2019 Luigi Santivetti <luigi.santivetti@gmail.com> |
| 6 | |
| 7 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | # copy of this software and associated documentation files (the "Software"), |
| 9 | # to deal in the Software without restriction, including without limitation |
| 10 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | # and/or sell copies of the Software, and to permit persons to whom the |
| 12 | # Software is furnished to do so, subject to the following conditions: |
| 13 | |
| 14 | # The above copyright notice and this permission notice (including the next |
| 15 | # paragraph) shall be included in all copies or substantial portions of the |
| 16 | # Software. |
| 17 | |
| 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 21 | # ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 22 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | |
| 25 | # Absolute path to where this script lives |
| 26 | declare -rg script_dir="$(get_script_dir)" |
| 27 | |
| 28 | # Runtime timestamp of when this script was executed |
| 29 | declare -rg script_now="$(get_script_now)" |
| 30 | |
| 31 | # Version file name |
| 32 | declare -rg __version="version" |
| 33 | |
| 34 | # Module staging area name |
| 35 | declare -rg staging="staging" |
| 36 | |
| 37 | # Name of this host's instance, it defaults to localhost |
| 38 | declare -rg def_hostname="localhost" |
| 39 | declare -rg host_name="${HOST_NAME:-$def_hostname}" |
| 40 | |
| 41 | # Switch for enabling debug features, it defaults to debug |
| 42 | declare -rg release="release" |
| 43 | declare -rg debug="debug" |
| 44 | declare -rg instance_mode="${INSTANCE_MODE:-$debug}" |
| 45 | |
| 46 | # Force to use also blacklisted modules |
| 47 | declare -rgi modall="${MODALL:-0}" |
| 48 | |
| 49 | # Default answer instead of waiting for user input |
| 50 | declare -rg answer=${DEFANS:-} |
| 51 | |
| 52 | # Runtime enabled list of modules |
| 53 | declare -ag MODULES=( ) |
| 54 | |
| 55 | # Blacklist modules |
| 56 | declare -arg BLMODULES=( "test1" "test2" ) |
| 57 | |
| 58 | # Runtime running option |
| 59 | declare -Ag OPTIONS=( \ |
| 60 | [check]=0 [watch]=0 [fetch]=0 [doall]=0 [doins]=0 \ |
| 61 | [upins]=0 [upmod]=0 [upall]=0 [clmod]=0 [clins]=0 \ |
| 62 | ) |
| 63 | |
| 64 | # Instance tree |
| 65 | declare -rg def_instance_d="$script_dir/$host_name" |
Luigi Santivetti | 6273bf2 | 2020-11-01 23:10:21 +0000 | [diff] [blame] | 66 | declare -rg instance_d="${INSTANCE_DIR-$def_instance_d}" |
Luigi Santivetti | 0fdd470 | 2020-06-22 19:00:32 +0100 | [diff] [blame] | 67 | declare -rg docker_d="$instance_d/docker" |
| 68 | declare -rg rootfs_d="$instance_d/rootfs" |
| 69 | |
| 70 | # Module tree |
| 71 | declare -rg module_d="$script_dir/module" |
| 72 | declare -rg scheme_sh="scheme.sh" |
| 73 | declare -rg holder_sh="holder.sh" |
| 74 | declare -rg module_sh="module.sh" |
| 75 | |
| 76 | # Runtime password file |
| 77 | declare -rg passwd_sh="${PASSWD_F:-}" |
| 78 | |
| 79 | # Module common files |
| 80 | declare -rg common_sh="$module_d/common.sh" |
Luigi Santivetti | 35de206 | 2020-10-26 09:40:09 +0000 | [diff] [blame] | 81 | declare -rg manifest_f="${MANIFEST_F:-$script_dir/MANIFEST}" |
Luigi Santivetti | 0fdd470 | 2020-06-22 19:00:32 +0100 | [diff] [blame] | 82 | declare -rg uninstall_f="$instance_d/uninstall.sh" |
| 83 | |
| 84 | # Set of regular expressions for accomplishing module validation |
| 85 | declare -rg rex_legal_holder_token="_([0-9]|[A-Z])+" |
| 86 | declare -rg rex_legal_holder_variable="($rex_legal_holder_token)+_" |
| 87 | declare -rg rex_legal_holder_assignment_op="[\+]?=" |
| 88 | declare -rg rex_legal_holder_assignment_lhs=\ |
| 89 | "$rex_legal_holder_variable$rex_legal_holder_assignment_op\"" |
| 90 | declare -rg rex_illegal_holder_assignment_rhs=".+[^\\]\".+" |
| 91 | declare -rg dynamic_typedef="local -r" |
| 92 | declare -rg rex_legal_dynamic_typedef="local[[:space:]]\-r" |
| 93 | declare -rg rex_legal_dynamic_assignment_lhs=\ |
| 94 | "$rex_legal_dynamic_typedef $rex_legal_holder_assignment_lhs" |
| 95 | declare -rg head_tag=">>>>>" |
| 96 | declare -rg foot_tag="<<<<<" |
| 97 | declare -rg rex_legal_file_header_tag="#[[:space:]]$head_tag[[:space:]].*" |
| 98 | declare -rg rex_legal_file_footer_tag="#[[:space:]]$foot_tag[[:space:]].*" |
| 99 | declare -rg rex_legal_manifest_hook_begin="@@MIRROR_BEGIN@@" |
| 100 | declare -rg rex_legal_manifest_hook_ended="@@MIRROR_ENDED@@" |
| 101 | |
| 102 | # Credits |
| 103 | declare -rg credits_year="2019" |
| 104 | declare -rg credits_author="Luigi Santivetti" |
| 105 | declare -rg credits_email="luigi.santivetti@gmail.com" |
| 106 | declare -rg credits_vers="1.0 beta" |
| 107 | |
| 108 | declare -rg license="\ |
| 109 | # Copyright ${credits_year} ${credits_author} <${credits_email}> |
| 110 | |
| 111 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 112 | # copy of this software and associated documentation files (the \"Software\"), |
| 113 | # to deal in the Software without restriction, including without limitation |
| 114 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 115 | # and/or sell copies of the Software, and to permit persons to whom the |
| 116 | # Software is furnished to do so, subject to the following conditions: |
| 117 | |
| 118 | # The above copyright notice and this permission notice (including the next |
| 119 | # paragraph) shall be included in all copies or substantial portions of the |
| 120 | # Software. |
| 121 | |
| 122 | # THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 123 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 124 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 125 | # ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 126 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 127 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 128 | |
| 129 | # This file is autogenerated with tod ${credits_vers} and manual edit can break |
| 130 | # your instance. Update this file using tod instead, check tod --help." |
| 131 | |
| 132 | # Logging and debug |
| 133 | declare -irg LOG_D="${LOG_D:-0}" |
| 134 | declare -irg LOG_I="${LOG_I:-1}" |
| 135 | declare -irg LOG_W="${LOG_W:-1}" |
| 136 | declare -irg LOG_X="${LOG_X:-1}" |
| 137 | |
| 138 | # Return codes |
| 139 | declare -ir s_ok=0 |
| 140 | declare -ir s_err=1 |
| 141 | declare -ir s_unbound=2 |
| 142 | declare -ir s_maybe_unbound=3 |
| 143 | declare -ir s_bound=4 |
| 144 | declare -ir s_null=5 |
| 145 | declare -ir s_unk_stdout=6 |
| 146 | declare -ir s_unk_stderr=7 |
| 147 | declare -ir s_inv_lhs=8 |
| 148 | declare -ir s_err2=9 |
| 149 | declare -ir s_err3=10 |
| 150 | declare -ir s_err4=11 |
| 151 | declare -ir s_err5=12 |
| 152 | declare -ir s_err6=13 |
| 153 | declare -ir s_err7=14 |
| 154 | declare -ir s_err8=15 |
| 155 | declare -ir s_err9=16 |
| 156 | declare -ir s_disabled=17 |
| 157 | declare -ir s_off_broken=18 |
| 158 | declare -ir s_off_usable=19 |
| 159 | declare -ir s_maybe_bound=20 |