diff options
Diffstat (limited to 'mcp/scripts/lib_jump_common.sh')
-rw-r--r-- | mcp/scripts/lib_jump_common.sh | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/mcp/scripts/lib_jump_common.sh b/mcp/scripts/lib_jump_common.sh index 02ada44e9..c2bd46649 100644 --- a/mcp/scripts/lib_jump_common.sh +++ b/mcp/scripts/lib_jump_common.sh @@ -61,13 +61,15 @@ function jumpserver_pkg_install { function jumpserver_check_requirements { # shellcheck disable=SC2178 + local states=$1; shift + # shellcheck disable=SC2178 local vnodes=$1; shift local br=("$@") local err_br_not_found='Linux bridge not found!' local err_br_virsh_net='is a virtual network, Linux bridge expected!' local warn_br_endpoint="Endpoints might be inaccessible from external hosts!" # MaaS requires a Linux bridge for PXE/admin - if [[ "${vnodes}" =~ mas01 ]]; then + if [[ "${states}" =~ maas ]]; then if ! brctl showmacs "${br[0]}" >/dev/null 2>&1; then notify_e "[ERROR] PXE/admin (${br[0]}) ${err_br_not_found}" fi @@ -77,9 +79,9 @@ function jumpserver_check_requirements { fi fi # If virtual nodes are present, public should be a Linux bridge - if [ "$(echo "${vnodes}" | wc -w)" -gt 2 ]; then + if [ -n "${vnodes}" ]; then if ! brctl showmacs "${br[3]}" >/dev/null 2>&1; then - if [[ "${vnodes}" =~ mas01 ]]; then + if [[ "${states}" =~ maas ]]; then # Baremetal nodes *require* a proper public network notify_e "[ERROR] Public (${br[3]}) ${err_br_not_found}" else @@ -88,13 +90,21 @@ function jumpserver_check_requirements { fi fi if ${VIRSH} net-info "${br[3]}" >/dev/null 2>&1; then - if [[ "${vnodes}" =~ mas01 ]]; then + if [[ "${states}" =~ maas ]]; then notify_e "[ERROR] ${br[3]} ${err_br_virsh_net}" else notify_n "[WARN] ${br[3]} ${err_br_virsh_net}" 3 notify_n "[WARN] ${warn_br_endpoint}" 3 fi fi + # https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1797332 + if lsb_release -d | grep -q -e 'Ubuntu 16.04'; then + if uname -r | grep -q -e '^4\.4\.'; then + notify_n "[WARN] Host kernel too old; nested virtualization issues!" 3 + notify_n "[WARN] apt install linux-generic-hwe-16.04 && reboot" 3 + notify_e "[ERROR] Please upgrade the kernel and reboot!" + fi + fi fi } @@ -114,7 +124,9 @@ function docker_install { fi fi # Distro-provided docker-compose might be simply broken (Ubuntu 16.04, CentOS 7) - if ! docker-compose --version > /dev/null 2>&1; then + if ! docker-compose --version > /dev/null 2>&1 || \ + [ "$(docker-compose version --short | tr -d '.')" -lt 1220 ] && \ + [ "$(uname -m)" = 'x86_64' ]; then COMPOSE_BIN="${image_dir}/docker-compose" COMPOSE_VERSION='1.22.0' notify_n "[WARN] Using docker-compose ${COMPOSE_VERSION} in ${COMPOSE_BIN}" 3 @@ -126,6 +138,26 @@ function docker_install { fi } +function e2fsprogs_install { + local image_dir=$1 + E2FS_VER=$(e2fsck -V 2>&1 | grep -Pzo "e2fsck \K1\.\d{2}") + if [ "${E2FS_VER//./}" -lt 143 ]; then + E2FS_TGZ="${image_dir}/e2fsprogs.tar.gz" + E2FS_VER='1.43.9' + E2FS_URL="https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/snapshot/e2fsprogs-${E2FS_VER}.tar.gz" + notify_n "[WARN] Using e2fsprogs ${E2FS_VER} from ${E2FS_TGZ}" 3 + if [ ! -e "${E2FS_TGZ}" ]; then + curl -L "${E2FS_URL}" -o "${E2FS_TGZ}" + mkdir -p "${image_dir}/e2fsprogs" + tar xzf "${E2FS_TGZ}" -C "${image_dir}/e2fsprogs" --strip-components=1 + cd "${image_dir}/e2fsprogs" || exit 1 + ./configure + make + cd - || exit 1 + fi + fi +} + function virtinst_install { local image_dir=$1 VIRT_VER=$(virt-install --version 2>&1) |