blob: 741150c2bd9f6a842169d8db1832a2ef823744d5 [file] [log] [blame]
#!/bin/bash
# vm-setup.sh
#
# This script installs ONOS dependencies and installs a desktop environment on a Miniet VM.
export CURRENT_USER=tutorial1
export SDN_IP_USER=sdnip
export DIST_USER=distributed
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'
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}
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
sudo apt-get update
sudo apt-get install -y git openjdk-8-jdk maven unzip quagga docker.io curl
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'