blob: 7c64126b23d442ff5447f981b0cc3742328d2e94 [file] [log] [blame]
#!/bin/bash
# vm-setup.sh
#
# This script installs ONOS dependencies for packet/optical use case.
export CURRENT_USER=optical
export USER_HOME=/home/${CURRENT_USER}
# -------------- Setup keys -------------------
mkdir -p ~/.ssh
ssh-keygen -t dsa -P "" -f .ssh/id_dsa
cp .ssh/id_dsa.pub .ssh/authorized_keys
# -------------- Setup Desktop ---------------
DESKTOP=${USER_HOME}/Desktop
mkdir -p ${DESKTOP}
cat > ${DESKTOP}/ONOS << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=ONOS
Name[en_US]=ONOS
Icon=konsole
Exec=/usr/bin/lxterminal -t 'ONOS' -e 'Applications/apache-karaf-3.0.2/bin/karaf clean'
Comment[en_US]=
EOF
cat > "${DESKTOP}/Mininet Small" << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Mininet Small
Name[en_US]=Mininet Small
Icon=konsole
Exec=/usr/bin/lxterminal -t 'Mininet Small Topology' -e 'sudo -E python onos/tools/test/topos/opticalTest.py'
Comment[en_US]=
EOF
cat > "${DESKTOP}/Mininet Large" << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Mininet Large
Name[en_US]=Mininet Large
Icon=konsole
Exec=/usr/bin/lxterminal -t 'Mininet Large Topology' -e 'sudo -E python onos/tools/test/topos/opticalTestBig.py'
Comment[en_US]=
EOF
cat > "${DESKTOP}/LINC-OE" << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=LINC-OE
Name[en_US]=LINC-OE
Icon=konsole
Exec=/usr/bin/lxterminal -t 'LINC-OE' -e 'sudo linc-oe/rel/linc/bin/linc attach'
Comment[en_US]=
EOF
cat > ${DESKTOP}/Tutorial << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Tutorial
Name[en_US]=Tutorial
Icon=internet-web-browser
Exec=/usr/bin/chromium-browser https://wiki.onosproject.org/display/ONOS/Packet+Optical+Tutorial
Comment[en_US]=
EOF
cat > ${DESKTOP}/GUI << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=ONOS GUI
Name[en_US]=ONOS GUI
Icon=internet-web-browser
Exec=/usr/bin/chromium-browser http://localhost:8181/onos/ui/index.html#topo
Comment[en_US]=
EOF
cat > ${DESKTOP}/Wireshark << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Wireshark
Name[en_US]=Wireshark
Icon=wireshark
Exec=/usr/bin/wireshark
Comment[en_US]=
EOF
cat > ${DESKTOP}/Reset << EOF
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Reset
Name[en_US]=Reset
Icon=konsole
Exec=/usr/bin/lxterminal -t 'Resetting; please wait' -e 'sudo mn -c'
Comment[en_US]=
EOF
# -------------- Setup LINC & dependencies ---------------
git clone https://github.com/FlowForwarding/LINC-config-generator.git
cd ~/LINC-config-generator
git checkout oe-0.4
make
cd
git clone https://github.com/FlowForwarding/LINC-Switch.git linc-oe
cd linc-oe
sed -i s/3000/300000/ rel/files/vm.args
cp rel/files/sys.config.orig rel/files/sys.config
make rel
cd
# -------------- Setup and install Apache Karaf ---------------
mkdir -p Applications
mkdir -p Downloads
cd Downloads
wget http://download.nextag.com/apache/karaf/3.0.2/apache-karaf-3.0.2.tar.gz
tar -zxvf apache-karaf-3.0.2.tar.gz -C ../Applications/
cd
sed -i s/features$/features,mvn:org.onosproject\\/onos-features\\/1.0.1-SNAPSHOT\\/xml\\/features/ ~/Applications/apache-karaf-3.0.2/etc/org.apache.karaf.features.cfg
sed -i s/management$/management,webconsole,onos-rest,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-gui,onos-app-optical,onos-app-proxyarp/ ~/Applications/apache-karaf-3.0.2/etc/org.apache.karaf.features.cfg
# -------------- Setup and install ONOS ---------------
git clone https://gerrit.onosproject.org/onos -b onos-1.0
export ONOS_USER=$CURRENT_USER
export ONOS_ROOT=~/onos
export KARAF_ROOT=~/Applications/apache-karaf-3.0.2
source onos/tools/dev/bash_profile
unset $JAVA_HOME
cd onos && mvn clean install && mvn dependency:go-offline && cd -
cp onos/tools/package/branding/target/onos-branding-1.0.1-SNAPSHOT.jar Applications/apache-karaf-3.0.2/lib/
# Configure cell
cat << EOF >> onos/tools/test/cells/optical
export ONOS_NIC=127.0.0.*
export OC1="127.0.0.1"
export OCI="${OC1}"
export ONOS_FEATURES="webconsole,onos-rest,onos-api,onos-core-trivial,onos-cli,onos-openflow,onos-gui,onos-app-optical,onos-app-proxyarp"
export ONOS_USER="optical"
EOF
# Setup profile
echo "source $ONOS_ROOT/tools/dev/bash_profile" >> ~/.profile
echo "unset JAVA_HOME" >> ~/.profile
echo "sudo service onos stop > /dev/null 2>&1" >> ~/.profile
echo "cell optical > /dev/null 2>&1" >> ~/.profile
# Allow user full access to wireshark
sudo usermod -a -G wireshark optical