blob: a7d119ee74e069342d32cdb05f5d320811e11183 [file] [log] [blame]
#!/bin/bash
# vm-setup.sh
#
# This script installs ONOS dependencies and installs a desktop environment on a Mininet VM.
export CURRENT_USER=tutorial1
export SDN_IP_USER=sdnip
export DIST_USER=distributed
export OPT_USER=optical
export USER_HOME=/home/${CURRENT_USER}
URL='https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=tutorial1-setup.sh'
SDNIP_URL='https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=sdnip-setup.sh'
DIST_URL='https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=dist-setup.sh'
OPT_URL='https://gerrit.onosproject.org/gitweb?p=onos-vm.git;a=blob_plain;hb=refs/heads/onos-tutorial;f=opt-setup.sh'
sudo /usr/sbin/useradd -c "Basic ONOS Tutorial" -d /home/${CURRENT_USER} -U -m -p $(openssl passwd -1 ${CURRENT_USER}) -s /bin/bash ${CURRENT_USER}
sudo /usr/sbin/useradd -c "Basic SDN-IP Tutorial" -d /home/${SDN_IP_USER} -U -m -p $(openssl passwd -1 ${SDN_IP_USER}) -s /bin/bash ${SDN_IP_USER}
sudo /usr/sbin/useradd -c "Distributed Tutorial" -d /home/${DIST_USER} -U -m -p $(openssl passwd -1 ${DIST_USER}) -s /bin/bash ${DIST_USER}
sudo /usr/sbin/useradd -c "Optical Tutorial" -d /home/${OPT_USER} -U -m -p $(openssl passwd -1 ${OPT_USER}) -s /bin/bash ${OPT_USER}
echo "${CURRENT_USER} ALL=(ALL) NOPASSWD:ALL" >> tutorial1
sudo cp tutorial1 /etc/sudoers.d
sudo chown root:root /etc/sudoers.d/tutorial1
echo "${SDN_IP_USER} ALL=(ALL) NOPASSWD:ALL" >> sdnip
sudo cp sdnip /etc/sudoers.d
sudo chown root:root /etc/sudoers.d/sdnip
echo "${DIST_USER} ALL=(ALL) NOPASSWD:ALL" >> dist
sudo cp dist /etc/sudoers.d
sudo chown root:root /etc/sudoers.d/dist
echo "${OPT_USER} ALL=(ALL) NOPASSWD:ALL" >> opt
sudo cp opt /etc/sudoers.d
sudo chown root:root /etc/sudoers.d/opt
sudo apt-get update
sudo apt-get install -y git openjdk-8-jdk maven unzip quagga docker.io curl erlang make gcc wget autoconf openssl libssl0.9.8 libssl-dev libncurses5 libncurses5-dev
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
#--------------- Setup Mininet ----------------
#git clone git://github.com/mininet/mininet
#mininet/util/install.sh -a
# -------------- Switch User ------------------
wget -O tutorial1-setup.sh $URL
sudo -u ${CURRENT_USER} -H sh -c 'cp tutorial1-setup.sh ~/ && cd ~/ && sh tutorial1-setup.sh'
wget -O sdnip-setup.sh $SDNIP_URL
sudo -u ${SDN_IP_USER} -H sh -c 'cp sdnip-setup.sh ~/ && cd ~/ && sh sdnip-setup.sh'
wget -O dist-setup.sh $DIST_URL
sudo -u ${DIST_USER} -H sh -c 'cp dist-setup.sh ~/ && cd ~/ && sh dist-setup.sh'
wget -O opt-setup.sh $OPT_URL
sudo -u ${OPT_USER} -H sh -c 'cp opt-setup.sh ~/ && cd ~/ && sh opt-setup.sh'