blob: dee85c96415dbb741efa0642d0630000172ec4dd [file] [log] [blame]
Hari Krishna74489792015-07-30 10:07:15 -07001#!/usr/bin/env bash
2
3# TestON install script for Ubuntu (Debian and Fedora)
4
5# Fail on error
6set -e
7
8# Fail on unset var usage
9set -o nounset
10
11# Identify Linux release
12DIST=Unknown
13RELEASE=Unknown
14CODENAME=Unknown
15
16ARCH=`uname -m`
17if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi
18if [ "$ARCH" = "i686" ]; then ARCH="i386"; fi
19
20if [ -e /etc/debian_version ]; then DIST="Debian"; fi
21if [ -e /etc/fedora-release ]; then DIST="Debian"; fi
22grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu"
23
24if [ "$DIST" = "Ubuntu" ] || [ "$DIST" = "Debian" ]; then
25 install='sudo apt-get -y install'
26 remove='sudo apt-get -y remove'
27 pipinstall='sudo pip install'
28 # Prereqs for this script
29 if ! which lsb_release &> /dev/null; then
30 $install lsb-release
31 fi
32fi
33
34if [ "$DIST" = "Fedora" ]; then
35 install='sudo yum -y install'
36 remove='sudo yum -y erase'
37 pipinstall='sudo pip install'
38 # Prereqs for this script
39 if ! which lsb_release &> /dev/null; then
40 $install redhat-lsb-core
41 fi
42fi
43if which lsb_release &> /dev/null; then
44 DIST=`lsb_release -is`
45 RELEASE=`lsb_release -rs`
46 CODENAME=`lsb_release -cs`
47fi
48echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH"
49
50if ! echo $DIST | egrep 'Ubuntu|Debian|Fedora'; then
51 echo "Install.sh currently only supports Ubuntu, Debian and Fedora."
52 exit 1
53fi
54
55# Check OnosSystemTest is cloned in home directory.
56if [ ! -d ~/OnosSystemTest ]; then
57 echo "Could not find OnosSystemTest in your home directory."
58 echo "Exiting from running install script."
59 exit 1
60fi
61
62# Install TestON dependencies
63echo "Installing TestON dependencies"
64if [ "$DIST" = "Fedora" ]; then
Hari Krishnabed3dab2015-08-05 14:30:30 -070065 # Fedora may have vlan enabled by default. Still need to confirm and update later
Jon Hall6268e942016-06-22 16:02:06 -070066 $install python-pip build-essential python-dev pep8 arping python3-requests
Hari Krishna74489792015-07-30 10:07:15 -070067 $pipinstall pexpect==3.2 configobj==4.7.2 numpy
68else
Jon Hall6268e942016-06-22 16:02:06 -070069 $install python-pip build-essential python-dev pep8 vlan arping python3-requests
Hari Krishna74489792015-07-30 10:07:15 -070070 $pipinstall pexpect==3.2 configobj==4.7.2 numpy
71fi
72
73# Add check here to make sure OnosSystemTest is cloned into home directory (place holder)
74
75# Add symbolic link to main TestON folder in Home dir
76pushd ~
77sudo ln -s ~/OnosSystemTest/TestON TestON
78echo "Added symbolic link to TestON folder in HOME directory."
79popd
80
81# OnosSystemTest git pre-commit hooks
82pushd ~/OnosSystemTest
83cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
84popd
85
86# Add symbolic link to TestON cli in /usr/local/bin
87pushd /usr/local/bin
88sudo ln -s $HOME/OnosSystemTest/TestON/bin/cli.py teston
89echo "Added symbolic link to TestON CLI in /usr/local/bin."
90popd
91
92# Add log rotation configuration for TestON logs here (place holder)
93
94echo "Completed running install.sh script"
95echo "Run TestON CLI by typing teston at bash prompt"
96echo "Example: teston run <TestSuite Name>"