#!/bin/sh # # Mike McCormack # 2011/2/24 # # Build a self-extracting devkit to be used on 2nd party machines # # die: print message to stderr and exit with error code # # PARAMETERS # $1 $2 ... - message to be printed die() { echo "$CE$N: fatal error: $*$CN" >&2 exit 1 } # make sure we're not root if test `id -u` = "0" then die "Please install SBS in a user account, not as root" fi # enable colors only on terminal devices TPUT="`which tput`" if test -t 0 -a -t 1 -a -n "$TPUT" then CI="`$TPUT setf 6 || true`" CE="`$TPUT setf 4 || true`" CX="`$TPUT setf 2 || true`" CN="`$TPUT sgr0 || true`" else CI='' CE='' CX='' CN='' fi N="`basename \"$0\"`" set +e ms=`which makeself` if [ ! "$ms" ] then die "makeself is not installed. (try: sudo aptitude install makeself)" fi if [ ! -x ./install-sbs ] then die "must be run from sbs git repository" fi # remove everything cleanup() { rm -rf "$tmpdir" } trap cleanup 0 INT TERM # setup a temporary home directory datestr=`date '+%Y%m%d'` tmpdir=`mktemp -d` # mirroring may take a long time, so cache the mirror echo echo "$CI""Mirroring debian repositories""$CN" echo ./make-offline-mirror.sh ./repo || die "Mirroring failed" # make sure SBS is installed SBS_INSTALL_DIR="$tmpdir/sbs-install" ./install-sbs || die "SBS install failed" mirror_dir="$tmpdir"/sbs-install/share/sbs/apt_mirror mkdir -p "$mirror_dir" cp -R ./repo/* "$mirror_dir/" echo echo "$CI""Creating installer""$CN" echo makeself "$tmpdir" "sbs-offline-$datestr.sh" "sbs-offline-$datestr" ./sbs-install/share/sbs/scripts/sbs-offline-install || die "failed to build self-extracting archive" exit 0