bootstrap.sh 1.09 KB
Newer Older
1 2 3 4
#!/bin/bash
#########################################################
# This script is intended to be run like this:
#
5
#   curl https://.../bootstrap.sh | sudo bash
6 7 8
#
#########################################################

9
if [ -z "$TAG" ]; then
Joshua Tauberer's avatar
Joshua Tauberer committed
10
	TAG=v0.06
11
fi
12

13 14 15 16 17 18 19
# Are we running as root?
if [[ $EUID -ne 0 ]]; then
	echo "This script must be run as root. Did you leave out sudo?"
	exit
fi

# Clone the Mail-in-a-Box repository if it doesn't exist.
20
if [ ! -d $HOME/mailinabox ]; then
21
	echo Installing git . . .
22 23
	DEBIAN_FRONTEND=noninteractive apt-get -q -q install -y git < /dev/null
	echo
24

25
	echo Downloading Mail-in-a-Box $TAG. . .
26 27 28 29 30 31 32 33 34 35 36
	git clone \
		-b $TAG --depth 1 \
		https://github.com/mail-in-a-box/mailinabox \
		$HOME/mailinabox \
		< /dev/null 2> /dev/null

	echo
fi

# Change directory to it.
cd $HOME/mailinabox
37

38 39
# Update it.
if [ "$TAG" != `git describe` ]; then
40
	echo Updating Mail-in-a-Box to $TAG . . .
41
	git fetch --depth 1 --force --prune origin tag $TAG
42
	if ! git checkout -q $TAG; then
43 44 45
		echo "Update failed. Did you modify something in `pwd`?"
		exit
	fi
46
	echo
47 48 49 50
fi

# Start setup script.
setup/start.sh
51