diff options
Diffstat (limited to 'boot')
-rw-r--r-- | boot/aaf_install.sh | 94 | ||||
-rw-r--r-- | boot/aaf_serv.sh | 98 | ||||
-rw-r--r-- | boot/aaf_vm_init.sh | 6 | ||||
-rw-r--r-- | boot/bind_zones | 14 | ||||
-rw-r--r-- | boot/bind_zones_onap | 16 | ||||
-rw-r--r-- | boot/db_simpledemo_onap_org | 20 | ||||
-rw-r--r-- | boot/db_simpledemo_openecomp_org | 20 | ||||
-rw-r--r-- | boot/dns_install.sh | 6 | ||||
-rw-r--r-- | boot/music_install.sh | 94 | ||||
-rw-r--r-- | boot/music_serv.sh | 98 | ||||
-rw-r--r-- | boot/music_vm_init.sh | 13 | ||||
-rw-r--r-- | boot/oof_install.sh | 94 | ||||
-rw-r--r-- | boot/oof_serv.sh | 98 | ||||
-rw-r--r-- | boot/oof_vm_init.sh | 6 |
14 files changed, 672 insertions, 5 deletions
diff --git a/boot/aaf_install.sh b/boot/aaf_install.sh new file mode 100644 index 00000000..14363269 --- /dev/null +++ b/boot/aaf_install.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# Read configuration files +NEXUS_REPO=$(cat /opt/config/nexus_repo.txt) +ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt) +DNS_IP_ADDR=$(cat /opt/config/dns_ip_addr.txt) +CLOUD_ENV=$(cat /opt/config/cloud_env.txt) +MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) + +# Add host name to /etc/host to avoid warnings in openstack images +if [[ $CLOUD_ENV != "rackspace" ]] +then + echo 127.0.0.1 $(hostname) >> /etc/hosts + + # Allow remote login as root + mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk + cp /home/ubuntu/.ssh/authorized_keys /root/.ssh +fi + +# Set private IP in /etc/network/interfaces manually in the presence of public interface +# Some VM images don't add the private interface automatically, we have to do it during the component installation +if [[ $CLOUD_ENV == "openstack_nofloat" ]] +then + LOCAL_IP=$(cat /opt/config/local_ip_addr.txt) + CIDR=$(cat /opt/config/oam_network_cidr.txt) + BITMASK=$(echo $CIDR | cut -d"/" -f2) + + # Compute the netmask based on the network cidr + if [[ $BITMASK == "8" ]] + then + NETMASK=255.0.0.0 + elif [[ $BITMASK == "16" ]] + then + NETMASK=255.255.0.0 + elif [[ $BITMASK == "24" ]] + then + NETMASK=255.255.255.0 + fi + + echo "auto eth1" >> /etc/network/interfaces + echo "iface eth1 inet static" >> /etc/network/interfaces + echo " address $LOCAL_IP" >> /etc/network/interfaces + echo " netmask $NETMASK" >> /etc/network/interfaces + echo " mtu $MTU" >> /etc/network/interfaces + ifup eth1 +fi + +# Download dependencies +echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list +echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list +apt-get update +apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate make + +# Download scripts from Nexus +curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/aaf_vm_init.sh -o /opt/aaf_vm_init.sh +curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/aaf_serv.sh -o /opt/aaf_serv.sh +chmod +x /opt/aaf_vm_init.sh +chmod +x /opt/aaf_serv.sh +mv /opt/aaf_serv.sh /etc/init.d +update-rc.d aaf_serv.sh defaults + +# Download and install docker-engine and docker-compose +echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | tee /etc/apt/sources.list.d/docker.list +apt-get update +apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual +apt-get install -y --allow-unauthenticated docker-engine + +mkdir /opt/docker +curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose +chmod +x /opt/docker/docker-compose + +# Set the MTU size of docker containers to the minimum MTU size supported by vNICs. OpenStack deployments may need to know the external DNS IP +DNS_FLAG="" +if [ -s /opt/config/dns_ip_addr.txt ] +then + DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/dns_ip_addr.txt) " +fi +if [ -s /opt/config/external_dns.txt ] +then + DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) " +fi +echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU\"" >> /etc/default/docker + +cp /lib/systemd/system/docker.service /etc/systemd/system +sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service +service docker restart + +# DNS IP address configuration +echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head +resolvconf -u + +# Clone Gerrit repository and run docker containers +cd /opt +./aaf_vm_init.sh
\ No newline at end of file diff --git a/boot/aaf_serv.sh b/boot/aaf_serv.sh new file mode 100644 index 00000000..73d22ad3 --- /dev/null +++ b/boot/aaf_serv.sh @@ -0,0 +1,98 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start daemon at boot time +# Description: Enable service provided by daemon. +### END INIT INFO + +dir="/opt" +cmd="./aaf_vm_init.sh" +user="root" + +name=`basename $0` +pid_file="/var/run/$name.pid" +stdout_log="/var/log/$name.log" +stderr_log="/var/log/$name.err" + +get_pid() { + cat "$pid_file" +} + +is_running() { + [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1 +} + +case "$1" in + start) + if is_running; then + echo "Already started" + else + echo "Starting $name" + cd "$dir" + if [ -z "$user" ]; then + sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & + else + sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & + fi + echo $! > "$pid_file" + if ! is_running; then + echo "Unable to start, see $stdout_log and $stderr_log" + exit 1 + fi + fi + ;; + stop) + if is_running; then + echo -n "Stopping $name.." + kill `get_pid` + for i in {1..10} + do + if ! is_running; then + break + fi + + echo -n "." + sleep 1 + done + echo + + if is_running; then + echo "Not stopped; may still be shutting down or shutdown may have failed" + exit 1 + else + echo "Stopped" + if [ -f "$pid_file" ]; then + rm "$pid_file" + fi + fi + else + echo "Not running" + fi + ;; + restart) + $0 stop + if is_running; then + echo "Unable to stop, will not attempt to start" + exit 1 + fi + $0 start + ;; + status) + if is_running; then + echo "Running" + else + echo "Stopped" + exit 1 + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/boot/aaf_vm_init.sh b/boot/aaf_vm_init.sh new file mode 100644 index 00000000..d0f23953 --- /dev/null +++ b/boot/aaf_vm_init.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) +NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) +NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) +DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt)
\ No newline at end of file diff --git a/boot/bind_zones b/boot/bind_zones index 870def1d..1dfd6d02 100644 --- a/boot/bind_zones +++ b/boot/bind_zones @@ -77,12 +77,16 @@ vm1.clamp.simpledemo.openecomp.org. IN A clamp_ip_addr c1.vm1.clamp.simpledemo.openecomp.org. IN A clamp_ip_addr c2.vm1.clamp.simpledemo.openecomp.org. IN A clamp_ip_addr -;vm1.aaf.simpledemo.openecomp.org. IN A aaf_ip_addr +vm1.aaf.simpledemo.openecomp.org. IN A aaf_ip_addr vm1.mr.simpledemo.openecomp.org. IN A mr_ip_addr vm1.openo.simpledemo.openecomp.org. IN A openo_ip_addr +vm1.music.simpledemo.openecomp.org. IN A music_ip_addr + +vm1.oof.simpledemo.openecomp.org. IN A oof_ip_addr + ;CNAMES ;A&AI @@ -131,7 +135,7 @@ robot.api.simpledemo.openecomp.org. IN CNAME vm1.robot.simpledemo.openecomp.org. sniro.api.simpledemo.openecomp.org. IN CNAME vm1.robot.simpledemo.openecomp.org. ;AAF -;aaf.api.simpledemo.openecomp.org. IN CNAME vm1.aaf.simpledemo.openecomp.org. +aaf.api.simpledemo.openecomp.org. IN CNAME vm1.aaf.simpledemo.openecomp.org. ;OPEN-O msb.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. @@ -140,3 +144,9 @@ vnfsdk.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp. vfc.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. uui.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. esr.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. + +;MUSIC +music.api.simpledemo.openecomp.org. IN CNAME vm1.music.simpledemo.openecomp.org. + +;OOF +oof.api.simpledemo.openecomp.org. IN CNAME vm1.oof.simpledemo.openecomp.org.
\ No newline at end of file diff --git a/boot/bind_zones_onap b/boot/bind_zones_onap index 365e3a3a..425f3d1e 100644 --- a/boot/bind_zones_onap +++ b/boot/bind_zones_onap @@ -77,12 +77,16 @@ vm1.clamp.simpledemo.onap.org. IN A clamp_ip_addr c1.vm1.clamp.simpledemo.onap.org. IN A clamp_ip_addr c2.vm1.clamp.simpledemo.onap.org. IN A clamp_ip_addr -;vm1.aaf.simpledemo.onap.org. IN A aaf_ip_addr +vm1.aaf.simpledemo.onap.org. IN A aaf_ip_addr vm1.mr.simpledemo.onap.org. IN A mr_ip_addr vm1.openo.simpledemo.onap.org. IN A openo_ip_addr +vm1.music.simpledemo.openecomp.org. IN A music_ip_addr + +vm1.oof.simpledemo.openecomp.org. IN A oof_ip_addr + ;CNAMES ;A&AI @@ -131,7 +135,7 @@ robot.api.simpledemo.onap.org. IN CNAME vm1.robot.simpledemo.onap.org. sniro.api.simpledemo.onap.org. IN CNAME vm1.robot.simpledemo.onap.org. ;AAF -;aaf.api.simpledemo.onap.org. IN CNAME vm1.aaf.simpledemo.onap.org. +aaf.api.simpledemo.onap.org. IN CNAME vm1.aaf.simpledemo.onap.org. ;OPEN-O msb.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. @@ -139,4 +143,10 @@ mvim.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. vnfsdk.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. vfc.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. uui.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. -esr.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org.
\ No newline at end of file +esr.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. + +;MUSIC +music.api.simpledemo.onap.org. IN CNAME vm1.music.simpledemo.onap.org. + +;OOF +oof.api.simpledemo.onap.org. IN CNAME vm1.oof.simpledemo.onap.org.
\ No newline at end of file diff --git a/boot/db_simpledemo_onap_org b/boot/db_simpledemo_onap_org index ca583c9b..c3a2df84 100644 --- a/boot/db_simpledemo_onap_org +++ b/boot/db_simpledemo_onap_org @@ -81,6 +81,12 @@ vm1.clamp.simpledemo.onap.org. IN A 10.0.12.1 c1.vm1.clamp.simpledemo.onap.org. IN A 10.0.12.1 c2.vm1.clamp.simpledemo.onap.org. IN A 10.0.12.1 +vm1.openo.simpledemo.onap.org. IN A 10.0.14.1 + +vm1.music.simpledemo.onap.org. IN A 10.0.15.1 + +vm1.oof.simpledemo.onap.org. IN A 10.0.16.1 + ;CNAMES ;A&AI @@ -132,3 +138,17 @@ clamp.api.simpledemo.onap.org. IN CNAME vm1.clamp.simpledemo.onap.org. ;AAF aaf.api.simpledemo.onap.org. IN CNAME vm1.aaf.simpledemo.onap.org. + +;OPEN-O +msb.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. +mvim.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. +vnfsdk.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. +vfc.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. +uui.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. +esr.api.simpledemo.onap.org. IN CNAME vm1.openo.simpledemo.onap.org. + +;MUSIC +music.api.simpledemo.onap.org. IN CNAME vm1.music.simpledemo.onap.org. + +;OOF +oof.api.simpledemo.onap.org. IN CNAME vm1.oof.simpledemo.onap.org.
\ No newline at end of file diff --git a/boot/db_simpledemo_openecomp_org b/boot/db_simpledemo_openecomp_org index b025f7bb..e867a26f 100644 --- a/boot/db_simpledemo_openecomp_org +++ b/boot/db_simpledemo_openecomp_org @@ -81,6 +81,12 @@ vm1.clamp.simpledemo.openecomp.org. IN A 10.0.12.1 c1.vm1.clamp.simpledemo.openecomp.org. IN A 10.0.12.1 c2.vm1.clamp.simpledemo.openecomp.org. IN A 10.0.12.1 +vm1.openo.simpledemo.openecomp.org. IN A 10.0.14.1 + +vm1.music.simpledemo.openecomp.org. IN A 10.0.15.1 + +vm1.oof.simpledemo.openecomp.org. IN A 10.0.16.1 + ;CNAMES ;A&AI @@ -132,3 +138,17 @@ clamp.api.simpledemo.openecomp.org. IN CNAME vm1.clamp.simpledemo.openecomp.org. ;AAF aaf.api.simpledemo.openecomp.org. IN CNAME vm1.aaf.simpledemo.openecomp.org. + +;OPEN-O +msb.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. +mvim.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. +vnfsdk.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. +vfc.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. +uui.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. +esr.api.simpledemo.openecomp.org. IN CNAME vm1.openo.simpledemo.openecomp.org. + +;MUSIC +music.api.simpledemo.openecomp.org. IN CNAME vm1.music.simpledemo.openecomp.org. + +;OOF +oof.api.simpledemo.openecomp.org. IN CNAME vm1.oof.simpledemo.openecomp.org. diff --git a/boot/dns_install.sh b/boot/dns_install.sh index 79272cbd..239bfce5 100644 --- a/boot/dns_install.sh +++ b/boot/dns_install.sh @@ -88,6 +88,9 @@ then sed -i "s/vid_ip_addr/"$(cat /opt/config/vid_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org sed -i "s/clamp_ip_addr/"$(cat /opt/config/clamp_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org sed -i "s/openo_ip_addr/"$(cat /opt/config/openo_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org + sed -i "s/music_ip_addr/"$(cat /opt/config/music_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org + sed -i "s/oof_ip_addr/"$(cat /opt/config/oof_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org + sed -i "s/aaf_ip_addr/"$(cat /opt/config/aaf_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org sed -i "s/aai1_ip_addr/"$(cat /opt/config/aai1_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.onap.org sed -i "s/aai2_ip_addr/"$(cat /opt/config/aai2_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.onap.org @@ -104,6 +107,9 @@ then sed -i "s/vid_ip_addr/"$(cat /opt/config/vid_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.onap.org sed -i "s/clamp_ip_addr/"$(cat /opt/config/clamp_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.onap.org sed -i "s/openo_ip_addr/"$(cat /opt/config/openo_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.onap.org + sed -i "s/music_ip_addr/"$(cat /opt/config/music_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org + sed -i "s/oof_ip_addr/"$(cat /opt/config/oof_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org + sed -i "s/aaf_ip_addr/"$(cat /opt/config/aaf_ip_addr.txt)"/g" /etc/bind/zones/db.simpledemo.openecomp.org fi # Configure Bind diff --git a/boot/music_install.sh b/boot/music_install.sh new file mode 100644 index 00000000..6965b957 --- /dev/null +++ b/boot/music_install.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# Read configuration files +NEXUS_REPO=$(cat /opt/config/nexus_repo.txt) +ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt) +DNS_IP_ADDR=$(cat /opt/config/dns_ip_addr.txt) +CLOUD_ENV=$(cat /opt/config/cloud_env.txt) +MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) + +# Add host name to /etc/host to avoid warnings in openstack images +if [[ $CLOUD_ENV != "rackspace" ]] +then + echo 127.0.0.1 $(hostname) >> /etc/hosts + + # Allow remote login as root + mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk + cp /home/ubuntu/.ssh/authorized_keys /root/.ssh +fi + +# Set private IP in /etc/network/interfaces manually in the presence of public interface +# Some VM images don't add the private interface automatically, we have to do it during the component installation +if [[ $CLOUD_ENV == "openstack_nofloat" ]] +then + LOCAL_IP=$(cat /opt/config/local_ip_addr.txt) + CIDR=$(cat /opt/config/oam_network_cidr.txt) + BITMASK=$(echo $CIDR | cut -d"/" -f2) + + # Compute the netmask based on the network cidr + if [[ $BITMASK == "8" ]] + then + NETMASK=255.0.0.0 + elif [[ $BITMASK == "16" ]] + then + NETMASK=255.255.0.0 + elif [[ $BITMASK == "24" ]] + then + NETMASK=255.255.255.0 + fi + + echo "auto eth1" >> /etc/network/interfaces + echo "iface eth1 inet static" >> /etc/network/interfaces + echo " address $LOCAL_IP" >> /etc/network/interfaces + echo " netmask $NETMASK" >> /etc/network/interfaces + echo " mtu $MTU" >> /etc/network/interfaces + ifup eth1 +fi + +# Download dependencies +echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list +echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list +apt-get update +apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate make + +# Download scripts from Nexus +curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/music_vm_init.sh -o /opt/music_vm_init.sh +curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/music_serv.sh -o /opt/music_serv.sh +chmod +x /opt/music_vm_init.sh +chmod +x /opt/music_serv.sh +mv /opt/music_serv.sh /etc/init.d +update-rc.d music_serv.sh defaults + +# Download and install docker-engine and docker-compose +echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | tee /etc/apt/sources.list.d/docker.list +apt-get update +apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual +apt-get install -y --allow-unauthenticated docker-engine + +mkdir /opt/docker +curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose +chmod +x /opt/docker/docker-compose + +# Set the MTU size of docker containers to the minimum MTU size supported by vNICs. OpenStack deployments may need to know the external DNS IP +DNS_FLAG="" +if [ -s /opt/config/dns_ip_addr.txt ] +then + DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/dns_ip_addr.txt) " +fi +if [ -s /opt/config/external_dns.txt ] +then + DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) " +fi +echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU\"" >> /etc/default/docker + +cp /lib/systemd/system/docker.service /etc/systemd/system +sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service +service docker restart + +# DNS IP address configuration +echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head +resolvconf -u + +# Clone Gerrit repository and run docker containers +cd /opt +./music_vm_init.sh
\ No newline at end of file diff --git a/boot/music_serv.sh b/boot/music_serv.sh new file mode 100644 index 00000000..29dc4c3c --- /dev/null +++ b/boot/music_serv.sh @@ -0,0 +1,98 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start daemon at boot time +# Description: Enable service provided by daemon. +### END INIT INFO + +dir="/opt" +cmd="./music_vm_init.sh" +user="root" + +name=`basename $0` +pid_file="/var/run/$name.pid" +stdout_log="/var/log/$name.log" +stderr_log="/var/log/$name.err" + +get_pid() { + cat "$pid_file" +} + +is_running() { + [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1 +} + +case "$1" in + start) + if is_running; then + echo "Already started" + else + echo "Starting $name" + cd "$dir" + if [ -z "$user" ]; then + sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & + else + sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & + fi + echo $! > "$pid_file" + if ! is_running; then + echo "Unable to start, see $stdout_log and $stderr_log" + exit 1 + fi + fi + ;; + stop) + if is_running; then + echo -n "Stopping $name.." + kill `get_pid` + for i in {1..10} + do + if ! is_running; then + break + fi + + echo -n "." + sleep 1 + done + echo + + if is_running; then + echo "Not stopped; may still be shutting down or shutdown may have failed" + exit 1 + else + echo "Stopped" + if [ -f "$pid_file" ]; then + rm "$pid_file" + fi + fi + else + echo "Not running" + fi + ;; + restart) + $0 stop + if is_running; then + echo "Unable to stop, will not attempt to start" + exit 1 + fi + $0 start + ;; + status) + if is_running; then + echo "Running" + else + echo "Stopped" + exit 1 + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/boot/music_vm_init.sh b/boot/music_vm_init.sh new file mode 100644 index 00000000..b18aa998 --- /dev/null +++ b/boot/music_vm_init.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) +NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) +NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) +DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt) + +docker pull library/zookeeper:3.4 +docker pull library/tomcat:8.5 + +docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO +docker pull $NEXUS_DOCKER_REPO/onap/music/Cassandra:$DOCKER_IMAGE_VERSION +docker pull $NEXUS_DOCKER_REPO/onap/music/music:$DOCKER_IMAGE_VERSION
\ No newline at end of file diff --git a/boot/oof_install.sh b/boot/oof_install.sh new file mode 100644 index 00000000..d4921371 --- /dev/null +++ b/boot/oof_install.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +# Read configuration files +NEXUS_REPO=$(cat /opt/config/nexus_repo.txt) +ARTIFACTS_VERSION=$(cat /opt/config/artifacts_version.txt) +DNS_IP_ADDR=$(cat /opt/config/dns_ip_addr.txt) +CLOUD_ENV=$(cat /opt/config/cloud_env.txt) +MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1) + +# Add host name to /etc/host to avoid warnings in openstack images +if [[ $CLOUD_ENV != "rackspace" ]] +then + echo 127.0.0.1 $(hostname) >> /etc/hosts + + # Allow remote login as root + mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk + cp /home/ubuntu/.ssh/authorized_keys /root/.ssh +fi + +# Set private IP in /etc/network/interfaces manually in the presence of public interface +# Some VM images don't add the private interface automatically, we have to do it during the component installation +if [[ $CLOUD_ENV == "openstack_nofloat" ]] +then + LOCAL_IP=$(cat /opt/config/local_ip_addr.txt) + CIDR=$(cat /opt/config/oam_network_cidr.txt) + BITMASK=$(echo $CIDR | cut -d"/" -f2) + + # Compute the netmask based on the network cidr + if [[ $BITMASK == "8" ]] + then + NETMASK=255.0.0.0 + elif [[ $BITMASK == "16" ]] + then + NETMASK=255.255.0.0 + elif [[ $BITMASK == "24" ]] + then + NETMASK=255.255.255.0 + fi + + echo "auto eth1" >> /etc/network/interfaces + echo "iface eth1 inet static" >> /etc/network/interfaces + echo " address $LOCAL_IP" >> /etc/network/interfaces + echo " netmask $NETMASK" >> /etc/network/interfaces + echo " mtu $MTU" >> /etc/network/interfaces + ifup eth1 +fi + +# Download dependencies +echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list +echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list +apt-get update +apt-get install --allow-unauthenticated -y apt-transport-https ca-certificates wget openjdk-8-jdk git ntp ntpdate make + +# Download scripts from Nexus +curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/oof_vm_init.sh -o /opt/oof_vm_init.sh +curl -k $NEXUS_REPO/org.onap.demo/boot/$ARTIFACTS_VERSION/oof_serv.sh -o /opt/oof_serv.sh +chmod +x /opt/oof_vm_init.sh +chmod +x /opt/oof_serv.sh +mv /opt/oof_serv.sh /etc/init.d +update-rc.d oof_serv.sh defaults + +# Download and install docker-engine and docker-compose +echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | tee /etc/apt/sources.list.d/docker.list +apt-get update +apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual +apt-get install -y --allow-unauthenticated docker-engine + +mkdir /opt/docker +curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /opt/docker/docker-compose +chmod +x /opt/docker/docker-compose + +# Set the MTU size of docker containers to the minimum MTU size supported by vNICs. OpenStack deployments may need to know the external DNS IP +DNS_FLAG="" +if [ -s /opt/config/dns_ip_addr.txt ] +then + DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/dns_ip_addr.txt) " +fi +if [ -s /opt/config/external_dns.txt ] +then + DNS_FLAG=$DNS_FLAG"--dns $(cat /opt/config/external_dns.txt) " +fi +echo "DOCKER_OPTS=\"$DNS_FLAG--mtu=$MTU\"" >> /etc/default/docker + +cp /lib/systemd/system/docker.service /etc/systemd/system +sed -i "/ExecStart/s/$/ --mtu=$MTU/g" /etc/systemd/system/docker.service +service docker restart + +# DNS IP address configuration +echo "nameserver "$DNS_IP_ADDR >> /etc/resolvconf/resolv.conf.d/head +resolvconf -u + +# Clone Gerrit repository and run docker containers +cd /opt +./oof_vm_init.sh
\ No newline at end of file diff --git a/boot/oof_serv.sh b/boot/oof_serv.sh new file mode 100644 index 00000000..58a1691b --- /dev/null +++ b/boot/oof_serv.sh @@ -0,0 +1,98 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start daemon at boot time +# Description: Enable service provided by daemon. +### END INIT INFO + +dir="/opt" +cmd="./oof_vm_init.sh" +user="root" + +name=`basename $0` +pid_file="/var/run/$name.pid" +stdout_log="/var/log/$name.log" +stderr_log="/var/log/$name.err" + +get_pid() { + cat "$pid_file" +} + +is_running() { + [ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1 +} + +case "$1" in + start) + if is_running; then + echo "Already started" + else + echo "Starting $name" + cd "$dir" + if [ -z "$user" ]; then + sudo $cmd >> "$stdout_log" 2>> "$stderr_log" & + else + sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" & + fi + echo $! > "$pid_file" + if ! is_running; then + echo "Unable to start, see $stdout_log and $stderr_log" + exit 1 + fi + fi + ;; + stop) + if is_running; then + echo -n "Stopping $name.." + kill `get_pid` + for i in {1..10} + do + if ! is_running; then + break + fi + + echo -n "." + sleep 1 + done + echo + + if is_running; then + echo "Not stopped; may still be shutting down or shutdown may have failed" + exit 1 + else + echo "Stopped" + if [ -f "$pid_file" ]; then + rm "$pid_file" + fi + fi + else + echo "Not running" + fi + ;; + restart) + $0 stop + if is_running; then + echo "Unable to stop, will not attempt to start" + exit 1 + fi + $0 start + ;; + status) + if is_running; then + echo "Running" + else + echo "Stopped" + exit 1 + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/boot/oof_vm_init.sh b/boot/oof_vm_init.sh new file mode 100644 index 00000000..d0f23953 --- /dev/null +++ b/boot/oof_vm_init.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) +NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) +NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) +DOCKER_IMAGE_VERSION=$(cat /opt/config/docker_version.txt)
\ No newline at end of file |