<commit_before>#!/bin/sh

# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             #
#                                                                            #
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
# not use this file except in compliance with the License. You may obtain    #
# a copy of the License at                                                   #
#                                                                            #
# http://www.apache.org/licenses/LICENSE-2.0                                 #
#                                                                            #
# Unless required by applicable law or agreed to in writing, software        #
# distributed under the License is distributed on an "AS IS" BASIS,          #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
# See the License for the specific language governing permissions and        #
# limitations under the License.                                             #
#--------------------------------------------------------------------------- #

if [ -f /mnt/context.sh ]
then
  . /mnt/context.sh
fi

##############################################################
#Please set all variables accordingly:
ONE_USER=
ONE_PASSWD=
#paste the content of your ~/.ssh/id_rsa.pub between quotes
PUBKEY=""
#use the xtreemfs url where the latest BaTS jars reside (e.g. 10.0.0.1/TaskFarm)
FRESH_BATS= 

echo $HOSTNAME > /etc/hostname
hostname $HOSTNAME
sed -i "/127.0.1.1/s/ubuntu/$HOSTNAME/" /etc/hosts
echo "10.0.0.200  n00.cumulus.zib.de n00" >> /etc/hosts
echo "10.0.0.201  n01.cumulus.zib.de n01" >> /etc/hosts 
echo "10.0.0.202  n02.cumulus.zib.de n02" >> /etc/hosts
echo "10.0.0.203  n03.cumulus.zib.de n03" >> /etc/hosts
echo "10.0.0.204  n04.cumulus.zib.de n04" >> /etc/hosts
echo "10.0.0.205  n05.cumulus.zib.de n05" >> /etc/hosts
echo "10.0.0.206  n06.cumulus.zib.de n06" >> /etc/hosts
echo "10.0.0.207  n07.cumulus.zib.de n07" >> /etc/hosts
echo "10.0.0.208  n08.cumulus.zib.de n08" >> /etc/hosts
echo "10.0.0.209  n09.cumulus.zib.de n09" >> /etc/hosts
echo "10.0.0.210  n10.cumulus.zib.de n10" >> /etc/hosts
echo "10.0.0.211  n11.cumulus.zib.de n11" >> /etc/hosts
echo "10.0.0.212  n12.cumulus.zib.de n12" >> /etc/hosts
echo "10.0.0.213  n13.cumulus.zib.de n13" >> /etc/hosts
echo "10.0.0.214  n14.cumulus.zib.de n14" >> /etc/hosts
echo "10.0.0.215  n15.cumulus.zib.de n15" >> /etc/hosts
echo "10.0.0.216  n16.cumulus.zib.de n16" >> /etc/hosts
echo "10.0.0.217  n17.cumulus.zib.de n17" >> /etc/hosts
echo "10.0.0.218  n18.cumulus.zib.de n18" >> /etc/hosts
echo "10.0.0.219  n19.cumulus.zib.de n19" >> /etc/hosts
echo "10.0.0.220  n20.cumulus.zib.de n20" >> /etc/hosts
echo "10.0.0.221  n21.cumulus.zib.de n21" >> /etc/hosts
echo "10.0.0.222  n22.cumulus.zib.de n22" >> /etc/hosts
echo "10.0.0.223  n23.cumulus.zib.de n23" >> /etc/hosts
echo "10.0.0.224  n24.cumulus.zib.de n24" >> /etc/hosts
echo "10.0.0.225  n25.cumulus.zib.de n25" >> /etc/hosts
echo "10.0.0.226  n26.cumulus.zib.de n26" >> /etc/hosts
echo "10.0.0.227  n27.cumulus.zib.de n27" >> /etc/hosts
echo "10.0.0.228  n28.cumulus.zib.de n28" >> /etc/hosts
echo "10.0.0.229  n29.cumulus.zib.de n29" >> /etc/hosts
echo "10.0.0.230  n30.cumulus.zib.de n30" >> /etc/hosts
echo "10.0.0.231  n31.cumulus.zib.de n31" >> /etc/hosts

##############################################################

export ONE_USER
export ONE_PASSWD
export ONE_AUTH_CONTENT=$ONE_USER:$ONE_PASSWD


# no files passed in the contextualization, so no id_rsa.pub
# set here your own key to enable access to the vm

export PUBKEY
if [ -n "$PUBKEY" ]; then
	mkdir -p /root/.ssh
	echo $PUBKEY >> /root/.ssh/authorized_keys
	chmod 600 /root/.ssh/authorized_keys
	chmod 700 /root/.ssh	
fi
##############################################################

if [ -n "$IP_PUBLIC" ]; then
	ifconfig eth0 $IP_PUBLIC
fi
 
if [ -n "$NETMASK" ]; then
	ifconfig eth0 netmask $NETMASK
