Compare commits
16 Commits
docker_too
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 831f96e001 | |||
| 3b9b07fdf3 | |||
| 76d58b74a2 | |||
| 925dda5d5b | |||
| 7b50783d3c | |||
| eebfc99b24 | |||
| 4e2f7b927d | |||
| bf1177c71a | |||
| 22d7d17cd0 | |||
| b7170807d5 | |||
| 69b26b35bf | |||
| 7278a536fd | |||
| ae36bab6ec | |||
| 7a4ee6f87f | |||
| 57fc0d82a5 | |||
| 1ffaa822e6 |
1
COPYING.LESSER
Symbolic link
1
COPYING.LESSER
Symbolic link
@@ -0,0 +1 @@
|
||||
GNU_LGPL-3.0.txt
|
||||
165
GNU_LGPL-3.0.txt
Normal file
165
GNU_LGPL-3.0.txt
Normal file
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
20
ReadMe.txt
20
ReadMe.txt
@@ -5,15 +5,27 @@ Welcome to Rx3-Docker/Docker Tools!
|
||||
This project aims to give some basic tools to be used by other Rx3 docker packaging projects.
|
||||
|
||||
Features:
|
||||
- docker_tools_install & docker_mk_dir to setup a new application environment,
|
||||
- docker_mk_env command to compile env file into .env file,
|
||||
- docker_start, docker_stop & docker_logs command,
|
||||
- docker_start, docker_stop , docker_restart & docker_logs command,
|
||||
- docker_network_up & docker_network_down automatically called to setup external network rule & route,
|
||||
- docker_service_add env file function,
|
||||
- docker_build_push.
|
||||
- docker_build_push & docker_sbs (Stop / Build / Start),
|
||||
- mk_base_image to build a base image,
|
||||
- distributed in two RPM packages: docker_tools & docker_tools-devel.
|
||||
|
||||
Support different mounted volume modes:
|
||||
- Single,
|
||||
- Merged, (Old mode)
|
||||
- Splited. (Default)
|
||||
- Mixed (Old mode),
|
||||
- Merged,
|
||||
- Splited (Default).
|
||||
|
||||
|
||||
|
||||
Docker Tools is licensed under the LGPL/GPL GNU Licenses.
|
||||
For more information, please read the corresponding source file headers.
|
||||
The license details can be found in the GNU-GPL.txt, GNU-LGPL.txt and GNU-FDL.txt files.
|
||||
|
||||
|
||||
|
||||
Enjoy it!
|
||||
|
||||
@@ -1,10 +1,96 @@
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.5.0 - A. GIBERT - 2026/03/29
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add mk_base_image script,
|
||||
- Add mk_base_image bash completion config,
|
||||
- Add GPL headers,
|
||||
- Add SPEC files to generate docker_tools & docker_tools-devel RPM packages,
|
||||
- Now support rx3-base 1.1.0.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.4.1 - A. GIBERT - 2026/02/28
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add docker_restart & docker_sbs scripts.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.4.0 - A. GIBERT - 2025/08/06
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add docker_network_up & docker_network_down scripts called by docker_start & docker_stop,
|
||||
- Add cd in script to allow external docker application dir call.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.7 - A. GIBERT - 2025/03/31
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Remove ${service_name} == ${APPL_NAME} exception handling for *_IMG_URL.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.6 - A. GIBERT - 2025/01/31
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add a new DOCKER_TOOLS_USER_GROUP_FORCE env variable support.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.5 - A. GIBERT - 2025/01/24
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add a new DOCKER_TOOLS_VOLUME mode: "MIXED".
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.4 - A. GIBERT - 2025/01/13
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Replace ENV_SED by ENV_NET_SED environment variable.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.3 - A. GIBERT - 2025/01/05
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add DOCKER_TOOLS_EXEPTION_LOGS env variable support,
|
||||
- Remove .env.sed file obsoleted by ENV_SED environment variable.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.2 - A. GIBERT - 2024/12/27
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add docker_config_add function for docker_mk_env to support config file generation.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.1 - A. GIBERT - 2024/12/14
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Add docker_mk_dir & docker_tools_install commands.
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
Rx3-Docker/Docker Tools V 1.3.0 - A. GIBERT - 2024/11/26
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
- Improve docker_service_add function,
|
||||
- Switch by default to splited volume mode,
|
||||
- Add DOCKER_TOOLS_DEBUG, DOCKER_TOOLS_VOLUME & DOCKER_TOOLS_EXECPTION_LIBS env variable support.
|
||||
- Add DOCKER_TOOLS_DEBUG, DOCKER_TOOLS_VOLUME & DOCKER_TOOLS_EXEPTION_LIBS env variable support.
|
||||
- Warning: API break!
|
||||
|
||||
|
||||
|
||||
178
SPECS/docker_tools.spec
Normal file
178
SPECS/docker_tools.spec
Normal file
@@ -0,0 +1,178 @@
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Tools
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
%define name docker_tools
|
||||
%define version 1.5.0
|
||||
%define release %mkrel 1rx3
|
||||
|
||||
%global debug_package %{nil}
|
||||
|
||||
|
||||
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Summary: Rx3 Docker Management Tools
|
||||
License: GPL
|
||||
URL: https://git.rx3.org/gitea/rx3/%{name}
|
||||
|
||||
Source0: https://git.rx3.org/gitea/rx3/%{name}/archive/%{name}-%{version}.tar.gz
|
||||
|
||||
Distribution: Rx3 Free Software
|
||||
Vendor: Rx3
|
||||
Packager: Arnaud G. GIBERT <arnaud@rx3.net>
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
Requires: rx3-base
|
||||
|
||||
%description
|
||||
This project aims to give some basic tools to be used by other Rx3 docker packaging projects
|
||||
|
||||
Features:
|
||||
- docker_tools_install & docker_mk_dir to setup a new application environment,
|
||||
- docker_mk_env command to compile env file into .env file,
|
||||
- docker_start, docker_stop , docker_restart & docker_logs command,
|
||||
- docker_network_up & docker_network_down automatically called to setup external network rule & route,
|
||||
- docker_service_add env file function,
|
||||
- docker_build_push & docker_sbs (Stop / Build / Start),
|
||||
- mk_base_image to build a base image,
|
||||
- distributed in two RPM packages: docker_tools & docker_tools-devel.
|
||||
|
||||
Support different mounted volume modes:
|
||||
- Single,
|
||||
- Mixed (Old mode),
|
||||
- Merged,
|
||||
- Splited (Default).
|
||||
|
||||
|
||||
|
||||
%package devel
|
||||
Summary: Meta Package Manager - Server repository
|
||||
Requires: rx3-base
|
||||
Requires: buildah
|
||||
|
||||
%description devel
|
||||
This project aims to give some basic tools to be used by other Rx3 docker packaging projects.
|
||||
|
||||
This is de development package, only needed for image creation.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Prep
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Build
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
%build
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Install
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
%install
|
||||
|
||||
# Bash completion
|
||||
%{__mkdir_p} %{buildroot}%{_sysconfdir}/bash_completion.d
|
||||
cp etc/bash_completion.d/* %{buildroot}%{_sysconfdir}/bash_completion.d
|
||||
|
||||
# Lib
|
||||
%{__mkdir_p} %{buildroot}%{_prefix}/lib/rx3
|
||||
cp usr/lib/rx3/*.bash %{buildroot}%{_prefix}/lib/rx3
|
||||
|
||||
# Bin
|
||||
%{__mkdir_p} %{buildroot}%{_sbindir}
|
||||
cp sbin/* %{buildroot}%{_sbindir}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Check
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
%check
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Files
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
%files
|
||||
%doc ReadMe.txt ReleaseNotes.txt ToDo.txt
|
||||
%license COPYING COPYING.LESSER GNU_GPL-3.0.txt GNU_LGPL-3.0.txt GNU_FDL-1.3.txt
|
||||
%defattr(0644,root,root)
|
||||
%{_prefix}/lib/rx3/*
|
||||
%defattr(0755,root,root)
|
||||
%{_sbindir}/docker_logs
|
||||
%{_sbindir}/docker_mk_env
|
||||
%{_sbindir}/docker_network_*
|
||||
%{_sbindir}/docker_restart
|
||||
%{_sbindir}/docker_start
|
||||
%{_sbindir}/docker_stop
|
||||
%{_sbindir}/docker_tools_install
|
||||
|
||||
|
||||
|
||||
%files devel
|
||||
%defattr(644,root,root)
|
||||
%{_sysconfdir}/bash_completion.d/mk_base_image
|
||||
%defattr(0755,root,root)
|
||||
%{_sbindir}/docker_build_push
|
||||
%{_sbindir}/docker_mk_dir
|
||||
%{_sbindir}/docker_sbs
|
||||
%{_sbindir}/mk_base_image
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# ChangeLog
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
%changelog
|
||||
* Sun Mar 29 2026 Arnaud G. GIBERT <arnaud@rx3.net> - 1.5.0-1rx3.mga9
|
||||
- Create initial SPEC file for 1.5.0 on Mageia 9
|
||||
54
etc/bash_completion.d/mk_base_image
Normal file
54
etc/bash_completion.d/mk_base_image
Normal file
@@ -0,0 +1,54 @@
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Mk Base Image
|
||||
#
|
||||
# Copyright (C) 2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# -*- mode: shell; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
|
||||
|
||||
_mk_base_image() {
|
||||
local cur prev opts lang_opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
# Top-level options
|
||||
opts="--help -h --version -V --post -p --strip -s --unstrip -u --direct -d --lang -l --language -L --localtime -m --root -r --tmp -t --test -T --verbose -v"
|
||||
|
||||
# Handle --lang and --language options
|
||||
lang_opts="en_US.UTF-8 fr_FR.UTF-8 de_DE.UTF-8" # Add your supported languages here
|
||||
|
||||
case "${prev}" in
|
||||
--lang|-l|--language|-L)
|
||||
COMPREPLY=( $(compgen -W "${lang_opts}" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
--localtime|-m|--root|-r|--tmp|-t)
|
||||
COMPREPLY=( $(compgen -f -- "${cur}") ) # Complete with filenames/directories
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
# Default completion: show all top-level options
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _mk_base_image mk_base_image
|
||||
@@ -1,13 +1,57 @@
|
||||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set -o errexit
|
||||
|
||||
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Build Push
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
sbin/docker_mk_env
|
||||
|
||||
|
||||
@@ -1,12 +1,56 @@
|
||||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set -o errexit
|
||||
|
||||
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Logs
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
docker compose logs -f
|
||||
|
||||
81
sbin/docker_mk_dir
Executable file
81
sbin/docker_mk_dir
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Mk Dir
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
grep -e _LOG_ -e _LIB_ .env | grep -e _EXT= | while read line
|
||||
do
|
||||
OIFS=$IFS
|
||||
IFS="="
|
||||
|
||||
set $line
|
||||
|
||||
IFS=$OIFS
|
||||
|
||||
|
||||
grep $1 compose.yaml >/dev/null
|
||||
|
||||
if [[ "$?" == "0" ]]
|
||||
then
|
||||
eval echo $2
|
||||
fi
|
||||
done | sort -u | while read dir
|
||||
do
|
||||
echo "Add/Create: [${dir}]"
|
||||
|
||||
mkdir -p ${dir}
|
||||
echo -e '# Ignore everything in this directory\n*\n# Except this file\n!.gitignore' > ${dir}/.gitignore
|
||||
|
||||
git add ${dir}/.gitignore
|
||||
done
|
||||
|
||||
@@ -1,35 +1,76 @@
|
||||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# DOCKER_TOOLS_DEBUG= TRUE | FALSE # Enable debugging (Default FALSE)
|
||||
#
|
||||
# DOCKER_TOOLS_VOLUME= SINGLE | MERGED | SPLITED # Default: SPLITED
|
||||
# Docker Mk Env
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# DOCKER_TOOLS_DEBUG= TRUE | FALSE # Enable debugging (Default FALSE)
|
||||
#
|
||||
# DOCKER_TOOLS_VOLUME= SINGLE | MIXED | MERGED | SPLITED # Default: SPLITED
|
||||
# SINGLE: Merged volume mode + No service suffix
|
||||
# MERGED: Merged volume mode + Service suffix
|
||||
# MIXED: Merged volume mode + Init/SV log Service suffix
|
||||
# MERGED: Merged volume mode + Full service suffix
|
||||
# SPLITED: By service volume mode + No service suffix
|
||||
#
|
||||
# DOCKER_TOOLS_EXECPTION_LIBS="module_name:lib_dir_name ..."
|
||||
# Example: postgres:pgsq
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# DOCKER_TOOLS_EXEPTION_LIBS="module_name:lib_dir_name ..."
|
||||
# Example: "postgres:pgsq httpd:/var/www/html"
|
||||
#
|
||||
# DOCKER_TOOLS_EXEPTION_LOGS="module_name:log_dir_name ..."
|
||||
# Example: "postgres:web-server:httpd"
|
||||
#
|
||||
# DOCKER_TOOLS_USER_GROUP_FORCE= TRUE | FALSE # Force using curent user / group (Default FALSE)
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
set -o errexit
|
||||
|
||||
if [[ "$DOCKER_TOOLS_DEBUG" == "TRUE" ]]
|
||||
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
|
||||
DYNVAR_LIST="APPL_HOME_DIR"
|
||||
|
||||
version="$1"
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
DYNVAR_LIST="APPL_HOME_DIR"
|
||||
CONFIG_FILE_LIST=""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
function dynvar_export
|
||||
{
|
||||
var=$1
|
||||
@@ -43,7 +84,7 @@ function dynvar_export
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
function psfix_cat
|
||||
{
|
||||
prefix=$1
|
||||
@@ -61,12 +102,12 @@ function psfix_cat
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
function module_lib_name_get
|
||||
{
|
||||
module=$1
|
||||
|
||||
for tup in ${DOCKER_TOOLS_EXECPTION_LIBS}
|
||||
for tup in ${DOCKER_TOOLS_EXEPTION_LIBS}
|
||||
do
|
||||
if [[ "${module}" == "${tup/:*}" ]]
|
||||
then
|
||||
@@ -80,7 +121,26 @@ function module_lib_name_get
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
function module_log_name_get
|
||||
{
|
||||
module=$1
|
||||
|
||||
for tup in ${DOCKER_TOOLS_EXEPTION_LOGS}
|
||||
do
|
||||
if [[ "${module}" == "${tup/:*}" ]]
|
||||
then
|
||||
echo ${tup/*:}
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${module}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
function docker_service_add
|
||||
{
|
||||
varible_prefix="$1"
|
||||
@@ -114,10 +174,10 @@ function docker_service_add
|
||||
|
||||
if [[ "${service_name}" == "${APPL_NAME}" ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}:${target_version}"
|
||||
# dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}:${target_version}"
|
||||
dynvar_export "${varible_prefix}_HOST_NAME" "$( psfix_cat "${HOST_NAME_PREFIX}" "-" "webapp")"
|
||||
else
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}/${target_name}:${target_version}"
|
||||
# dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}/${target_name}:${target_version}"
|
||||
dynvar_export "${varible_prefix}_HOST_NAME" "$( psfix_cat "${HOST_NAME_PREFIX}" "-" "${service_name}")"
|
||||
fi
|
||||
|
||||
@@ -164,29 +224,62 @@ function docker_service_add
|
||||
volume_prefix="./mnt/${service_name}"
|
||||
fi
|
||||
|
||||
if [[ "${DOCKER_TOOLS_VOLUME}" != "MERGED" ]]
|
||||
|
||||
if [[ "${DOCKER_TOOLS_VOLUME}" == "SINGLE" ]] || [[ "${DOCKER_TOOLS_VOLUME}" == "SPLITED" ]]
|
||||
then
|
||||
volume_suffix_ext=""
|
||||
volume_suffix_initsv_ext=""
|
||||
volume_suffix_module_ext=""
|
||||
else
|
||||
volume_suffix_ext="${service_name}"
|
||||
volume_suffix_initsv_ext="${service_name}"
|
||||
|
||||
if [[ "${DOCKER_TOOLS_VOLUME}" == "MIXED" ]]
|
||||
then
|
||||
volume_suffix_module_ext=""
|
||||
else
|
||||
volume_suffix_module_ext="${service_name}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
module_lib_name="$( module_lib_name_get "${module_name}")"
|
||||
|
||||
if [[ "${module_lib_name}" != /* ]]
|
||||
then
|
||||
path_prefix="/var/lib/"
|
||||
else
|
||||
path_prefix=""
|
||||
fi
|
||||
|
||||
dynvar_export "${varible_prefix}_LIB_INT" "/var/lib/${module_lib_name}"
|
||||
dynvar_export "${varible_prefix}_LIB_EXT" "$( psfix_cat "${volume_prefix}/var/lib/${module_lib_name}" "-" "${volume_suffix_ext}")"
|
||||
module_lib_path=${path_prefix}${module_lib_name}
|
||||
|
||||
|
||||
module_log_name="$( module_log_name_get "${module_name}")"
|
||||
|
||||
if [[ "${module_log_name}" != /* ]]
|
||||
then
|
||||
path_prefix="/var/log/"
|
||||
else
|
||||
path_prefix=""
|
||||
fi
|
||||
|
||||
module_log_path=${path_prefix}${module_log_name}
|
||||
|
||||
|
||||
dynvar_export "${varible_prefix}_LIB_INT" "${module_lib_path}"
|
||||
dynvar_export "${varible_prefix}_LIB_EXT" "$( psfix_cat "${volume_prefix}${module_lib_path}" "-" "${volume_suffix_module_ext}")"
|
||||
|
||||
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_INT" "/var/log/init"
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_EXT" "$( psfix_cat "${volume_prefix}/var/log/init" "-" "${volume_suffix_ext}")"
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_EXT" "$( psfix_cat "${volume_prefix}/var/log/init" "-" "${volume_suffix_initsv_ext}")"
|
||||
|
||||
dynvar_export "${varible_prefix}_LOG_SV_INT" "/var/log/supervisor"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_EXT" "$( psfix_cat "${volume_prefix}/var/log/supervisor" "-" "${volume_suffix_ext}")"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_EXT" "$( psfix_cat "${volume_prefix}/var/log/supervisor" "-" "${volume_suffix_initsv_ext}")"
|
||||
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_INT" "/var/log/${module_name}"
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_EXT" "$( psfix_cat "${volume_prefix}/var/log/${module_name}" "-" "${volume_suffix_ext}")"
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_INT" "${module_log_path}"
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_EXT" "$( psfix_cat "${volume_prefix}${module_log_path}" "-" "${volume_suffix_module_ext}")"
|
||||
|
||||
|
||||
|
||||
# Ports
|
||||
|
||||
if [[ "${port_main_int}" != "-" ]]
|
||||
@@ -215,6 +308,11 @@ function docker_service_add
|
||||
user_name="-"
|
||||
user_id="-"
|
||||
else
|
||||
if [[ "${DOCKER_TOOLS_USER_GROUP_FORCE}" == "TRUE" ]]
|
||||
then
|
||||
user_name_id=$( id -u)
|
||||
fi
|
||||
|
||||
if [[ "${user_name_id}" =~ ^[0-9]+$ ]]
|
||||
then
|
||||
user_name="-"
|
||||
@@ -234,6 +332,11 @@ function docker_service_add
|
||||
group_name="-"
|
||||
group_id="-"
|
||||
else
|
||||
if [[ "${DOCKER_TOOLS_USER_GROUP_FORCE}" == "TRUE" ]]
|
||||
then
|
||||
group_name_id=$( id -g)
|
||||
fi
|
||||
|
||||
if [[ "${group_name_id}" =~ ^[0-9]+$ ]]
|
||||
then
|
||||
group_name="-"
|
||||
@@ -250,108 +353,73 @@ function docker_service_add
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
function docker_service_add-12
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
function docker_config_add
|
||||
{
|
||||
varible_prefix="$1"
|
||||
shift
|
||||
|
||||
for var in NAME NAME_FULL URL_PREFIX IMG_NAME APPL_NAME VERSION_EXT VERSION_INT PORT_MAIN_EXT PORT_MAIN_INT PORT_ADMIN_EXT PORT_ADMIN_INT USER_NAME GROUP_NAME
|
||||
do
|
||||
dynvar_export "${varible_prefix}_${var}" "$1"
|
||||
shift
|
||||
done
|
||||
config_file_target="$1"
|
||||
config_file_source="$2"
|
||||
|
||||
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_INT" "/var/log/init"
|
||||
dynvar_export "${varible_prefix}_LOG_INIT_EXT" "./var/log/init-\${${varible_prefix}_NAME}"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_INT" "/var/log/supervisor"
|
||||
dynvar_export "${varible_prefix}_LOG_SV_EXT" "./var/log/supervisor-\${${varible_prefix}_NAME}"
|
||||
|
||||
if [[ $( eval echo \${${varible_prefix}_APPL_NAME}) != "-" ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_LIB_INT" "/var/lib/\${${varible_prefix}_APPL_NAME}"
|
||||
dynvar_export "${varible_prefix}_LIB_EXT" "./var/lib/\${${varible_prefix}_APPL_NAME}"
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_INT" "/var/log/\${${varible_prefix}_APPL_NAME}"
|
||||
dynvar_export "${varible_prefix}_LOG_MAIN_EXT" "./var/log/\${${varible_prefix}_APPL_NAME}"
|
||||
fi
|
||||
|
||||
if [[ $( eval echo \${${varible_prefix}_IMG_NAME}) != "-" ]]
|
||||
then
|
||||
# No Build
|
||||
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_IMG_NAME}:\${${varible_prefix}_VERSION_EXT}"
|
||||
else
|
||||
# Build
|
||||
|
||||
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_NAME}:\${${varible_prefix}_VERSION_EXT}"
|
||||
|
||||
dynvar_export "${varible_prefix}_MODULE_NAME" "\${${varible_prefix}_NAME}"
|
||||
dynvar_export "${varible_prefix}_MODULE_PATH" "src/\${${varible_prefix}_NAME}"
|
||||
fi
|
||||
|
||||
dynvar_export "${varible_prefix}_CONTAINER_NAME" "${CONTAINER_NAME_PREFIX}-\${${varible_prefix}_NAME}"
|
||||
dynvar_export "${varible_prefix}_HOST" "\${${varible_prefix}_CONTAINER_NAME}"
|
||||
|
||||
dynvar_export "${varible_prefix}_PORT_MAIN_EXT" "\$(( \${${varible_prefix}_PORT_MAIN_EXT} + ${PORT_ENV_OFFSET}))"
|
||||
dynvar_export "${varible_prefix}_PORT_SV_EXT" "\$(( \${${varible_prefix}_PORT_MAIN_EXT} + ${PORT_SV_OFFSET}))"
|
||||
dynvar_export "${varible_prefix}_PORT_SV_INT" "9001"
|
||||
|
||||
if [[ $( eval echo \${${varible_prefix}_PORT_ADMIN_EXT}) != "-" ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_PORT_ADMIN_EXT" "\$(( \${${varible_prefix}_PORT_ADMIN_EXT} + ${PORT_ENV_OFFSET}))"
|
||||
fi
|
||||
|
||||
if [[ $( eval echo \${${varible_prefix}_USER_NAME}) == "-" ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_USER_ID" "-"
|
||||
else
|
||||
if [[ $( eval echo \${${varible_prefix}_USER_NAME}) =~ ^[0-9]+$ ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_USER_ID" "\${${varible_prefix}_USER_NAME}"
|
||||
else
|
||||
dynvar_export "${varible_prefix}_USER_ID" "\$( id -u \${${varible_prefix}_USER_NAME})"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $( eval echo \${${varible_prefix}_GROUP_NAME}) == "-" ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_GROUP_ID" "-"
|
||||
else
|
||||
if [[ $( eval echo \${${varible_prefix}_GROUP_NAME}) =~ ^[0-9]+$ ]]
|
||||
then
|
||||
dynvar_export "${varible_prefix}_GROUP_ID" "\${${varible_prefix}_GROUP_NAME}"
|
||||
else
|
||||
dynvar_export "${varible_prefix}_GROUP_ID" "\$( getent group \${${varible_prefix}_GROUP_NAME} | cut -d: -f3)"
|
||||
fi
|
||||
fi
|
||||
|
||||
dynvar_export "${varible_prefix}_CONTEXT_PATH" "/${APPL_NAME}/\${${varible_prefix}_NAME}/"
|
||||
|
||||
|
||||
# dynvar_export "${varible_prefix}_" "${varible_prefix}_${}"
|
||||
CONFIG_FILE_LIST+=" ${config_file_target}:${config_file_source}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#version="$1"
|
||||
#
|
||||
#if [[ "${version}" != "" ]]
|
||||
#then
|
||||
# APPL_VERSION="$1"
|
||||
#fi
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. ${APPL_HOME_DIR}/env
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${version}" != "" ]]
|
||||
then
|
||||
APPL_VERSION="$1"
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
>${APPL_HOME_DIR}/.env
|
||||
ENV_SED=""
|
||||
ENV_NET_SED=""
|
||||
|
||||
for var in $( ( grep "^ *[a-zA-Z0-9_-]*=" ${APPL_HOME_DIR}/env | sed -e "s/=.*//" -e "s/ *//"; echo ${DYNVAR_LIST} | sed -e 's/ /\n/g') | sort -u)
|
||||
do
|
||||
echo "${var}='${!var}'" >>${APPL_HOME_DIR}/.env
|
||||
if [[ ! -v ${var} ]]
|
||||
then
|
||||
eval ${var}=""
|
||||
fi
|
||||
|
||||
echo "${var}='${!var}'" >>${APPL_HOME_DIR}/.env
|
||||
|
||||
|
||||
pat="s/\${${var}}/${!var//\//\\/}/g
|
||||
"
|
||||
ENV_SED="${ENV_SED}${pat}"
|
||||
|
||||
if [[ ${var} =~ _HOST_ ]] || ( [[ ${var} =~ _PORT_ ]] && [[ ${var} =~ _INT ]])
|
||||
then
|
||||
ENV_NET_SED="${ENV_NET_SED}${pat}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ENV_NET_SED=\'"${ENV_NET_SED}"\' >>${APPL_HOME_DIR}/.env
|
||||
|
||||
|
||||
|
||||
for tupple in ${CONFIG_FILE_LIST}
|
||||
do
|
||||
IFS=":"
|
||||
set ${tupple}
|
||||
|
||||
config_file_target="$1"
|
||||
config_file_source="$2"
|
||||
IFS=" "
|
||||
|
||||
|
||||
sed <${config_file_source} >${config_file_target} -e "${ENV_SED}"
|
||||
done
|
||||
|
||||
63
sbin/docker_network_down
Executable file
63
sbin/docker_network_down
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Network Down
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Init
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${appl_home_dir}
|
||||
|
||||
|
||||
. .env
|
||||
|
||||
if [[ "${NETWORK_TABLE:-}" != "" ]]
|
||||
then
|
||||
if [[ "$( ip rule list | grep "from ${NETWORK_ADDRESS}")" != "" ]]
|
||||
then
|
||||
ip rule del from ${NETWORK_ADDRESS}
|
||||
fi
|
||||
|
||||
if [[ "$( ip route list table ${NETWORK_TABLE} | grep "${NETWORK_SUBNET}")" != "" ]]
|
||||
then
|
||||
ip route del ${NETWORK_SUBNET} table ${NETWORK_TABLE}
|
||||
fi
|
||||
fi
|
||||
65
sbin/docker_network_up
Executable file
65
sbin/docker_network_up
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Network Up
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
. .env
|
||||
|
||||
if [[ "${NETWORK_TABLE:-}" != "" ]]
|
||||
then
|
||||
sbin/docker_network_down
|
||||
|
||||
ip rule add from ${NETWORK_ADDRESS} table ${NETWORK_TABLE}
|
||||
|
||||
ip route add ${NETWORK_SUBNET} dev ${NETWORK_IF_NAME} table ${NETWORK_TABLE}
|
||||
fi
|
||||
58
sbin/docker_restart
Executable file
58
sbin/docker_restart
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker ReStart
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
sbin/docker_stop
|
||||
|
||||
sbin/docker_start
|
||||
60
sbin/docker_sbs
Executable file
60
sbin/docker_sbs
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker SBS (Stop Build Start)
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
sbin/docker_stop
|
||||
|
||||
sbin/docker_build_push
|
||||
|
||||
sbin/docker_start
|
||||
@@ -1,15 +1,61 @@
|
||||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set -o errexit
|
||||
|
||||
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Start
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
sbin/docker_mk_env
|
||||
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
docker compose up -d
|
||||
|
||||
sbin/docker_network_up
|
||||
|
||||
@@ -1,12 +1,58 @@
|
||||
#!/bin/bash
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
set -o errexit
|
||||
|
||||
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Stop
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
|
||||
docker compose down
|
||||
|
||||
sbin/docker_network_down
|
||||
|
||||
107
sbin/docker_tools_install
Executable file
107
sbin/docker_tools_install
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Tools Install
|
||||
#
|
||||
# Copyright (C) 2024-2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# Include
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if [[ "${DOCKER_TOOLS_DEBUG:-}" == "TRUE" ]]
|
||||
then
|
||||
set -x
|
||||
fi
|
||||
|
||||
dt_appl_home_get "${1:-}"
|
||||
|
||||
DOCKER_TOOLS_HOME_DIR="$(dirname "$(dirname "$0")")"
|
||||
|
||||
|
||||
|
||||
if [[ "${1:-}" == "" ]]
|
||||
then
|
||||
APPL_HOME_DIR="$PWD"
|
||||
else
|
||||
APPL_HOME_DIR="${1}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Link Create
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
function link_create
|
||||
{
|
||||
source="$1"
|
||||
target="$2"
|
||||
|
||||
if [[ -d "$target" ]]
|
||||
then
|
||||
real_target=${target}/$( basename "${source}")
|
||||
else
|
||||
real_target=${target}
|
||||
fi
|
||||
|
||||
if [[ -e "${real_target}" ]]
|
||||
then
|
||||
mv ${real_target} ${real_target}.old
|
||||
fi
|
||||
|
||||
ln -s ${source} ${target}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Main
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
cd ${APPL_HOME_DIR}
|
||||
|
||||
#docker_tools_home_dir=$( realpath --relative-to ${APPL_HOME_DIR} ${DOCKER_TOOLS_HOME_DIR})
|
||||
|
||||
docker_tools_home_dir=$( realpath ${DOCKER_TOOLS_HOME_DIR})
|
||||
|
||||
|
||||
#link_create ${docker_tools_home_dir}/sbin .
|
||||
|
||||
mkdir ${docker_tools_home_dir}/sbin
|
||||
for cmd in docker_build_push docker_logs docker_mk_dir docker_mk_env docker_network_down docker_network_up docker_restart docker_sbs docker_start docker_stop
|
||||
do
|
||||
ln -s /usr/sbin/${cmd} ${docker_tools_home_dir}/sbin
|
||||
done
|
||||
|
||||
|
||||
link_create env.dist env
|
||||
447
sbin/mk_base_image
Executable file
447
sbin/mk_base_image
Executable file
@@ -0,0 +1,447 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Mk Base Image
|
||||
#
|
||||
# Copyright (C) 2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/docker_tools.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Global Variables
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
declare -g VERSION=1.0.0
|
||||
declare -g NAME="MBI"
|
||||
declare -g HELP="usage: mk_base_image [[-h | --help] | [-V | --version] | [-p | --post] | [-s | --strip] | [-u | --unstrip]] [-d | --direct] [-l | --lang <Lang>] [-L | --language <Langage>] [-m | --localtime <Local_Time>] [-r | --root <Root_Dir>] [-t | --tmp <Tmp_Dir>] [-T | --test] [-v | --verbose]"
|
||||
|
||||
declare -g CONTAINER_NAME="rx3-mageia9"
|
||||
declare -g TMP_DIR_DEF="/tmp/mk_base_image"
|
||||
declare -g ROOT_DIR_DEF="/var/tmp/base_root"
|
||||
|
||||
declare -g LANG_DEF='en_US.UTF-8'
|
||||
declare -g LANGUAGE_DEF='en_US.UTF-8:en_US:en'
|
||||
declare -g LOCALTIME_DEF='Europe/Paris'
|
||||
|
||||
declare -g NAME_SERVER_0='10.10.0.254'
|
||||
declare -g NAME_SERVER_1='8.8.8.8'
|
||||
|
||||
declare -g MIRRORLIST_MGA='http://mirror.xor.rx3/mageia/distrib/9/x86_64 https://mirror.rx3.net/mageia/distrib/9/x86_64 ftp://ftp.proxad.net/mirrors/mageia.org/distrib/9/x86_64 http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/9/x86_64'
|
||||
declare -g MIRRORLIST_RX3='http://mirror.xor.rx3/rx3/distrib/9/x86_64 https://mirror.rx3.net/rx3/distrib/9/x86_64'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Func Exec
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function mbi_func_exec()
|
||||
{
|
||||
func="$1"
|
||||
arg="$2"
|
||||
name="$3"
|
||||
|
||||
|
||||
if [[ "${direct}" != "true" ]] || [[ "${root_dir}" != "/" ]]
|
||||
then
|
||||
error_echo "Only direct ${name} and / Root Dir supported: Recall..."
|
||||
|
||||
cmd_exec 'chroot "${root_dir}" '"mk_base_image ${arg} --direct --root / ${RECALL_OPTS}"
|
||||
else
|
||||
set +e
|
||||
|
||||
# find / 2>/dev/null | grep -v -e "^/dev" -e "^/proc" -e "^/run" -e "^/sys/" >/root/before
|
||||
|
||||
declare -f ${func} | sed -n '/^{/,/^}/p' | sed -e '1d;$d' -e 's/;$//' | grep -v -E '^$|^#' | while read -r line
|
||||
do
|
||||
cmd_exec "${line}"
|
||||
done
|
||||
|
||||
# find / 2>/dev/null | grep -v -e "^/dev" -e "^/proc" -e "^/run" -e "^/sys/" >/root/after
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Version
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function mbi_version_print()
|
||||
{
|
||||
version_print
|
||||
# echo "MBI Version: [${VERSION}]"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Help
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function mbi_help_print()
|
||||
{
|
||||
mbi_version_print
|
||||
help_print
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Arg Parse
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function mbi_args_parse()
|
||||
{
|
||||
mode="default"
|
||||
verbose="false"
|
||||
dry_run="false"
|
||||
direct="false"
|
||||
|
||||
|
||||
tmp_args=$(getopt -o dhl:L:m:pr:Tt:suvV --long direct,help,lang:,language:,localtime:,post,root:,test,tmp:,strip,unstrip,verbose,version -- "$@")
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$tmp_args': they are essential!
|
||||
eval set -- "${tmp_args}"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
|
||||
# Options
|
||||
-d|--direct) direct="true"; shift;;
|
||||
|
||||
# Locale options
|
||||
-l|--lang) shift; lang="$1"; shift; RECALL_OPTS+=" --lang ${lang}";;
|
||||
-L|--language) shift; language="$1"; shift; RECALL_OPTS+=" --language ${language}";;
|
||||
-m|--localtime) shift; localtime="$1"; shift; RECALL_OPTS+=" --localtime ${localtime}";;
|
||||
|
||||
# Path options
|
||||
-t|--tmp) shift; tmp_dir="$1"; shift;;
|
||||
-r|--root) shift; root_dir="$1"; shift;;
|
||||
|
||||
# Mode switches
|
||||
-h|--help) mode="exit"; mbi_help_print; shift;;
|
||||
-s|--post) mode="post"; shift;;
|
||||
-s|--strip) mode="strip"; shift;;
|
||||
-u|--unstrip) mode="unstrip"; shift;;
|
||||
-V|--version) mode="exit"; mbi_version_print; shift;;
|
||||
|
||||
# Global options
|
||||
-T|--test) dry_run="true"; shift;;
|
||||
-v|--verbose) verbose="true"; shift; RECALL_OPTS+=" --verbose";;
|
||||
|
||||
#
|
||||
--) shift; break;;
|
||||
*) echo "args_parse internal error [$1] !"; exit 1;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Env Init
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function mbi_env_init()
|
||||
{
|
||||
root_clean="$1"
|
||||
|
||||
|
||||
if [[ -d "${tmp_dir}" ]]
|
||||
then
|
||||
error_echo "Removing Tmp Dir: [${tmp_dir}] content..."
|
||||
cmd_exec "echo rm -R \"${tmp_dir}/*\""
|
||||
else
|
||||
error_echo "Creating Tmp Dir: [${tmp_dir}]..."
|
||||
cmd_exec "mkdir -p \"${tmp_dir}\""
|
||||
fi
|
||||
|
||||
if [[ "${direct}" == "true" ]]
|
||||
then
|
||||
if [[ -d "${root_dir}" ]]
|
||||
then
|
||||
if [[ "${root_clean}" == "true" ]]
|
||||
then
|
||||
error_echo "Removing Root Dir: [${root_dir}] content..."
|
||||
cmd_exec "echo rm -R \"${root_dir}/*\""
|
||||
else
|
||||
error_echo "Keeping Root Dir content..."
|
||||
fi
|
||||
else
|
||||
if [[ "${root_clean}" == "true" ]]
|
||||
then
|
||||
error_echo "Creating Root Dir: [${root_dir}]..."
|
||||
cmd_exec "mkdir -p \"${root_dir}\""
|
||||
else
|
||||
error_echo "Error: Root Dir: [${root_dir}] not found!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [[ "${root_clean}" == "true" ]]
|
||||
then
|
||||
if [[ $( buildah ls | grep ${CONTAINER_NAME}) != "" ]]
|
||||
then
|
||||
cmd_exec "buildah rm \"${CONTAINER_NAME}\" >/dev/null"
|
||||
fi
|
||||
|
||||
cmd_exec "buildah from --name \"${CONTAINER_NAME}\" scratch >/dev/null"
|
||||
cmd_exec "buildah config --label maintainer=\"Arnaud G. GIBERT <arnaud@rx3.net>\" \"${CONTAINER_NAME}\""
|
||||
else
|
||||
if [[ $( buildah ls | grep ${CONTAINER_NAME}) == "" ]]
|
||||
then
|
||||
error_echo "buildah container: [${CONTAINER_NAME}] not found!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$BUILDAH_ISOLATION" != "rootless" ]]
|
||||
then
|
||||
error_echo "Unsharing..."
|
||||
|
||||
cmd_exec 'buildah unshare "$0" "${orig_args[@]}"'
|
||||
exit $?
|
||||
fi
|
||||
|
||||
root_dir=$(buildah mount ${CONTAINER_NAME})
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Base Install Pre
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function mbi_base_install_pre()
|
||||
{
|
||||
cmd_exec 'urpmi --root ${root_dir} --force --no-install --no-recommends --nolock --reinstall --download-all ${tmp_dir} --downloader curl makedev filesystem curl urpmi rx3-base docker_tools-devel'
|
||||
|
||||
cmd_exec 'rpm --root ${root_dir} --initdb'
|
||||
cmd_exec 'rpm --root ${root_dir} -Uvh --nodeps --noscripts ${tmp_dir}/rpms/filesystem*'
|
||||
cmd_exec 'rm ${tmp_dir}/rpms/filesystem*'
|
||||
|
||||
cmd_exec 'rpm --root ${root_dir} -Uvh --nodeps --noscripts ${tmp_dir}/rpms/makedev*'
|
||||
cmd_exec 'rm ${tmp_dir}/rpms/makedev*'
|
||||
|
||||
cmd_exec 'rpm --root ${root_dir} -Uvh --nodeps ${tmp_dir}/rpms/*'
|
||||
cmd_exec 'rm -R ${tmp_dir}'
|
||||
|
||||
# Enable Neworking
|
||||
cmd_exec 'echo -e "nameserver ${NAME_SERVER_0}\nnameserver ${NAME_SERVER_1}" >"${root_dir}/etc/resolv.conf"'
|
||||
cmd_exec 'echo -e "NETWORKING=yes" >"${root_dir}/etc/sysconfig/network"'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Base Install Post
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function _mbi_base_install_post()
|
||||
{
|
||||
urpmi.addmedia --distrib --mirrorlist "${MIRRORLIST_MGA}"
|
||||
urpmi.addmedia --distrib --mirrorlist "${MIRRORLIST_RX3}"
|
||||
urpmi.update -a
|
||||
|
||||
urpmi --force basesystem-minimal locales locales-en shared-mime-info vim-minimal mpm
|
||||
|
||||
echo -e "LANG=${lang}\nLANGUAGE=${language}" >"${root_dir}/etc/locale.conf"
|
||||
ln -s /usr/share/zoneinfo/${localtime} "${root_dir}/etc/localtime"
|
||||
|
||||
urpmi --force --auto-update
|
||||
}
|
||||
|
||||
|
||||
function mbi_base_install_post()
|
||||
{
|
||||
mbi_func_exec "_mbi_base_install_post" "--post" "post-installing"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Base Strip
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function _mbi_base_strip()
|
||||
{
|
||||
# RPM force uninstall
|
||||
rpm -e --nodeps cracklib-dicts buildah
|
||||
rpm -e dhcp-common dhcp-client cronie-anacron opencontainers-runc lib64gpgme11 gnupg2 lib64ksba8 lib64usb1.0_0 lib64npth0 lib64assuan0
|
||||
|
||||
# Docker mounts tmpfs at /dev and procfs at /proc so we can remove them
|
||||
rm -rf /dev /proc 2>/tmp/null
|
||||
mkdir -p /dev /proc 2>/tmp/null
|
||||
|
||||
# Keep only en_US.UTF8 locale
|
||||
rm -rf /usr/share/locale/!("en_US.UTF-8"|"locale.alias"|"locale-archive")
|
||||
|
||||
rm -rf /usr/{{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive}
|
||||
|
||||
# Docs
|
||||
rm -rf /usr/share/{man,doc,info,gnome/help}
|
||||
|
||||
# sln
|
||||
rm -rf /sbin/sln
|
||||
|
||||
# ldconfig
|
||||
rm -rf /etc/ld.so.cache /var/cache/ldconfig
|
||||
mkdir -p --mode=0755 /var/cache/ldconfig
|
||||
|
||||
# UDev
|
||||
rm -rf /usr/lib/udev
|
||||
rm -rf /etc/udev/hwdb.bin
|
||||
|
||||
rm -rf /usr/lib/.build-id
|
||||
|
||||
# Cache & Tmp
|
||||
rm -rf /var/cache/urpmi/rpms 2>/tmp/null
|
||||
rm -rf /tmp/*
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mbi_base_strip()
|
||||
{
|
||||
mbi_func_exec "_mbi_base_strip" "--strip" "stripping"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Base UnStrip
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function _mbi_base_unstrip()
|
||||
{
|
||||
urpmi.update -a
|
||||
|
||||
# Install uninstalled packages
|
||||
urpmi --force cracklib-dicts buildah dhcp-common dhcp-client cronie-anacron buildah opencontainers-runc lib64gpgme11 gnupg2 lib64ksba8 lib64usb1.0_0 lib64npth0 lib64assuan0
|
||||
|
||||
# Force reinstall all packages
|
||||
urpmi --force --replacepkgs $(rpm -qa | grep -v gpg-pubkey)
|
||||
}
|
||||
|
||||
|
||||
|
||||
function mbi_base_unstrip()
|
||||
{
|
||||
mbi_func_exec "_mbi_base_unstrip" "--unstrip" "unstripping"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Main
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
orig_args=("$@")
|
||||
|
||||
root_dir="${ROOT_DIR_DEF}"
|
||||
tmp_dir="${TMP_DIR_DEF}"
|
||||
|
||||
lang="${LANG_DEF}"
|
||||
language="${LANGUAGE_DEF}"
|
||||
localtime="${LOCALTIME_DEF}"
|
||||
|
||||
for var in $(env | grep -e LC_ -e LANG); do unset ${var/=*/}; done
|
||||
export LC_ALL="C"
|
||||
|
||||
|
||||
|
||||
mbi_args_parse "$@"
|
||||
|
||||
|
||||
|
||||
if [[ ${mode} == "exit" ]]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ "${mode}" == "default" ]]
|
||||
then
|
||||
mbi_env_init "true"
|
||||
else
|
||||
mbi_env_init "false"
|
||||
fi
|
||||
|
||||
error_echo "MBI: Mode: [${mode}] Verbose: [${verbose}] Direct: [${direct}] Dry_Run: [${dry_run}] Root_Dir: [${root_dir}] Tmp_Dir: [${tmp_dir}] Lang: [${lang}] Language: [${language}] Local_Time: [${localtime}]"
|
||||
|
||||
case "${mode}" in
|
||||
|
||||
"default")
|
||||
mbi_base_install_pre
|
||||
mbi_base_install_post
|
||||
mbi_base_strip
|
||||
;;
|
||||
|
||||
"post")
|
||||
mbi_base_install_post
|
||||
;;
|
||||
|
||||
"strip")
|
||||
mbi_base_strip
|
||||
;;
|
||||
|
||||
"unstrip")
|
||||
mbi_base_unstrip
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
|
||||
70
usr/lib/rx3/docker_tools.bash
Normal file
70
usr/lib/rx3/docker_tools.bash
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Docker Tools Library
|
||||
#
|
||||
# Copyright (C) 2026 Arnaud G. GIBERT
|
||||
# mailto:arnaud@rx3.net
|
||||
#
|
||||
# This is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; If not, see
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Includes
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
. /usr/lib/rx3/base.bash
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
# Appl Home Get
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
dt_appl_home_get()
|
||||
{
|
||||
if [[ "${1:-}" != "" ]]
|
||||
then
|
||||
# Force appl home
|
||||
|
||||
APPL_HOME_DIR="$(realpath "$1")"
|
||||
else
|
||||
# First check if parent dir has a compose environement
|
||||
|
||||
APPL_HOME_DIR="$(realpath "$(dirname "$(dirname "$0")")")"
|
||||
|
||||
if [[ ( "${APPL_HOME_DIR}" != "/usr") && ( ( -f "${APPL_HOME_DIR}/compose.yml") || ( -f "${APPL_HOME_DIR}/compose.yaml")) ]]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Next check if the current dir has a compose environement
|
||||
|
||||
APPL_HOME_DIR="${PWD}"
|
||||
fi
|
||||
|
||||
if [[ ( -f "${APPL_HOME_DIR}/compose.yml") || ( -f "${APPL_HOME_DIR}/compose.yaml") ]]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
echo_error "No appl directory found!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user