4 # Copyright 2016 RIFT.IO Inc
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # Author(s): Anil Gunturu
19 # Creation Date: 07/24/2014
23 # This script is used to copy the riftware software into the qcow image
24 # This script must be run on the grunt machine as root
30 if ! [ $# -eq 1 ]; then
31 echo "Usage: $0 <ping-pong-ns-dir>"
33 echo " $0 /net/boson/home1/agunturu/lepton/atg/modules/core/mc/examples/ping_pong_ns"
37 # Currently returning 0 on error as this script fails in Bangalore
38 # systems and causes the jenkins spot_debug to fail
40 if [ "$(ls -A $MOUNT_PT)" ]; then
41 guestunmount
$MOUNT_PT
47 MOUNT_PT
=ping_pong
/mnt$$
49 if [ -d $MOUNT_PT ]; then
50 echo "ping_pong_mnt directory exists - deleting..!!"
51 guestunmount
$MOUNT_PT || true
56 FC20QCOW
=Fedora-x86_64-20-20131211.1
-sda.qcow2
57 PINGQCOW
=Fedora-x86_64-20-20131211.1
-sda-ping.qcow2
58 PONGQCOW
=Fedora-x86_64-20-20131211.1
-sda-pong.qcow2
60 if [ ! -e ${RIFT_ROOT}/images
/${FC20QCOW} ]; then
61 echo >&2 "Warn: Cannot prepare ping_pong qcow due to missing FC20 image: ${RIFT_ROOT}/images/${FC20QCOW}"
65 echo "Copying $FC20QCOW"
66 cp ${RIFT_ROOT}/images/${FC20QCOW} ping_pong/${PINGQCOW}
67 chmod +w ping_pong
/${PINGQCOW}
68 cp ${RIFT_ROOT}/images/${FC20QCOW} ping_pong/${PONGQCOW}
69 chmod +w ping_pong
/${PONGQCOW}
72 echo "Mounting guestfs for $PINGQCOW"
73 guestmount
-a ping_pong
/$PINGQCOW -m /dev
/sda1
$MOUNT_PT
75 echo "Setting up resolv.conf"
76 # removed RIFT.io lab-centric setup in RIFT-11991
77 #echo "search lab.riftio.com eng.riftio.com riftio.com" > $MOUNT_PT/etc/resolv.conf
78 #echo "nameserver 10.64.1.3" >> $MOUNT_PT/etc/resolv.conf
79 #echo "PEERDNS=no" >> $MOUNT_PT/etc/sysconfig/network-scripts/ifcfg-eth0
81 # add a valid DNS server just in case
82 echo "nameserver 8.8.8.8" > $MOUNT_PT/etc
/resolv.conf
83 echo "DEFROUTE=yes" >> $MOUNT_PT/etc
/sysconfig
/network-scripts
/ifcfg-eth0
87 cat <<EOF >> $MOUNT_PT/etc/sysconfig/network-scripts/ifcfg-eth$i
98 echo "Copying ping/pong ns..."
104 mv $MOUNT_PT/opt
/rift
/ping_pong_ns
/ping.service
$MOUNT_PT/etc
/systemd
/system
105 cp -ar /usr
/lib
/python2.7
/site-packages
/tornado
$MOUNT_PT/usr
/lib
/python2.7
/site-packages
/
106 guestunmount
$MOUNT_PT
108 echo "Mounting guestfs for $PINGQCOW"
109 guestmount
-a ping_pong
/$PONGQCOW -m /dev
/sda1
$MOUNT_PT
111 echo "Setting up resolv.conf"
112 echo "search lab.riftio.com eng.riftio.com riftio.com" > $MOUNT_PT/etc
/resolv.conf
113 echo "nameserver 10.64.1.3" >> $MOUNT_PT/etc
/resolv.conf
114 echo "PEERDNS=no" >> $MOUNT_PT/etc
/sysconfig
/network-scripts
/ifcfg-eth0
115 echo "DEFROUTE=yes" >> $MOUNT_PT/etc
/sysconfig
/network-scripts
/ifcfg-eth0
119 cat <<EOF >> $MOUNT_PT/etc/sysconfig/network-scripts/ifcfg-eth$i
129 echo "Copying ping/pong ns..."
135 cp -ar /usr
/lib
/python2.7
/site-packages
/tornado
$MOUNT_PT/usr
/lib
/python2.7
/site-packages
/
136 mv $MOUNT_PT/opt
/rift
/ping_pong_ns
/pong.service
$MOUNT_PT/etc
/systemd
/system
137 guestunmount
$MOUNT_PT