fi

if [ -f /mnt/$ROOT_PUBKEY ]; then
	mkdir -p /root/.ssh
	cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
	#chmod -R 600 /root/.ssh/
	chmod 600 /root/.ssh/authorized_keys
	chmod 700 /root/.ssh
fi

if [ -n "$USERNAME" ]; then
	useradd -s /bin/bash -m $USERNAME
	if [ -f /mnt/$USER_PUBKEY ]; then
		mkdir -p /home/$USERNAME/.ssh/
		cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
		chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
		chmod 600 /home/$USERNAME/.ssh/authorized_keys
	fi
fi

# added:
if [ -n "$IP_GATEWAY" ]; then
        # Change gateway from default; note eth0 is already active
        (           
            ip route add default via $IP_GATEWAY
            echo Now set IP_GATEWAY to $IP_GATEWAY
        ) >> /var/log/context.log 2>&1

fi

# added:
if [ -n "$NAMESERVER" ]; then
        echo "Setting DNS server to $NAMESERVER" >>/var/log/context.log
        echo "nameserver $NAMESERVER" >/etc/resolv.conf
fi

#=============================================================================
# Specifics for the Bats manager
#-----------------------------------------------------------------------------

export BATS_HOME=/home/opennebula/BoT
export BATS_HOME_LIB=$BATS_HOME/lib
export IPL_HOME=$BATS_HOME/ibis

export FRESH_BATS

mkdir $BATS_HOME_LIB
#----------------------------------------------------------------------------

#============================================================================
# The worker's init.sh. Export the filename so that the JVM knows where it is.
# this is the content of /home/vumaricel/batsManager/OpenNebulaCluster/init.sh
# with escaped variables

export WORKER_INIT_SH=$BATS_HOME/init.sh

cat > $WORKER_INIT_SH <<EOF
#!bin/bash

# THIS FILE IS THE INIT.SH FOR THE WORKERS. IT WILL BE CONVERTED TO A HEX STRING AND PASSED TO THE WORKERS.

if [ -f /mnt/context.sh ]
then<commit_msg>- known issues:    - poor XML parser of the cluster configuration file. This should be fixed once we know the OVF that will be provided by the federation    describing the available instances.   - service shutdown only terminates the manager instance   - send makespan in minutes to the GUI (right now is expressed in timeUnits, that is the reservation cycle for which the user pays, e.g. 1hour for EC2)   - clean up schedules generation<commit_after>#!/bin/sh

# -------------------------------------------------------------------------- #
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             #
#                                                                            #
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
# not use this file except in compliance with the License. You may obtain    #
# a copy of the License at                                                   #
#                                                                            #
# http://www.apache.org/licenses/LICENSE-2.0                                 #
#                                                                            #
# Unless required by applicable law or agreed to in writing, software        #
# distributed under the License is distributed on an "AS IS" BASIS,          #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
# See the License for the specific language governing permissions and        #
# limitations under the License.                                             #
#--------------------------------------------------------------------------- #

if [ -f /mnt/context.sh ]
then
  . /mnt/context.sh
fi

##############################################################
#Please set all variables accordingly:
ONE_USER=
ONE_PASSWD=
#paste the content of your ~/.ssh/id_rsa.pub between quotes
PUBKEY=""
#use the xtreemfs url where the latest BaTS jars reside (e.g. 10.0.0.1/TaskFarm)
FRESH_BATS= 

