-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcn-setup.sh
67 lines (61 loc) · 2.87 KB
/
cn-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
echo ##################################################
echo ############# Compute Node Setup #################
echo ##################################################
IPPRE=$1
USER=$2
GANG_HOST=$3
HOST=`hostname`
if grep -q $IPPRE /etc/fstab; then FLAG=MOUNTED; else FLAG=NOTMOUNTED; fi
if [ $FLAG = NOTMOUNTED ] ; then
echo $FLAG
echo installing NFS and mounting
pkill -9 yum
sleep 10
yum install -y -q nfs-utils pdsh
mkdir -p /mnt/nfsshare
mkdir -p /mnt/resource/scratch
chmod 777 /mnt/nfsshare
systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable nfs-lock
systemctl enable nfs-idmap
systemctl start rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap
localip=`hostname -i | cut --delimiter='.' -f -3`
## echo "$IPPRE:/mnt/nfsshare /mnt/nfsshare nfs defaults 0 0" | tee -a /etc/fstab
echo "$IPPRE:/mnt/resource/scratch /mnt/resource/scratch nfs defaults 0 0" | tee -a /etc/fstab
mount -a
df | grep $IPPRE
impi_version=`ls /opt/intel/impi`
source /opt/intel/impi/${impi_version}/bin64/mpivars.sh
ln -s /opt/intel/impi/${impi_version}/intel64/bin/ /opt/intel/impi/${impi_version}/bin
ln -s /opt/intel/impi/${impi_version}/lib64/ /opt/intel/impi/${impi_version}/lib
#echo "@reboot mkdir -p /mnt/resource/scratch && chown ${USER}:${USER} /mnt/resource/scratch && mount -t nfs $IPPRE:/mnt/resource/scratch /mnt/resource/scratch" | tee -a /var/spool/cron/root
#echo "@reboot chown ${USER}:${USER} /mnt/resource/scratch" | tee -a /var/spool/cron/root
#echo "@reboot $IPPRE:/mnt/resource/scratch /mnt/resource/scratch" | tee -a /var/spool/cron/root
# fix mount problem
echo "@reboot ~/bootcron.sh" | tee -a /var/spool/cron/root
echo "*/15 * * * * ~/bootcron.sh" | tee -a /var/spool/cron/root
# create script
echo "#!/bin/bash" | tee -a ~/bootcron.sh
echo "if [ -d /mnt/resource/scratch ]; then" | tee -a ~/bootcron.sh
echo "echo '[bootcron] Already mounted'" | tee -a ~/bootcron.sh
echo "else" | tee -a ~/bootcron.sh
echo "mkdir -p /mnt/resource/scratch" | tee -a ~/bootcron.sh
echo "chown ${USER}:${USER} /mnt/resource/scratch" | tee -a ~/bootcron.sh
echo "mount -t nfs $IPPRE:/mnt/resource/scratch /mnt/resource/scratch" | tee -a ~/bootcron.sh
echo "fi" | tee -a ~/bootcron.sh
chmod +x ~/bootcron.sh
ln -s /root/bootcron.sh /home/${USER}/bootcron.sh
echo export I_MPI_FABRICS=shm:dapl >> /home/$USER/.bashrc
echo export I_MPI_DAPL_PROVIDER=ofa-v2-ib0 >> /home/$USER/.bashrc
echo export I_MPI_ROOT=/opt/intel/impi/${impi_version} >> /home/$USER/.bashrc
echo export PATH=/opt/intel/impi/${impi_version}/bin64:$PATH >> /home/$USER/.bashrc
echo export I_MPI_DYNAMIC_CONNECTION=0 >> /home/$USER/.bashrc
else
echo already mounted
df | grep $IPPRE
fi