blob: 4bbfe92e5787e307438dc79ca4f0c2e1ac948fcb [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 Hall34573f02016-07-15 14:41:46 -070066 $install python-pip build-essential python-dev pep8 python3-requests
Hari Krishna74489792015-07-30 10:07:15 -070067 $pipinstall pexpect==3.2 configobj==4.7.2 numpy
68else
Jon Hall34573f02016-07-15 14:41:46 -070069 $install python-pip build-essential python-dev pep8 vlan python3-requests
Hari Krishna74489792015-07-30 10:07:15 -070070 $pipinstall pexpect==3.2 configobj==4.7.2 numpy
71fi
72
Jon Hall34573f02016-07-15 14:41:46 -070073# Some Distos have this already from another package
74if which arping > /dev/null ; then
75 echo "Arping command detected, skipping package installation."
76else
77 $install arping
78fi
79
Hari Krishna74489792015-07-30 10:07:15 -070080# Add check here to make sure OnosSystemTest is cloned into home directory (place holder)
81
82# Add symbolic link to main TestON folder in Home dir
83pushd ~
84sudo ln -s ~/OnosSystemTest/TestON TestON
85echo "Added symbolic link to TestON folder in HOME directory."
86popd
87
88# OnosSystemTest git pre-commit hooks
89pushd ~/OnosSystemTest
90cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
91popd
92
93# Add symbolic link to TestON cli in /usr/local/bin
94pushd /usr/local/bin
95sudo ln -s $HOME/OnosSystemTest/TestON/bin/cli.py teston
96echo "Added symbolic link to TestON CLI in /usr/local/bin."
97popd
98
99# Add log rotation configuration for TestON logs here (place holder)
100
101echo "Completed running install.sh script"
102echo "Run TestON CLI by typing teston at bash prompt"
103echo "Example: teston run <TestSuite Name>"