From 056b0237adb533315ad650a0273fe1c7890f65c1 Mon Sep 17 00:00:00 2001 From: Bike Dude Date: Wed, 10 Feb 2021 14:33:04 +0100 Subject: [PATCH] Ubuntu Focal support incl. minor fixes --- usr/local/share/bastille/bootstrap.sh | 40 +++++++++++++++++++++++++++ usr/local/share/bastille/create.sh | 14 ++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/usr/local/share/bastille/bootstrap.sh b/usr/local/share/bastille/bootstrap.sh index 7d6344d..226cc2a 100644 --- a/usr/local/share/bastille/bootstrap.sh +++ b/usr/local/share/bastille/bootstrap.sh @@ -462,12 +462,52 @@ ubuntu_bionic|bionic|ubuntu-bionic) ;; esac fi + echo "APT::Cache-Start 251658240;" > ${bastille_releasesdir}/Ubuntu_1804/etc/apt/apt.conf.d/00aptitude + ;; +ubuntu_focal|focal|ubuntu-focal) + #check and install OS dependencies @hackacad + #ToDo: add function 'linux_pre' for sysrc etc. + if [ ! "$(sysrc -f /boot/loader.conf -n linprocfs_load)" = "YES" ] && [ ! "$(sysrc -f /boot/loader.conf -n linsysfs_load)" = "YES" ] && [ ! "$(sysrc -f /boot/loader.conf -n tmpfs_load)" = "YES" ]; then + warn "linprocfs_load, linsysfs_load, tmpfs_load not enabled in /boot/loader.conf or linux_enable not active. Should I do that for you? (N|y)" + read answer + case $answer in + no|No|n|N|"") + error_exit "Exiting." + ;; + yes|Yes|y|Y) + info "Loading modules" + kldload linux linux64 linprocfs linsysfs tmpfs + info "Persisting modules" + sysrc linux_enable=YES + sysrc -f /boot/loader.conf linprocfs_load=YES + sysrc -f /boot/loader.conf linsysfs_load=YES + sysrc -f /boot/loader.conf tmpfs_load=YES + ;; + esac + fi + if which -s debootstrap; then + debootstrap --foreign --arch=amd64 --no-check-gpg focal ${bastille_releasesdir}/Ubuntu_2004 + else + warn "Debootstrap not found. Should it be installed? (N|y)" + read answer + case $answer in + no|No|n|N|"") + error_exit "Exiting. You need to install debootstap before boostrapping a Linux jail." + ;; + yes|Yes|y|Y) + pkg install debootstrap -y + debootstrap --foreign --arch=amd64 --no-check-gpg focal ${bastille_releasesdir}/Ubuntu_2004 + ;; + esac + fi ;; *) usage ;; esac + + case "${OPTION}" in update) bastille update "${RELEASE}" diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index 160574e..48c615b 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -424,7 +424,6 @@ create_jail() { chmod 0700 "${bastille_jailsdir}/${NAME}" # Jail must be started before applying the default template. -- cwells -# if [ -z "${EMPTY_JAIL}" ] && [ -z "${LINUX_JAIL}" ]; then #SRDEBUB if [ -z "${EMPTY_JAIL}" ]; then bastille start "${NAME}" elif [ -n "${EMPTY_JAIL}" ]; then @@ -461,10 +460,11 @@ create_jail() { ## Using templating function to fetch necessary packges @hackacad elif [ -n "${LINUX_JAIL}" ]; then info "Fetchting packages..." - #jexec -l "${NAME}" /bin/bash -c "export DEBIAN_FRONTEND=noninteractive" #SRDEBUG jexec -l "${NAME}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive rm /var/cache/apt/archives/rsyslog*.deb" jexec -l "${NAME}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive dpkg --force-depends --force-confdef --force-confold -i /var/cache/apt/archives/*.deb" jexec -l "${NAME}" /bin/bash -c "DEBIAN_FRONTEND=noninteractive dpkg --force-depends --force-confdef --force-confold -i /var/cache/apt/archives/*.deb" + jexec -l "${NAME}" /bin/bash -c "chmod 777 /tmp" + jexec -l "${NAME}" /bin/bash -c "apt update" else # Thin jail. if [ -n "${bastille_template_thin}" ]; then bastille template "${NAME}" ${bastille_template_thin} --arg BASE_TEMPLATE="${bastille_template_base}" --arg HOST_RESOLV_CONF="${bastille_resolv_conf}" @@ -536,7 +536,7 @@ RELEASE="$2" IP="$3" INTERFACE="$4" -if [ -n "${EMPTY_JAIL}"; then +if [ -n "${EMPTY_JAIL}" ]; then if [ $# -ne 1 ]; then usage fi @@ -558,6 +558,10 @@ if [ -n "${LINUX_JAIL}" ]; then ## check for FreeBSD releases name NAME_VERIFY=ubuntu_bionic ;; + focal|ubuntu_focal|ubuntu-focal) + ## check for FreeBSD releases name + NAME_VERIFY=ubuntu_focal + ;; *) error_notify "Unknown Linux." usage @@ -607,6 +611,10 @@ if [ -z "${EMPTY_JAIL}" ]; then NAME_VERIFY=Ubuntu_1804 validate_release ;; + ubuntu_focal|focal|ubuntu-focal) + NAME_VERIFY=Ubuntu_2004 + validate_release + ;; *) error_notify "Unknown Release." usage