summaryrefslogtreecommitdiffstats
path: root/utils/site_assets/oo-install-bootstrap.sh
blob: 3847c029aa2f31f2524c88a3b3b6556d4bc1016d (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh

# Grab command-line arguments
cmdlnargs="$@"

: ${OO_INSTALL_KEEP_ASSETS:="false"}
: ${OO_INSTALL_CONTEXT:="INSTALLCONTEXT"}
: ${TMPDIR:=/tmp}
: ${OO_INSTALL_LOG:=${TMPDIR}/INSTALLPKGNAME.log}
[[ $TMPDIR != */ ]] && TMPDIR="${TMPDIR}/"

if rpm -q dnf;
then
  PKG_MGR="dnf"
else
  PKG_MGR="yum"
fi

if [ $OO_INSTALL_CONTEXT != 'origin_vm' ]
then
  clear
  echo "Checking for necessary tools..."
fi
if [ -e /etc/redhat-release  ]
then
  for i in python python-virtualenv openssh-clients gcc
  do
    rpm -q $i  >/dev/null 2>&1 || { echo >&2 "Missing installation dependency detected.  Please run \"${PKG_MGR} install ${i}\"."; exit 1; }
  done
fi
for i in python virtualenv ssh gcc
do
  command -v $i >/dev/null 2>&1 || { echo >&2 "OpenShift installation requires $i on the PATH but it does not appear to be available. Correct this and rerun the installer."; exit 1; }
done

# All instances of INSTALLPKGNAME are replaced during packaging with the actual package name.
if [[ -e ./INSTALLPKGNAME.tgz ]]
then
  if [ $OO_INSTALL_CONTEXT != 'origin_vm' ]
  then
    echo "Using bundled assets."
  fi
  cp INSTALLPKGNAME.tgz ${TMPDIR}/INSTALLPKGNAME.tgz
elif [[ $OO_INSTALL_KEEP_ASSETS == 'true' && -e ${TMPDIR}/INSTALLPKGNAME.tgz ]]
then
  if [ $OO_INSTALL_CONTEXT != 'origin_vm' ]
  then
    echo "Using existing installer assets."
  fi
else
  echo "Downloading oo-install package to ${TMPDIR}INSTALLPKGNAME.tgz..."
  curl -s -o ${TMPDIR}INSTALLPKGNAME.tgz https://install.openshift.com/INSTALLVERPATHINSTALLPKGNAME.tgz
fi

if [ $OO_INSTALL_CONTEXT != 'origin_vm' ]
then
  echo "Extracting oo-install to ${TMPDIR}INSTALLPKGNAME..."
fi
tar xzf ${TMPDIR}INSTALLPKGNAME.tgz -C ${TMPDIR} 2>&1 >> $OO_INSTALL_LOG

echo "Preparing to install.  This can take a minute or two..."
virtualenv ${TMPDIR}/INSTALLPKGNAME 2>&1 >> $OO_INSTALL_LOG
cd ${TMPDIR}/INSTALLPKGNAME 2>&1 >> $OO_INSTALL_LOG
source ./bin/activate 2>&1 >> $OO_INSTALL_LOG
pip install --no-index -f file:///$(readlink -f deps) ansible 2>&1 >> $OO_INSTALL_LOG

# TODO: these deps should technically be handled as part of installing ooinstall
pip install --no-index -f file:///$(readlink -f deps) click 2>&1 >> $OO_INSTALL_LOG
pip install --no-index ./src/ 2>&1 >> $OO_INSTALL_LOG
echo "Installation preperation done!" 2>&1 >> $OO_INSTALL_LOG

echo "Using `ansible --version`" 2>&1 >> $OO_INSTALL_LOG

if [ $OO_INSTALL_CONTEXT != 'origin_vm' ]
then
  echo "Starting oo-install..." 2>&1 >> $OO_INSTALL_LOG
else
  clear
fi
oo-install $cmdlnargs --ansible-playbook-directory ${TMPDIR}/INSTALLPKGNAME/openshift-ansible-*/ --ansible-log-path $OO_INSTALL_LOG

if [ $OO_INSTALL_KEEP_ASSETS == 'true' ]
then
  echo "Keeping temporary assets in ${TMPDIR}"
else
  echo "Removing temporary assets."
  rm -rf ${TMPDIR}INSTALLPKGNAME
  rm -rf ${TMPDIR}INSTALLPKGNAME.tgz
fi

echo "Please see $OO_INSTALL_LOG for full output."

exit