6 # Build a self-extracting devkit to be used on 2nd party machines
9 # die: print message to stderr and exit with error code
12 # $1 $2 ... - message to be printed
15 echo "$CE$N: fatal error: $*$CN" >&2
19 # make sure we're not root
22 die "Please install SBS in a user account, not as root"
25 # enable colors only on terminal devices
27 if test -t 0 -a -t 1 -a -n "$TPUT"
29 CI="`$TPUT setf 6 || true`"
30 CE="`$TPUT setf 4 || true`"
31 CX="`$TPUT setf 2 || true`"
32 CN="`$TPUT sgr0 || true`"
47 die "makeself is not installed. (try: sudo aptitude install makeself)"
50 if [ ! -x ./install-sbs ]
52 die "must be run from sbs git repository"
61 trap cleanup 0 INT TERM
63 # setup a temporary home directory
64 datestr=`date '+%Y%m%d'`
67 # mirroring may take a long time, so cache the mirror
69 echo "$CI""Mirroring debian repositories""$CN"
71 ./make-offline-mirror.sh ./repo || die "Mirroring failed"
73 # make sure SBS is installed
74 SBS_INSTALL_DIR="$tmpdir/sbs-install" ./install-sbs || die "SBS install failed"
76 mirror_dir="$tmpdir"/sbs-install/share/sbs/apt_mirror
77 mkdir -p "$mirror_dir"
78 cp -R ./repo/* "$mirror_dir/"
81 echo "$CI""Creating installer""$CN"
83 makeself "$tmpdir" "sbs-offline-$datestr.sh" "sbs-offline-$datestr" ./sbs-install/share/sbs/scripts/sbs-offline-install || die "failed to build self-extracting archive"