./utils/lxc.sh: add command 'install base'

to install basic packages like git and *build essentials*::

  $ ./utils/lxc.sh install base

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2020-03-18 17:47:48 +01:00
parent d2cfe9ce5b
commit 62da769952
2 changed files with 34 additions and 5 deletions

View File

@ -1090,6 +1090,28 @@ touch "/.lxcenv"
ls -l "/.lxcenv" ls -l "/.lxcenv"
EOF EOF
} }
# apt packages
LXC_BASE_PACKAGES_debian="git build-essential"
# pacman packages
LXC_BASE_PACKAGES_arch="git base-devel"
# dnf packages
LXC_BASE_PACKAGES_fedora="git @development-tools"
case $DIST_ID in
ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;;
fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
*) err_msg "$DIST_ID-$DIST_VERS: pkg_install LXC_BASE_PACKAGES not yet implemented" ;;
esac
lxc_install_base_packages() {
info_msg "install LXC_BASE_PACKAGES in container $1"
pkg_install "${LXC_BASE_PACKAGES}"
}
lxc_exists(){ lxc_exists(){
# usage: lxc_exists <name> || echo "container <name> does not exists" # usage: lxc_exists <name> || echo "container <name> does not exists"

View File

@ -82,10 +82,10 @@ usage::
$_cmd [start|stop] [containers|<name>] $_cmd [start|stop] [containers|<name>]
$_cmd show [info|config|suite|images] $_cmd show [info|config|suite|images]
$_cmd cmd [--|<name>] '...' $_cmd cmd [--|<name>] '...'
$_cmd install [suite|buildhost] $_cmd install [suite|base|buildhost]
build build
:containers: build & launch all LXC containers of the suite :containers: build, launch and 'install basic' packages on 'containers'
copy: copy:
:images: copy remote images of the suite into local storage :images: copy remote images of the suite into local storage
remove remove
@ -105,7 +105,8 @@ cmd
:<name>: run command '...' in container <name> :<name>: run command '...' in container <name>
install install
:suite: install LXC suite; ${lxc_suite_install_info} :suite: install LXC suite; ${lxc_suite_install_info}
:buildhost: prepare LXC; buildhost :base: prepare LXC; install basic packages
:buildhost: prepare LXC; install buildhost packages
EOF EOF
usage_images usage_images
@ -217,6 +218,7 @@ main() {
esac esac
;; ;;
__show) __show)
# wrapped show commands, called once in each container
case $2 in case $2 in
suite) lxc_suite_info ;; suite) lxc_suite_info ;;
esac esac
@ -238,14 +240,17 @@ main() {
install) install)
sudo_or_exit sudo_or_exit
case $2 in case $2 in
suite) lxc_exec "${LXC_REPO_ROOT}/utils/lxc.sh" __install suite;; suite|base|buildhost)
buildhost) lxc_exec "${LXC_REPO_ROOT}/utils/lxc.sh" __install buildhost;; lxc_exec "${LXC_REPO_ROOT}/utils/lxc.sh" __install $2
;;
*) usage "$_usage"; exit 42 ;; *) usage "$_usage"; exit 42 ;;
esac esac
;; ;;
__install) __install)
# wrapped install commands, called once in each container
case $2 in case $2 in
suite) lxc_suite_install ;; suite) lxc_suite_install ;;
base) FORCE_TIMEOUT=0 lxc_install_base_packages ;;
buildhost) lxc_suite_prepare_buildhost ;; buildhost) lxc_suite_prepare_buildhost ;;
esac esac
;; ;;
@ -269,6 +274,8 @@ build_instances() {
lxc_config_containers lxc_config_containers
lxc_boilerplate_containers lxc_boilerplate_containers
echo echo
lxc_exec "${LXC_REPO_ROOT}/utils/lxc.sh" __install base
echo
lxc list "$LXC_HOST_PREFIX" lxc list "$LXC_HOST_PREFIX"
} }