/
v2.6 Example User-Data LSF
v2.6 Example User-Data LSF
Sample User Data Scripts
Example
#!/bin/bash
set -x
#typical aws-style hostname
NEW\
_HOSTNAME=$( echo ip-$( hostname -I |sed 's/\./-/g' |sed 's/ //g' ) )
hostname ${NEW_HOSTNAME}
##temporarily change the root password
#echo root:AAAAAA |chpasswd
##delete line 3 of /etc/hosts
#sed -i.orig '3d' /etc/hosts
#add an /etc/hosts self-identifying entry
echo >> /etc/hosts
echo -e "$( hostname -I )\t\t\t${NEW_HOSTNAME}" >> /etc/hosts
##aws-resource-connector based AMI has a local /opt/lsf/conf asset
## and needs configuration file updated to faciliate startup under
## the XIO Provider in Resource Connector:
## change resource designation
sed -i 's/awshost/xiohost/g' /opt/lsf/conf/lsf.conf
. /opt/lsf/conf/profile.lsf
lsadmin limstartup
lsadmin resstartup
badmin hstartup
#!/bin/bash
#set -ex
#set -e
export LOGGER="/tmp/log.user-data-$( basename ${0} ).$$"
# by dropping everything in to a subshell
(
echo STARTing $( date )
set -x
echo root:AAAAAAA |chpasswd
%EXPORT_USER_DATA%
IP=$( hostname -I |awk '{print $1}' )
NEW_HOSTNAME=ip-$( echo ${IP} |sed 's/\./-/g' )
hostnamectl set-hostname ${NEW_HOSTNAME} --static
#example cleanup of /etc/hosts artifacts
sed -i "/lsf-head/d; /ems/d" /etc/hosts
echo >> /etc/hosts
echo -e "172.28.130.158\t\thead" >> /etc/hosts
echo -e "${IP}\t\t${NEW_HOSTNAME}" >> /etc/hosts
#example fixing of the FS Table
sed -i s'/#head/head/g' /etc/fstab && systemctl daemon-reload && mount -a
sleep 2
#example copying of a remote LSF_TOP dir
#to avoid changing the cluster-wide configuration files
#when changing local copies instead is safer
mkdir -p /local/lsf/{log,conf}
rsync -avr /opt/lsf/conf/ /local/lsf/conf/
sed -i 's/opt/local/g' /local/lsf/conf/profile.lsf
sed -i 's/opt/local/g' /local/lsf/conf/lsf.conf
/opt/lsf/10.1/install/hostsetup --top=/opt/lsf --boot=y --dynamic
. /local/lsf/conf/profile.lsf
LSF_CONF_FILE=/local/lsf/conf/lsf.conf
if [[ -n ${rc_account} ]]; then
sed -i "s/\(LSF_LOCAL_RESOURCES=.*\)\"/\1 [resourcemap ${rc_account}*rc_account]\"/" $LSF_CONF_FILE
fi
if [[ -n ${template_id} ]]; then
sed -i "s/\(LSF_LOCAL_RESOURCES=.*\)\"/\1 [resourcemap ${template_id}*templateID]\"/" $LSF_CONF_FILE
fi
if [[ -n ${clustername} ]]; then
sed -i "s/\(LSF_LOCAL_RESOURCES=.*\)\"/\1 [resourcemap ${clustername}*clusterName]\"/" $LSF_CONF_FILE
fi
if [[ -n ${providerName} ]]; then
sed -i "s/\(LSF_LOCAL_RESOURCES=.*\)\"/\1 [resourcemap ${providerName}*providerName]\"/" $LSF_CONF_FILE
fi
#. /opt/lsf/conf/profile.lsf
systemctl daemon-reload
systemctl start lsfd &
echo ENDing $( date )
) |& tee -a ${LOGGER}
, multiple selections available, Use left or right arrow keys to navigate selected items