echo $HOSTNAME > /etc/hostname
hostname $HOSTNAME
sed -i "/127.0.1.1/s/ubuntu/$HOSTNAME/" /etc/hosts
echo "10.0.0.200  n00.cumulus.zib.de n00" >> /etc/hosts
echo "10.0.0.201  n01.cumulus.zib.de n01" >> /etc/hosts 
echo "10.0.0.202  n02.cumulus.zib.de n02" >> /etc/hosts
echo "10.0.0.203  n03.cumulus.zib.de n03" >> /etc/hosts
echo "10.0.0.204  n04.cumulus.zib.de n04" >> /etc/hosts
echo "10.0.0.205  n05.cumulus.zib.de n05" >> /etc/hosts
echo "10.0.0.206  n06.cumulus.zib.de n06" >> /etc/hosts
echo "10.0.0.207  n07.cumulus.zib.de n07" >> /etc/hosts
echo "10.0.0.208  n08.cumulus.zib.de n08" >> /etc/hosts
echo "10.0.0.209  n09.cumulus.zib.de n09" >> /etc/hosts
echo "10.0.0.210  n10.cumulus.zib.de n10" >> /etc/hosts
echo "10.0.0.211  n11.cumulus.zib.de n11" >> /etc/hosts
echo "10.0.0.212  n12.cumulus.zib.de n12" >> /etc/hosts
echo "10.0.0.213  n13.cumulus.zib.de n13" >> /etc/hosts
echo "10.0.0.214  n14.cumulus.zib.de n14" >> /etc/hosts
echo "10.0.0.215  n15.cumulus.zib.de n15" >> /etc/hosts
echo "10.0.0.216  n16.cumulus.zib.de n16" >> /etc/hosts
echo "10.0.0.217  n17.cumulus.zib.de n17" >> /etc/hosts
echo "10.0.0.218  n18.cumulus.zib.de n18" >> /etc/hosts
echo "10.0.0.219  n19.cumulus.zib.de n19" >> /etc/hosts
echo "10.0.0.220  n20.cumulus.zib.de n20" >> /etc/hosts
echo "10.0.0.221  n21.cumulus.zib.de n21" >> /etc/hosts
echo "10.0.0.222  n22.cumulus.zib.de n22" >> /etc/hosts
echo "10.0.0.223  n23.cumulus.zib.de n23" >> /etc/hosts
echo "10.0.0.224  n24.cumulus.zib.de n24" >> /etc/hosts
echo "10.0.0.225  n25.cumulus.zib.de n25" >> /etc/hosts
echo "10.0.0.226  n26.cumulus.zib.de n26" >> /etc/hosts
echo "10.0.0.227  n27.cumulus.zib.de n27" >> /etc/hosts
echo "10.0.0.228  n28.cumulus.zib.de n28" >> /etc/hosts
echo "10.0.0.229  n29.cumulus.zib.de n29" >> /etc/hosts
echo "10.0.0.230  n30.cumulus.zib.de n30" >> /etc/hosts
echo "10.0.0.231  n31.cumulus.zib.de n31" >> /etc/hosts

##############################################################

export ONE_USER
export ONE_PASSWD
export ONE_AUTH_CONTENT=$ONE_USER:$ONE_PASSWD


# no files passed in the contextualization, so no id_rsa.pub
# set here your own key to enable access to the vm

export PUBKEY
if [ -n "$PUBKEY" ]; then
	mkdir -p /root/.ssh
	echo $PUBKEY >> /root/.ssh/authorized_keys
	chmod 600 /root/.ssh/authorized_keys
	chmod 700 /root/.ssh	
fi
##############################################################

if [ -n "$IP_PUBLIC" ]; then
	ifconfig eth0 $IP_PUBLIC
fi
 
if [ -n "$NETMASK" ]; then
	ifconfig eth0 netmask $NETMASK
fi

if [ -f /mnt/$ROOT_PUBKEY ]; then
	mkdir -p /root/.ssh
	cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
	#chmod -R 600 /root/.ssh/
	chmod 600 /root/.ssh/authorized_keys
	chmod 700 /root/.ssh
fi

if [ -n "$USERNAME" ]; then
	useradd -s /bin/bash -m $USERNAME
	if [ -f /mnt/$USER_PUBKEY ]; then
		mkdir -p /home/$USERNAME/.ssh/
		cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
		chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
		chmod 600 /home/$USERNAME/.ssh/authorized_keys
	fi
fi

# added:
if [ -n "$IP_GATEWAY" ]; then
        # Change gateway from default; note eth0 is already active
        (           
            ip route add default via $IP_GATEWAY
            echo Now set IP_GATEWAY to $IP_GATEWAY
        ) >> /var/log/context.log 2>&1

fi

# added:
if [ -n "$NAMESERVER" ]; then
        echo "Setting DNS server to $NAMESERVER" >>/var/log/context.log
        echo "nameserver $NAMESERVER" >/etc/resolv.conf
fi

#=============================================================================
# Specifics for the Bats manager
#-----------------------------------------------------------------------------

export BATS_HOME=/home/opennebula/BoT
export BATS_HOME_LIB=$BATS_HOME/lib
export IPL_HOME=$BATS_HOME/ibis

export FRESH_BATS

mkdir $BATS_HOME_LIB
#----------------------------------------------------------------------------

#============================================================================
# The worker's init.sh. Export the filename so that the JVM knows where it is.
# this is the content of a workers init.sh
# with escaped variables

export WORKER_INIT_SH=$BATS_HOME/init.sh

cat > $WORKER_INIT_SH <<EOF
#!bin/bash

# THIS FILE IS THE INIT.SH FOR THE WORKERS. IT WILL BE CONVERTED TO A HEX STRING AND PASSED TO THE WORKERS.

if [ -f /mnt/context.sh ]
then
{'fraction_non_alphanumeric': 0.22548218372016998, 'fraction_numerical': 0.06521739130434782, 'mean_word_length': 2.154679040989946, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 159, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 68, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4711031', 'n_tokens_mistral': 4851, 'n_tokens_neox': 4215, 'n_words': 1099}