-
Notifications
You must be signed in to change notification settings - Fork 16
/
install.sh
executable file
·60 lines (52 loc) · 1.49 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
while getopts "c:d:v:" OPTION
do
case ${OPTION} in
c) CLOUD_CONFIG="${OPTARG}" ;;
d) DEVICE="${OPTARG}" ;;
v) VERSION="${OPTARG}" ;;
*) 2>&1 echo "Usage: ${0} [-c cloud-config.yml] [-d /dev/sdX] [-v 0.X.Y]" && exit 1 ;;
esac
done
if [ -z "${DEVICE}" ]
then
if [ -e "/dev/sda" ]
then
DEVICE="/dev/sda"
elif [ -e "/dev/vda" ]
then
DEVICE="/dev/vda"
else
2>&1 echo "Error: could not automatically determine device to install to, use -d to specify"
exit 1
fi
fi
if [ -z "${CLOUD_CONFIG}" ]
then
CLOUD_CONFIG="/tmp/cloud-config.yml"
cat > "${CLOUD_CONFIG}" <<- EOF
#cloud-config
EOF
fi
set -x
if which apt-get > /dev/null
then
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update
apt-get -qq install --no-install-recommends ca-certificates git grub2
fi
if [ -z "${VERSION}" ]
then
VERSION=$(wget -q -O - https://releases.rancher.com/os/releases.yml | grep current | cut -d: -f3)
else
VERSION=$(echo "${VERSION}" | sed 's/^v*/v/')
fi
export VERSION
git clone --branch "${VERSION}" https://github.com/rancher/os.git rancheros
ln -fs ../../build.conf rancheros/scripts/installer/build.conf
ln -fs `pwd`/rancheros/scripts/installer /scripts
mkdir dist
wget -q -P dist "https://github.com/rancher/os/releases/download/${VERSION}/initrd"
wget -q -P dist "https://github.com/rancher/os/releases/download/${VERSION}/vmlinuz"
rancheros/scripts/installer/set-disk-partitions "${DEVICE}"
rancheros/scripts/installer/lay-down-os -c "${CLOUD_CONFIG}" -d "${DEVICE}" -i dist -t generic