diff --git a/CHANGES b/CHANGES index 71bc1a5dd..9769d3d89 100644 --- a/CHANGES +++ b/CHANGES @@ -2456,4 +2456,5 @@ * nginx: update to 1.20.0-1 * Check if CNAME record exists and remove it if overwrite is set * cifs: use credentials file for better password support +* installer: rework script to fix DNS resolution issues diff --git a/baseimage/initializeBaseUbuntuImage.sh b/baseimage/initializeBaseUbuntuImage.sh index c6cfc4582..efed89101 100755 --- a/baseimage/initializeBaseUbuntuImage.sh +++ b/baseimage/initializeBaseUbuntuImage.sh @@ -1,5 +1,7 @@ #!/bin/bash +# This script is run on the base ubuntu. Put things here which are managed by ubuntu + set -euv -o pipefail readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -62,12 +64,6 @@ apt-get -y install --no-install-recommends \ unzip \ xfsprogs -echo "==> installing nginx for xenial for TLSv3 support" -curl -sL http://nginx.org/packages/ubuntu/pool/nginx/n/nginx/nginx_1.20.0-1~${ubuntu_codename}_amd64.deb -o /tmp/nginx.deb -# apt install with install deps (as opposed to dpkg -i) -apt install -y /tmp/nginx.deb -rm /tmp/nginx.deb - # on some providers like scaleway the sudo file is changed and we want to keep the old one apt-get -o Dpkg::Options::="--force-confold" install -y --no-install-recommends sudo @@ -75,57 +71,15 @@ apt-get -o Dpkg::Options::="--force-confold" install -y --no-install-recommends # debconf-set-selection of unattended-upgrades/enable_auto_updates + dpkg-reconfigure does not work cp /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades -echo "==> Installing node.js" -readonly node_version=16.13.1 -mkdir -p /usr/local/node-${node_version} -curl -sL https://nodejs.org/dist/v${node_version}/node-v${node_version}-linux-x64.tar.gz | tar zxf - --strip-components=1 -C /usr/local/node-${node_version} -ln -sf /usr/local/node-${node_version}/bin/node /usr/bin/node -ln -sf /usr/local/node-${node_version}/bin/npm /usr/bin/npm apt-get install -y --no-install-recommends python # Install python which is required for npm rebuild [[ "$(python --version 2>&1)" == "Python 2.7."* ]] || die "Expecting python version to be 2.7.x" -# https://docs.docker.com/engine/installation/linux/ubuntulinux/ -echo "==> Installing Docker" - -# create systemd drop-in file. if you channge options here, be sure to fixup installer.sh as well -mkdir -p /etc/systemd/system/docker.service.d -echo -e "[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --log-driver=journald --exec-opt native.cgroupdriver=cgroupfs --storage-driver=overlay2 --experimental --ip6tables" > /etc/systemd/system/docker.service.d/cloudron.conf - -# there are 3 packages for docker - containerd, CLI and the daemon -readonly docker_version=20.10.12 -curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/containerd.io_1.4.9-1_amd64.deb" -o /tmp/containerd.deb -curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/docker-ce-cli_${docker_version}~3-0~ubuntu-${ubuntu_codename}_amd64.deb" -o /tmp/docker-ce-cli.deb -curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/docker-ce_${docker_version}~3-0~ubuntu-${ubuntu_codename}_amd64.deb" -o /tmp/docker.deb -# apt install with install deps (as opposed to dpkg -i) -apt install -y /tmp/containerd.deb /tmp/docker-ce-cli.deb /tmp/docker.deb -rm /tmp/containerd.deb /tmp/docker-ce-cli.deb /tmp/docker.deb - -storage_driver=$(docker info | grep "Storage Driver" | sed 's/.*: //') -if [[ "${storage_driver}" != "overlay2" ]]; then - echo "Docker is using "${storage_driver}" instead of overlay2" - exit 1 -fi - # do not upgrade grub because it might prompt user and break this script echo "==> Enable memory accounting" apt-get -y --no-upgrade --no-install-recommends install grub2-common sed -e 's/^GRUB_CMDLINE_LINUX="\(.*\)"$/GRUB_CMDLINE_LINUX="\1 cgroup_enable=memory swapaccount=1 panic_on_oops=1 panic=5"/' -i /etc/default/grub update-grub -echo "==> Downloading docker images" -if [ ! -f "${arg_infraversionpath}/infra_version.js" ]; then - echo "No infra_versions.js found" - exit 1 -fi - -images=$(node -e "var i = require('${arg_infraversionpath}/infra_version.js'); console.log(i.baseImages.map(function (x) { return x.tag; }).join(' '), Object.keys(i.images).map(function (x) { return i.images[x].tag; }).join(' '));") - -echo -e "\tPulling docker images: ${images}" -for image in ${images}; do - docker pull "${image}" - docker pull "${image%@sha256:*}" # this will tag the image for readability -done - echo "==> Install collectd" # without this, libnotify4 will install gnome-shell apt-get install -y libnotify4 --no-install-recommends @@ -191,6 +145,7 @@ ufw disable || true echo -e "server:\n\tinterface: 127.0.0.1\n\tdo-ip6: no" > /etc/unbound/unbound.conf.d/cloudron-network.conf systemctl restart unbound +# create the yellowtent user if ! id yellowtent 2>/dev/null; then useradd yellowtent -m fi diff --git a/scripts/installer.sh b/scripts/installer.sh index f238b5c27..eb647ad64 100755 --- a/scripts/installer.sh +++ b/scripts/installer.sh @@ -71,10 +71,15 @@ readonly is_update=$(systemctl is-active -q box && echo "yes" || echo "no") log "Updating from $(cat $box_src_dir/VERSION) to $(cat $box_src_tmp_dir/VERSION)" -log "updating docker" - +# https://docs.docker.com/engine/installation/linux/ubuntulinux/ readonly docker_version=20.10.12 -if [[ $(docker version --format {{.Client.Version}}) != "${docker_version}" ]]; then +if ! which docker 2>/dev/null || [[ $(docker version --format {{.Client.Version}}) != "${docker_version}" ]]; then + log "installing/updating docker" + + # create systemd drop-in file already to make sure images are with correct driver + mkdir -p /etc/systemd/system/docker.service.d + echo -e "[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --log-driver=journald --exec-opt native.cgroupdriver=cgroupfs --storage-driver=overlay2 --experimental --ip6tables" > /etc/systemd/system/docker.service.d/cloudron.conf + # there are 3 packages for docker - containerd, CLI and the daemon $curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/containerd.io_1.4.9-1_amd64.deb" -o /tmp/containerd.deb $curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/docker-ce-cli_${docker_version}~3-0~ubuntu-${ubuntu_codename}_amd64.deb" -o /tmp/docker-ce-cli.deb @@ -87,8 +92,8 @@ if [[ $(docker version --format {{.Client.Version}}) != "${docker_version}" ]]; fi readonly nginx_version=$(nginx -v 2>&1) -if [[ "${nginx_version}" != *"1.20."* ]]; then - log "installing nginx 1.20" +if ! which nginx 2>/dev/null || [[ "${nginx_version}" != *"1.20."* ]]; then + log "installing/updating nginx 1.20" $curl -sL http://nginx.org/packages/ubuntu/pool/nginx/n/nginx/nginx_1.20.0-1~${ubuntu_codename}_amd64.deb -o /tmp/nginx.deb prepare_apt_once @@ -98,9 +103,9 @@ if [[ "${nginx_version}" != *"1.20."* ]]; then rm /tmp/nginx.deb fi -log "updating node" readonly node_version=16.13.1 -if [[ "$(node --version)" != "v${node_version}" ]]; then +if ! which node 2>/dev/null || [[ "$(node --version)" != "v${node_version}" ]]; then + log "installing/updating node ${node_version}" mkdir -p /usr/local/node-${node_version} $curl -sL https://nodejs.org/dist/v${node_version}/node-v${node_version}-linux-x64.tar.gz | tar zxvf - --strip-components=1 -C /usr/local/node-${node_version} ln -sf /usr/local/node-${node_version}/bin/node /usr/bin/node