<commit_before>#!/bin/sh

SSH_PUBLIC_KEY='insert_your_ssh_public_key_here'

function add_ssh_public_key() {
    cd
    mkdir -p .ssh
    chmod 700 .ssh
    echo "$SSH_PUBLIC_KEY" >> .ssh/authorized_keys
    chmod 600 .ssh/authorized_keys
}

function get_network_info() {
    echo '* settings for cloud agent'
    read -p ' hostname   (ex:cloudstack)   : ' HOSTNAME
    read -p ' ip address (ex:192.168.1.2)  : ' IPADDR
    read -p ' netmask    (ex:255.255.255.0): ' NETMASK
    read -p ' gateway    (ex:192.168.1.1)  : ' GATEWAY
    read -p ' dns1       (ex:192.168.1.1)  : ' DNS1
    read -p ' dns2       (ex:8.8.4.4)      : ' DNS2
}

function get_nfs_info() {
    echo '* settings for nfs server'
    read -p ' NFS Server IP: ' NFS_SERVER_IP
    read -p ' Primary mount point   (ex:/export/primary)  : ' NFS_SERVER_PRIMARY
    read -p ' Secondary mount point (ex:/export/secondary): ' NFS_SERVER_SECONDARY
}

function get_nfs_network() {
    echo '* settings for nfs server'
    read -p ' accept access from (ex:192.168.1.0/24): ' NETWORK
}

function install_common() {
    yum update -y
    sed -i -e 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
    setenforce permissive
    echo "[cloudstack]
name=cloudstack
baseurl=http://cloudstack.apt-get.eu/rhel/4.5/
enabled=1
gpgcheck=0" > /etc/yum.repos.d/CloudStack.repo
    sed -i -e "s/localhost/$HOSTNAME localhost/" /etc/hosts
    yum install ntp wget -y
    service ntpd start
    chkconfig ntpd on
    wget http://download.cloud.com.s3.amazonaws.com/tools/vhd-util
    mkdir -p /usr/share/cloudstack-common/common/scripts/vm/hypervisor/xenserver
    mv vhd-util /usr/share/cloudstack-common/common/scripts/vm/hypervisor/xenserver
}

function install_management() {
    yum install cloudstack-management mysql-server expect -y

    head -7 /etc/my.cnf > /tmp/before
    tail -n +7 /etc/my.cnf > /tmp/after
    cat /tmp/before > /etc/my.cnf
    echo "innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'" >> /etc/my.cnf
    cat /tmp/after >> /etc/my.cnf
    rm -rf /tmp/before /tmp/after

    service mysqld start
    chkconfig mysqld on

    expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none): \"
send \"\n\"
expect \"Set root password?\"
send \"Y\n\"
expect \"New password: \"
send \"password\n\"
expect \"Re-enter new password: \"
send \"password\n\"<commit_msg>update cloudstack<commit_after>#!/bin/sh

SSH_PUBLIC_KEY='insert_your_ssh_public_key_here'

function add_ssh_public_key() {
    cd
    mkdir -p .ssh
    chmod 700 .ssh
    echo "$SSH_PUBLIC_KEY" >> .ssh/authorized_keys
    chmod 600 .ssh/authorized_keys
}

function get_network_info() {
    echo '* settings for cloud agent'
    #read -p ' hostname   (ex:cloudstack)   : ' HOSTNAME
    #read -p ' ip address (ex:192.168.1.2)  : ' IPADDR
    #read -p ' netmask    (ex:255.255.255.0): ' NETMASK
    #read -p ' gateway    (ex:192.168.1.1)  : ' GATEWAY
    #read -p ' dns1       (ex:192.168.1.1)  : ' DNS1
    #read -p ' dns2       (ex:8.8.4.4)      : ' DNS2
    HOSTANME="oudswiss packer-templates"
    GATEWAY="$(route | grep default | awk '{print $2}')"
    IPADRR="$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}')"
    NETMASK="255.255.255.0"
    DNS1="8.8.8.8"
    DNS2="8.8.8.8"
    




}

function get_nfs_info() {
    echo '* settings for nfs server'
    #read -p ' NFS Server IP: ' NFS_SERVER_IP
    #read -p ' Primary mount point   (ex:/export/primary)  : ' NFS_SERVER_PRIMARY
    #read -p ' Secondary mount point (ex:/export/secondary): ' NFS_SERVER_SECONDARY
    NFS_SERVER_PRIMARY=/export/primary
    NFS_SERVER_SECONDARY=/export/primary
    NFS_SERVER_IP="$(IPADRR)"

}

function get_nfs_network() {
    echo '* settings for nfs server'
    #read -p ' accept access from (ex:192.168.1.0/24): ' NETWORK
    NETWORK="0.0.0.0/0"
}

function install_common() {
    yum update -y
    sed -i -e 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
    setenforce permissive
    echo "[cloudstack]
name=cloudstack
baseurl=http://http://packages.shapeblue.com/cloudstack/upstream/centos/4.8
enabled=1
gpgcheck=0" > /etc/yum.repos.d/CloudStack.repo
    sed -i -e "s/localhost/$HOSTNAME localhost/" /etc/hosts
    yum install ntp wget -y
    service ntpd start
    chkconfig ntpd on
    wget http://download.cloud.com.s3.amazonaws.com/tools/vhd-util
    #mkdir -p /usr/share/cloudstack-common/common/scripts/vm/hypervisor/xenserver
    #mv vhd-util /usr/share/cloudstack-common/common/scripts/vm/hypervisor/xenserver
}

function install_management() {
    yum install cloudstack-management mysql-server expect -y

    head -7 /etc/my.cnf > /tmp/before
    tail -n +7 /etc/my.cnf > /tmp/after
    cat /tmp/before > /etc/my.cnf
    echo "innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'" >> /etc/my.cnf
    cat /tmp/after >> /etc/my.cnf
    rm -rf /tmp/before /tmp/after

    service mysqld start
    chkconfig mysqld on

    expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none): \"
send \"\n\"
expect \"Set root password?\"
send \"Y\n\"
expect \"New password: \"
send \"password\n\"
expect \"Re-enter new password: \"
send \"password\n\"
{'fraction_non_alphanumeric': 0.1364060459040866, 'fraction_numerical': 0.03302855010263109, 'mean_word_length': 2.938280675973549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 16, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3306930', 'n_tokens_mistral': 2160, 'n_tokens_neox': 2003, 'n_words': 458}