Hari Krishna | 7448979 | 2015-07-30 10:07:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # TestON install script for Ubuntu (Debian and Fedora) |
| 4 | |
| 5 | # Fail on error |
| 6 | set -e |
| 7 | |
| 8 | # Fail on unset var usage |
| 9 | set -o nounset |
| 10 | |
| 11 | # Identify Linux release |
| 12 | DIST=Unknown |
| 13 | RELEASE=Unknown |
| 14 | CODENAME=Unknown |
| 15 | |
| 16 | ARCH=`uname -m` |
| 17 | if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; fi |
| 18 | if [ "$ARCH" = "i686" ]; then ARCH="i386"; fi |
| 19 | |
| 20 | if [ -e /etc/debian_version ]; then DIST="Debian"; fi |
| 21 | if [ -e /etc/fedora-release ]; then DIST="Debian"; fi |
| 22 | grep Ubuntu /etc/lsb-release &> /dev/null && DIST="Ubuntu" |
| 23 | |
| 24 | if [ "$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 |
| 32 | fi |
| 33 | |
| 34 | if [ "$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 |
| 42 | fi |
| 43 | if which lsb_release &> /dev/null; then |
| 44 | DIST=`lsb_release -is` |
| 45 | RELEASE=`lsb_release -rs` |
| 46 | CODENAME=`lsb_release -cs` |
| 47 | fi |
| 48 | echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH" |
| 49 | |
| 50 | if ! echo $DIST | egrep 'Ubuntu|Debian|Fedora'; then |
| 51 | echo "Install.sh currently only supports Ubuntu, Debian and Fedora." |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | # Check OnosSystemTest is cloned in home directory. |
| 56 | if [ ! -d ~/OnosSystemTest ]; then |
| 57 | echo "Could not find OnosSystemTest in your home directory." |
| 58 | echo "Exiting from running install script." |
| 59 | exit 1 |
| 60 | fi |
| 61 | |
| 62 | # Install TestON dependencies |
| 63 | echo "Installing TestON dependencies" |
| 64 | if [ "$DIST" = "Fedora" ]; then |
Hari Krishna | bed3dab | 2015-08-05 14:30:30 -0700 | [diff] [blame] | 65 | # Fedora may have vlan enabled by default. Still need to confirm and update later |
Hari Krishna | ec5d0fe | 2015-08-19 13:23:23 -0700 | [diff] [blame^] | 66 | $install python-pip build-essential python-dev pep8 arping |
Hari Krishna | 7448979 | 2015-07-30 10:07:15 -0700 | [diff] [blame] | 67 | $pipinstall pexpect==3.2 configobj==4.7.2 numpy |
| 68 | else |
Hari Krishna | ec5d0fe | 2015-08-19 13:23:23 -0700 | [diff] [blame^] | 69 | $install python-pip build-essential python-dev pep8 vlan arping |
Hari Krishna | 7448979 | 2015-07-30 10:07:15 -0700 | [diff] [blame] | 70 | $pipinstall pexpect==3.2 configobj==4.7.2 numpy |
| 71 | fi |
| 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 |
| 76 | pushd ~ |
| 77 | sudo ln -s ~/OnosSystemTest/TestON TestON |
| 78 | echo "Added symbolic link to TestON folder in HOME directory." |
| 79 | popd |
| 80 | |
| 81 | # OnosSystemTest git pre-commit hooks |
| 82 | pushd ~/OnosSystemTest |
| 83 | cp .git/hooks/pre-commit.sample .git/hooks/pre-commit |
| 84 | popd |
| 85 | |
| 86 | # Add symbolic link to TestON cli in /usr/local/bin |
| 87 | pushd /usr/local/bin |
| 88 | sudo ln -s $HOME/OnosSystemTest/TestON/bin/cli.py teston |
| 89 | echo "Added symbolic link to TestON CLI in /usr/local/bin." |
| 90 | popd |
| 91 | |
| 92 | # Add log rotation configuration for TestON logs here (place holder) |
| 93 | |
| 94 | echo "Completed running install.sh script" |
| 95 | echo "Run TestON CLI by typing teston at bash prompt" |
| 96 | echo "Example: teston run <TestSuite Name>" |