3
TARGET_REPO=`config-get XCAT_REPO`
4
OVERRIDE_DOMAIN=`config-get XCAT_DOMAIN`
7
FQDN_NAME=`/bin/hostname --fqdn`
8
HOSTNAME=`/bin/hostname`
9
#Release name like trusty
10
RELEASE=`lsb_release -c | cut -d":" -f2 | tr -d '[[:space:]]'`
12
juju-log "FQDN: $FQDN_NAME"
13
juju-log "HOSTNAME: $HOSTNAME"
14
juju-log "OVERRIDE_DOMAIN: $OVERRIDE_DOMAIN"
15
juju-log "TARGET_REPO: $TARGET_REPO"
17
# Update the /etc/hosts file
18
# Argumenst: IP Address, FQDN, Host name
22
# If IP address already present, update the entry
23
if grep -q "$1" /etc/hosts
25
sed -i "s/$1.*/$1 $2 $3/" /etc/hosts
27
echo "$1 $2 $3" >> /etc/hosts
32
juju-log "Installing software."
33
status-set maintenance "Installing software."
35
# Host name and fully qualified name are same
36
# Or the user has updated/set a new domain name
37
if [ "$HOSTNAME" = "$FQDN_NAME" -o "$OVERRIDE_DOMAIN" != "" ]
39
#domain name is set correctly set.
40
if [ "$OVERRIDE_DOMAIN" ]
42
#user override for domain name
43
FQDN_NAME="$HOSTNAME.$OVERRIDE_DOMAIN"
44
IPADDR=`unit-get private-address`
45
update_host_file $IPADDR $FQDN_NAME $HOSTNAME
47
juju-log "Domain name not properly set in /etc/hosts. Exiting."
48
status-set blocked "Please set the XCAT_DOMAIN name."
52
IPADDR=`unit-get private-address`
53
update_host_file $IPADDR $FQDN_NAME $HOSTNAME
56
# Target repository from where the packages are to be downloaded is not set
57
if [ "$TARGET_REPO" = "" ]
59
juju-log "Target repository not set."
60
status-set blocked "Please set the XCAT_REPO value"
65
/bin/ping -c 1 $TARGET_REPO
68
juju-log "Target Repository ${TARGET_REPO} is unreachable. Please check name or availability. Exiting with error."
69
status-set blocked "Target Repository ${TARGET_REPO} is not reachable"
73
# Remove the previously installed software
74
if [ -f /etc/profile.d/xcat.sh ]
76
juju-log "Removing the installed software."
77
/usr/bin/apt-get -y remove software-properties-common xcat
80
# Get the architecture from the uname command.
81
ARCHITECTURE=`uname -m`
82
if [ "$ARCHITECTURE" = "ppc64le" ]; then
84
juju-log "Creating ppc64 repositories"
85
apt-add-repository "deb [arch=ppc64el] http://${TARGET_REPO}/projects/xcat/files/ubuntu/2.9/core-snap $RELEASE main"
86
apt-add-repository "deb [arch=ppc64el] http://${TARGET_REPO}/projects/xcat/files/ubuntu/xcat-dep $RELEASE main"
88
juju-log "Creating amd64 repositories"
89
apt-add-repository "deb [arch=amd64] http://${TARGET_REPO}/projects/xcat/files/ubuntu/2.9/core-snap $RELEASE main"
90
apt-add-repository "deb [arch=amd64] http://${TARGET_REPO}/projects/xcat/files/ubuntu/xcat-dep $RELEASE main"
93
wget -O - "http://$TARGET_REPO/projects/xcat/files/ubuntu/apt.key/download" | apt-key add -
95
/usr/bin/apt-get -y update
98
juju-log "Update call failed. Check if permissions or access to repository correct. Exiting."
103
/usr/bin/apt-get -y install software-properties-common xcat
106
juju-log "install software-properties-common or xcat call failed. Check if permissions or access to repository correct. Exiting."
110
/usr/bin/apt-get -y clean
112
source /etc/profile.d/xcat.sh
117
juju-log "xCAT is up"
118
status-set active "xCAT is up"
120
juju-log "Failed to get xCAT status."