@@ -63,6 +63,12 @@ HOST_USER="${SUDO_USER:-$USER}"
6363HOST_USER_ID=$(id -u "${HOST_USER}")
6464HOST_GROUP_ID=$(id -g "${HOST_USER}")
6565
66+searx_suite_set_env() {
67+ export FILTRON_API="0.0.0.0:4005"
68+ export FILTRON_LISTEN="0.0.0.0:4004"
69+ export MORTY_LISTEN="0.0.0.0:3000"
70+}
71+
6672# ----------------------------------------------------------------------------
6773usage() {
6874# ----------------------------------------------------------------------------
@@ -74,8 +80,8 @@ usage::
7480 $(basename "$0") build [containers]
7581 $(basename "$0") install [searx-suite]
7682 $(basename "$0") remove [containers|subordinate]
77− $(basename "$0") [start|stop] [containers]
78− $(basename "$0") inspect [info|config]
83+ $(basename "$0") [start|stop] [containers|<container-name>]
84+ $(basename "$0") show [info|config|searx-suite]
7985 $(basename "$0") cmd ...
8086
8187build / remove
@@ -83,10 +89,11 @@ build / remove
8389add / remove
8490 :subordinate: lxd permission to map ${HOST_USER}'s user/group id through
8591start/stop
86− :containers: start/stop of all containers
87−inspect
88− :info: show info of all containers
89− :config: show config of all containers
92+ :containers: start/stop of all 'containers' or only <container-name>
93+show
94+ :info: show info of all containers
95+ :config: show config of all containers
96+ :searx-suite: show searx-suite services of all containers
9097cmd ...
9198 run commandline ... in all containers
9299install
@@ -116,22 +123,10 @@ main() {
116123 local exit_val
117124 local _usage="unknown or missing $1 command $2"
118125
119− case $1 in
120− __install)
121− sudo_or_exit
122− case $2 in
123− searx-suite) install_searx_suite ;;
124− esac
125− exit
126− ;;
127− *)
128− if ! required_commands lxc; then
129− lxd_info
130− exit 42
131− fi
132− ;;
133− esac
134−
126+ if [[ ! $1 == __* ]] && ! required_commands lxc; then
127+ lxd_info
128+ exit 42
129+ fi
135130 case $1 in
136131 --source-only) ;;
137132 -h|--help) usage; exit 0;;
@@ -141,20 +136,23 @@ main() {
141136 case $2 in
142137 containers) build_instances ;;
143138 *) usage "$_usage"; exit 42;;
144− esac ;;
139+ esac
140+ ;;
145141 remove)
146142 sudo_or_exit
147143 case $2 in
148144 containers) remove_instances ;;
149145 subordinate) echo; del_subordinate_ids ;;
150146 *) usage "$_usage"; exit 42;;
151− esac ;;
147+ esac
148+ ;;
152149 add)
153150 sudo_or_exit
154151 case $2 in
155152 subordinate) echo; add_subordinate_ids ;;
156153 *) usage "$_usage"; exit 42;;
157− esac ;;
154+ esac
155+ ;;
158156 start|stop)
159157 sudo_or_exit
160158 case $2 in
@@ -163,14 +161,27 @@ main() {
163161 info_msg "lxc $1 $2"
164162 lxc "$1" "$2" | prefix_stdout "[${_BBlue}${i}${_creset}] "
165163 ;;
166− esac ;;
167− inspect)
164+ esac
165+ ;;
166+ show)
168167 sudo_or_exit
169168 case $2 in
170169 config) lxc_cmd config show;;
171170 info) lxc_cmd info;;
171+ searx-suite)
172+ for i in "${LOCAL_IMAGES[@]}"; do
173+ info_msg "[${_BBlue}${i}${_creset}] ${_BGreen}${LXC_REPO_ROOT}/utils/lxc.sh install $2${_creset}"
174+ lxc exec -t "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show "$2" | prefix_stdout "[${i}] "
175+ done
176+ ;;
172177 *) usage "$_usage"; exit 42;;
173− esac ;;
178+ esac
179+ ;;
180+ __show)
181+ case $2 in
182+ searx-suite) searx_suite_info ;;
183+ esac
184+ ;;
174185 cmd)
175186 sudo_or_exit
176187 shift
@@ -192,30 +203,55 @@ main() {
192203 searx-suite)
193204 for i in "${LOCAL_IMAGES[@]}"; do
194205 info_msg "[${_BBlue}${i}${_creset}] ${_BGreen}${LXC_REPO_ROOT}/utils/lxc.sh install $2${_creset}"
195− lxc exec "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2"
206+ lxc exec -t "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2" | prefix_stdout "[${i}] "
196207 done
197208 ;;
198209 *) usage "$_usage"; exit 42;;
199− esac ;;
210+ esac
211+ ;;
212+ __install)
213+ case $2 in
214+ searx-suite) searx_suite_install ;;
215+ esac
216+ ;;
200217 *)
201218 usage "unknown or missing command $1"; exit 42;;
202219 esac
203220}
204221
205−install_searx_suite() {
206− export FILTRON_API="0.0.0.0:4005"
207− export FILTRON_LISTEN="0.0.0.0:4004"
208− export MORTY_LISTEN="0.0.0.0:3000"
209− FORCE_TIMEOUT=0 "${LXC_REPO_ROOT}/utils/searx.sh" install all
210− FORCE_TIMEOUT=0 "${LXC_REPO_ROOT}/utils/morty.sh" install all
211− FORCE_TIMEOUT=0 "${LXC_REPO_ROOT}/utils/filtron.sh" install all
212− rst_title "[$(hostname)] searx-suite installation finished" part
213− rst_para "IPs of the container ..."
214− echo
215− ip addr show | grep "inet\s*[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*"
216− echo
222+searx_suite_install() {
223+ (
224+ searx_suite_set_env
225+ export FORCE_TIMEOUT=0
226+ "${LXC_REPO_ROOT}/utils/searx.sh" install all
227+ "${LXC_REPO_ROOT}/utils/morty.sh" install all
228+ "${LXC_REPO_ROOT}/utils/filtron.sh" install all
229+
230+ rst_title "searx-suite installation finished ($(hostname))" part
231+ searx_suite_info
232+ echo
233+ )
217234}
218235
236+searx_suite_info() {
237+ (
238+ searx_suite_set_env
239+ rst_para "Services of the container $(hostname)"
240+ for ip in $(hostname -I); do
241+ echo
242+ if [[ $ip =~ .*:.* ]]; then
243+ :
244+ # IPv6: not yet implemented / tested
245+ # echo " searx (filtron) --> http://[$ip]:4004/"
246+ # echo " morty --> http://[$ip]:3000/"
247+ else
248+ # IPv4:
249+ echo " searx (filtron) --> http://$ip:4004/"
250+ echo " morty --> http://$ip:3000/"
251+ fi
252+ done
253+ )
254+}
219255
220256build_instances() {
221257 rst_title "Build LXC instances"