blob: 3e415eb42a300d964842499232d27cc00a092e2e [file] [log] [blame]
Luigi Santivetti0fdd4702020-06-22 19:00:32 +01001#!/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
26declare -rg script_dir="$(get_script_dir)"
27
28# Runtime timestamp of when this script was executed
29declare -rg script_now="$(get_script_now)"
30
31# Version file name
32declare -rg __version="version"
33
34# Module staging area name
35declare -rg staging="staging"
36
37# Name of this host's instance, it defaults to localhost
38declare -rg def_hostname="localhost"
39declare -rg host_name="${HOST_NAME:-$def_hostname}"
40
41# Switch for enabling debug features, it defaults to debug
42declare -rg release="release"
43declare -rg debug="debug"
44declare -rg instance_mode="${INSTANCE_MODE:-$debug}"
45
46# Force to use also blacklisted modules
47declare -rgi modall="${MODALL:-0}"
48
49# Default answer instead of waiting for user input
50declare -rg answer=${DEFANS:-}
51
52# Runtime enabled list of modules
53declare -ag MODULES=( )
54
55# Blacklist modules
56declare -arg BLMODULES=( "test1" "test2" )
57
58# Runtime running option
59declare -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
65declare -rg def_instance_d="$script_dir/$host_name"
Luigi Santivetti6273bf22020-11-01 23:10:21 +000066declare -rg instance_d="${INSTANCE_DIR-$def_instance_d}"
Luigi Santivetti0fdd4702020-06-22 19:00:32 +010067declare -rg docker_d="$instance_d/docker"
68declare -rg rootfs_d="$instance_d/rootfs"
69
70# Module tree
71declare -rg module_d="$script_dir/module"
72declare -rg scheme_sh="scheme.sh"
73declare -rg holder_sh="holder.sh"
74declare -rg module_sh="module.sh"
75
76# Runtime password file
77declare -rg passwd_sh="${PASSWD_F:-}"
78
79# Module common files
80declare -rg common_sh="$module_d/common.sh"
Luigi Santivetti35de2062020-10-26 09:40:09 +000081declare -rg manifest_f="${MANIFEST_F:-$script_dir/MANIFEST}"
Luigi Santivetti0fdd4702020-06-22 19:00:32 +010082declare -rg uninstall_f="$instance_d/uninstall.sh"
83
84# Set of regular expressions for accomplishing module validation
85declare -rg rex_legal_holder_token="_([0-9]|[A-Z])+"
86declare -rg rex_legal_holder_variable="($rex_legal_holder_token)+_"
87declare -rg rex_legal_holder_assignment_op="[\+]?="
88declare -rg rex_legal_holder_assignment_lhs=\
89"$rex_legal_holder_variable$rex_legal_holder_assignment_op\""
90declare -rg rex_illegal_holder_assignment_rhs=".+[^\\]\".+"
91declare -rg dynamic_typedef="local -r"
92declare -rg rex_legal_dynamic_typedef="local[[:space:]]\-r"
93declare -rg rex_legal_dynamic_assignment_lhs=\
94"$rex_legal_dynamic_typedef $rex_legal_holder_assignment_lhs"
95declare -rg head_tag=">>>>>"
96declare -rg foot_tag="<<<<<"
97declare -rg rex_legal_file_header_tag="#[[:space:]]$head_tag[[:space:]].*"
98declare -rg rex_legal_file_footer_tag="#[[:space:]]$foot_tag[[:space:]].*"
99declare -rg rex_legal_manifest_hook_begin="@@MIRROR_BEGIN@@"
100declare -rg rex_legal_manifest_hook_ended="@@MIRROR_ENDED@@"
101
102# Credits
103declare -rg credits_year="2019"
104declare -rg credits_author="Luigi Santivetti"
105declare -rg credits_email="luigi.santivetti@gmail.com"
106declare -rg credits_vers="1.0 beta"
107
108declare -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
133declare -irg LOG_D="${LOG_D:-0}"
134declare -irg LOG_I="${LOG_I:-1}"
135declare -irg LOG_W="${LOG_W:-1}"
136declare -irg LOG_X="${LOG_X:-1}"
137
138# Return codes
139declare -ir s_ok=0
140declare -ir s_err=1
141declare -ir s_unbound=2
142declare -ir s_maybe_unbound=3
143declare -ir s_bound=4
144declare -ir s_null=5
145declare -ir s_unk_stdout=6
146declare -ir s_unk_stderr=7
147declare -ir s_inv_lhs=8
148declare -ir s_err2=9
149declare -ir s_err3=10
150declare -ir s_err4=11
151declare -ir s_err5=12
152declare -ir s_err6=13
153declare -ir s_err7=14
154declare -ir s_err8=15
155declare -ir s_err9=16
156declare -ir s_disabled=17
157declare -ir s_off_broken=18
158declare -ir s_off_usable=19
159declare -ir s_maybe_bound=20