Newer
Older
nc-env / templates / template07-glusterfs-server / provision.sh
@pmarini pmarini on 13 Apr 2022 1 KB initial commit
#!/bin/bash

timedatectl set-timezone Europe/Madrid

start_time=`date`
  
echo "provisioning started: ${start_time}" 

MACHINE_HOSTNAME=glusterfs-server.localenv.com

SYSTEM_USER=usrv

NETWORK_INTERFACE=eth0

hostnamectl set-hostname ${MACHINE_HOSTNAME}

# Print some information about the container OS
hostnamectl

# Print some information about the container timezone
timedatectl

#####################################################################
## Get the IP address into an environment variable. This command outputs 
## an empty variable if the network interface name is not ${NETWORK_INTERFACE}
#####################################################################
ip_address=`ip -4 addr show ${NETWORK_INTERFACE} | grep -oP '(?<=inet\s)\d+(\.\d+){3}'`

adduser --disabled-password --gecos GECOS ${SYSTEM_USER}
 
usermod -p "`openssl passwd -1  -salt 5RPVAd ${SYSTEM_USER}`" ${SYSTEM_USER}
 
adduser ${SYSTEM_USER} sudo

apt install -y glusterfs-server

systemctl start glusterd

mkdir /srv/glusterfs-volume

gluster volume create vol01 ${MACHINE_HOSTNAME}:/srv/glusterfs-volume force

gluster volume start vol01

systemctl enable glusterd

systemctl status glusterd

echo "START - Cleanup"

rm -rf /vagrant/artifacts/*

echo "END - Cleanup"

end_time=`date`

echo "This container has IP (interface: ${NETWORK_INTERFACE}): ${ip_address}"

echo "If you add this IP to the hostname (${MACHINE_HOSTNAME}) in your hosts file:"

echo "	You can connect with user ${SYSTEM_USER} via ssh (password ${SYSTEM_USER}): ssh ${SYSTEM_USER}@${MACHINE_HOSTNAME}"

echo "provisioning started: ${start_time}" 
 
echo "provisioning ended: ${end_time}"