diff --git a/baseimage/initializeBaseUbuntuImage.sh b/baseimage/initializeBaseUbuntuImage.sh index ebfed0530..27ae3f8cd 100755 --- a/baseimage/initializeBaseUbuntuImage.sh +++ b/baseimage/initializeBaseUbuntuImage.sh @@ -16,6 +16,9 @@ export DEBIAN_FRONTEND=noninteractive readonly ubuntu_codename=$(lsb_release -cs) readonly ubuntu_version=$(lsb_release -rs) +# readonly arch="amd64" +readonly arch="arm64" + # hold grub since updating it breaks on some VPS providers. also, dist-upgrade will trigger it apt-mark hold grub* >/dev/null apt-get -o Dpkg::Options::="--force-confdef" update -y @@ -43,7 +46,6 @@ apt-get -y install \ ipset \ iptables \ libpython2.7 \ - linux-generic \ logrotate \ $mysql_package \ openssh-server \ @@ -55,8 +57,15 @@ apt-get -y install \ unbound \ xfsprogs -echo "==> installing nginx for xenial for TLSv3 support" -curl -sL http://nginx.org/packages/ubuntu/pool/nginx/n/nginx/nginx_1.18.0-1~${ubuntu_codename}_amd64.deb -o /tmp/nginx.deb +# TODO make it more generic for arm +if [[ "${arch}" == "arm64" ]]; then + apt-get install -y linux-raspi +else + apt-get isntall -y linux-generic +fi + +echo "==> installing nginx for ${ubuntu_codename} for TLSv3 support" +curl -sL http://nginx.org/packages/ubuntu/pool/nginx/n/nginx/nginx_1.18.0-1~${ubuntu_codename}_${arch}.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 @@ -70,7 +79,11 @@ cp /usr/share/unattended-upgrades/20auto-upgrades /etc/apt/apt.conf.d/20auto-upg echo "==> Installing node.js" mkdir -p /usr/local/node-10.18.1 -curl -sL https://nodejs.org/dist/v10.18.1/node-v10.18.1-linux-x64.tar.gz | tar zxf - --strip-components=1 -C /usr/local/node-10.18.1 +if [[ "${arch}" == "arm64" ]]; then + curl -sL https://nodejs.org/dist/v10.18.1/node-v10.18.1-linux-arm64.tar.gz | tar zxf - --strip-components=1 -C /usr/local/node-10.18.1 +else + curl -sL https://nodejs.org/dist/v10.18.1/node-v10.18.1-linux-x64.tar.gz | tar zxf - --strip-components=1 -C /usr/local/node-10.18.1 +fi ln -sf /usr/local/node-10.18.1/bin/node /usr/bin/node ln -sf /usr/local/node-10.18.1/bin/npm /usr/bin/npm apt-get install -y python # Install python which is required for npm rebuild @@ -84,9 +97,9 @@ 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" > /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.2.13-2_amd64.deb" -o /tmp/containerd.deb -curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/amd64/docker-ce-cli_19.03.12~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_19.03.12~3-0~ubuntu-${ubuntu_codename}_amd64.deb" -o /tmp/docker.deb +curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/${arch}/containerd.io_1.2.13-2_${arch}.deb" -o /tmp/containerd.deb +curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/${arch}/docker-ce-cli_19.03.12~3-0~ubuntu-${ubuntu_codename}_${arch}.deb" -o /tmp/docker-ce-cli.deb +curl -sL "https://download.docker.com/linux/ubuntu/dists/${ubuntu_codename}/pool/stable/${arch}/docker-ce_19.03.12~3-0~ubuntu-${ubuntu_codename}_${arch}.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 @@ -97,11 +110,14 @@ if [[ "${storage_driver}" != "overlay2" ]]; then 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 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 +# TODO what about arm?? +if [[ "${arch}" == "amd64" ]]; then + # do not upgrade grub because it might prompt user and break this script + echo "==> Enable memory accounting" + apt-get -y --no-upgrade 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 +fi echo "==> Downloading docker images" if [ ! -f "${arg_infraversionpath}/infra_version.js" ]; then @@ -124,7 +140,9 @@ if ! apt-get install -y libcurl3-gnutls collectd collectd-utils; then sed -e 's/^FQDNLookup true/FQDNLookup false/' -i /etc/collectd/collectd.conf fi # https://bugs.launchpad.net/ubuntu/+source/collectd/+bug/1872281 -[[ "${ubuntu_version}" == "20.04" ]] && echo -e "\nLD_PRELOAD=/usr/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.so" >> /etc/default/collectd + +[[ "${ubuntu_version}" == "20.04" && "${arch}" == "amd64" ]] && echo -e "\nLD_PRELOAD=/usr/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.so" >> /etc/default/collectd +[[ "${ubuntu_version}" == "20.04" && "${arch}" == "arm64" ]] && echo -e "\nLD_PRELOAD=/usr/lib/python3.8/config-3.8-aarch64-linux-gnu/libpython3.8.so" >> /etc/default/collectd echo "==> Configuring host" sed -e 's/^#NTP=/NTP=0.ubuntu.pool.ntp.org 1.ubuntu.pool.ntp.org 2.ubuntu.pool.ntp.org 3.ubuntu.pool.ntp.org/' -i /etc/systemd/timesyncd.conf diff --git a/scripts/cloudron-setup b/scripts/cloudron-setup index 3a9f15729..4b21e4be1 100755 --- a/scripts/cloudron-setup +++ b/scripts/cloudron-setup @@ -48,13 +48,14 @@ webServerOrigin="https://cloudron.io" sourceTarballUrl="" rebootServer="true" -args=$(getopt -o "" -l "help,skip-baseimage-init,provider:,version:,env:,skip-reboot" -n "$0" -- "$@") +args=$(getopt -o "" -l "help,skip-baseimage-init,provider:,source-tarball-url:,version:,env:,skip-reboot" -n "$0" -- "$@") eval set -- "${args}" while true; do case "$1" in --help) echo "See https://docs.cloudron.io/installation/ on how to install Cloudron"; exit 0;; --provider) provider="$2"; shift 2;; + --source-tarball-url) sourceTarballUrl="$2"; shift 2;; --version) requestedVersion="$2"; shift 2;; --env) if [[ "$2" == "dev" ]]; then @@ -118,21 +119,25 @@ if [[ "${initBaseImage}" == "true" ]]; then fi fi -echo "=> Checking version" -if ! releaseJson=$($curl -s "${apiServerOrigin}/api/v1/releases?boxVersion=${requestedVersion}"); then - echo "Failed to get release information" - exit 1 -fi +if [[ "$sourceTarballUrl" == "" ]]; then + echo "=> Checking version" + if ! releaseJson=$($curl -s "${apiServerOrigin}/api/v1/releases?boxVersion=${requestedVersion}"); then + echo "Failed to get release information" + exit 1 + fi -if [[ "$requestedVersion" == "" ]]; then - version=$(echo "${releaseJson}" | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["version"])') + if [[ "$requestedVersion" == "" ]]; then + version=$(echo "${releaseJson}" | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["version"])') + else + version="${requestedVersion}" + fi + + if ! sourceTarballUrl=$(echo "${releaseJson}" | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["info"]["sourceTarballUrl"])'); then + echo "No source code for version '${requestedVersion:-latest}'" + exit 1 + fi else - version="${requestedVersion}" -fi - -if ! sourceTarballUrl=$(echo "${releaseJson}" | python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj["info"]["sourceTarballUrl"])'); then - echo "No source code for version '${requestedVersion:-latest}'" - exit 1 + version=${requestedVersion} fi echo "=> Downloading version ${version} ..."