#!/bin/bash
set -x
set -e
set -o pipefail
set -u
projectstring=main

datestring=$(date '+on-%Y%m-%dd%Hh%Mm%S%z')
exec >& >(ts '%.s: ' > ~/logs/$projectstring-$datestring.log)

inner=iuser
udir=/home/$inner/i

lxc-stop -n ghcbuild || true
container=ghcbuild-continue
lxc-stop -n $container || true
lxc-destroy -n $container || true
lxc-clone -s ghcbuild $container
lxc-start -n $container -o ~/logs/lxc-$projectstring-$datestring.log -d
sleep 5
bash transfer-do-with-stack.sh $container

nice time lxc-attach -n $container -- sudo -u $inner bash $udir/do-with-stack/user.sh || true ERROR user.sh failed

date
true $0 all done
