#!/bin/sh set -x set -e # 1. Create partitions # 2. install OS # 3. configure with cdist # 4. start initial sync (mbsync, nextcloud) # Things to automate: # - mbsync call (?) # - nextcloud sync / config # - wireguard installation / config # Things to fix: # cdist sets hostname of HOST when running in chroot! if [ $# -ne 1 ]; then echo "$0 name-of-the-notebook" exit 1 fi # Get OS alpine_version=3.10.2 alpine_url=http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-minirootfs-${alpine_version}-x86_64.tar.gz hostname=nicos-notebook tmpdir=$(mktemp -d) tmpdir=/tmp/tmp.w5LTsMtCDX root_dir=${tmpdir}/rootfs dot_cdist=~/vcs/nico-dot-cdist/ cdist_dir=~/vcs/cdist cdist_copy=${cdist_dir}/other/examples/remote/chroot/copy cdist_exec=${cdist_dir}/other/examples/remote/chroot/exec cd ${tmpdir} # get alpine chroot / extract wget -c ${alpine_url} -O alpine.tar.gz mkdir ${root_dir} chmod 0755 ${root_dir} cd ${root_dir} sudo tar xvfz ${tmpdir}/alpine.tar.gz # enable networking sudo cp /etc/resolv.conf ${root_dir}/etc/ sudo sudo chroot ${root_dir} apk update sudo ${cdist_dir}/bin/cdist config -vv -c ${dot_cdist} \ --remote-copy "${cdist_copy} ${root_dir}" \ --remote-exec "${cdist_exec} ${root_dir}" ${hostname}