install.sh 2.05 KB
Newer Older
Marek Gumiński's avatar
Marek Gumiński committed
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
#!/bin/bash

if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

# make sure that top directory is called properly

topdir=`basename $PWD`
if [ "$topdir" != "fmcmasterfip" ]
then
    echo "Projects top directory must be called \"fmcmasterfip\""
    echo "Do you want to rename it right now [y/n]"
    read res

    if [ "$res" != "y" ] || [ -z "$res" ]
    then
        echo "Abording"
        exit

    else
        cd ..
        mv "$topdir" fmcmasterfip
        cd fmcmasterfip
    fi
fi

29
apt-get install python-numpy python-scipy python-matplotlib ipython python2-pyro4 python-psutil python-dnspython
30
apt-get install git gitk libusb-dev terminator
31

Marek Gumiński's avatar
Marek Gumiński committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
# initialise and update repository
git submodule init
git submodule update

# build software
cd software
make
cd ..
sleep 1
# load drivers in order to check if no errors occure
./scripts/drivers_load.sh    

sleep 1

# test software
Marek Gumiński's avatar
Marek Gumiński committed
47
if [ `lsmod | grep spec | wc -l` -eq 0 ]; 
Marek Gumiński's avatar
Marek Gumiński committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
then 
    
    echo "ERROR! Required drivers are not loaded correctly:"; 

    lsmod

    exit

fi

if [ `lspci | grep CERN | wc -l` -ne 1 ]
then 

    echo "ERROR! SPEC device not found" 

    lspci
else
    spec=1
fi

Marek Gumiński's avatar
Marek Gumiński committed
68
if [ `ls /sys/bus/fmc/devices | wc -l` -ne 1 ]; 
Marek Gumiński's avatar
Marek Gumiński committed
69
then 
Marek Gumiński's avatar
Marek Gumiński committed
70
    echo "ERROR! No device is visible in /sys/bus/fmc/devices"
Marek Gumiński's avatar
Marek Gumiński committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

    if [ ! -z $spec ]
    then
        echo "ERROR! Drives might not build correctly";

    else
        echo "Make sure that SPEC device is mount correctly and run this script again."
    
    fi
    
    exit
    
fi


echo "Installation successful!"
echo "Creating desktop shortcut"

89 90 91 92 93 94 95 96 97 98
echo -e "[Desktop Entry]
Type=Application
Terminal=false
Name=PTSmasterFIP
Exec=terminator --working-directory=${PWD}/pts/ -e \"sudo -u root ${PWD}/pts/fmcmasterfip.sh ; bash\"
Icon=${PWD}/doc/icon.png
Comment=
Path=
StartupNotify=false
" > ~/Desktop/test_fmcmasterfip.desktop
Marek Gumiński's avatar
Marek Gumiński committed
99

100 101 102 103 104
# copy read_samples.py to logdir
LOGDIR="${HOME}/Desktop/pts_log/fmcmasterfip"
mkdir -p "$LOGDIR/adcdata"
cp "python/read_samples.py" "$LOGDIR/adcdata"

Marek Gumiński's avatar
Marek Gumiński committed
105
# create desktop shortcut
106
chmod +x ~/Desktop/test_fmcmasterfip.desktop