bootstrap.sh 1.16 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
10
	TAG=v0.13a
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 22 23 24 25 26
	if [ ! -f /usr/bin/git ]; then
		echo Installing git . . .
		apt-get -q -q update
		DEBIAN_FRONTEND=noninteractive apt-get -q -q install -y git < /dev/null
		echo
	fi
27

28
	echo Downloading Mail-in-a-Box $TAG. . .
29 30 31 32 33 34 35 36 37 38 39
	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
40

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

# Start setup script.
setup/start.sh
54