Browse Source

Upload files to 'site'

master
cs151003 4 years ago
parent
commit
0b034520a6
  1. 3
      site/get_hosts
  2. 73
      site/mpi_bootstrap
  3. 61
      site/startup.sh
  4. 10
      site/supervisor.conf

3
site/get_hosts

@ -0,0 +1,3 @@
#!/bin/sh
nslookup tasks.ondemand_mpi2_worker | grep Addr | cut -d':' -f2 | grep -v 127.0.

73
site/mpi_bootstrap

@ -0,0 +1,73 @@
#!/bin/sh
ROLE="undefined"
MPI_MASTER_SERVICE_NAME="mpi2_master"
MPI_WORKER_SERVICE_NAME="mpi2_worker"
#######################
# ARGUMENTS PARSER
while [ "$1" != "" ];
do
PARAM=$(echo "$1" | awk -F= '{print $1}')
VALUE=$(echo "$1" | awk -F= '{print $2}')
case $PARAM in
role)
[ "$VALUE" ] && ROLE=$VALUE
;;
mpi_master_service_name)
[ "$VALUE" ] && MPI_MASTER_SERVICE_NAME=$VALUE
;;
mpi_worker_service_name)
[ "$VALUE" ] && MPI_WORKER_SERVICE_NAME=$VALUE
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
exit 1
;;
esac
shift
done
cat > /etc/opt/service_names <<- EOF
MPI_MASTER_SERVICE_NAME=${MPI_MASTER_SERVICE_NAME}
MPI_WORKER_SERVICE_NAME=${MPI_WORKER_SERVICE_NAME}
EOF
case $ROLE in
"master")
# Auto update default host file in background and dumb all output
auto_update_hosts "${HYDRA_HOST_FILE}" > /dev/null 2>&1 &
/bin/bash /home/ubuntu/startup.sh
# Start ssh server
#/usr/sbin/sshd -D
;;
"worker")
# Start ssh server in background
/bin/bash /home/ubuntu/startup.sh &
/usr/sbin/sshd -D &
# Keep trying to connect to master node and stay there indefinitely so that master node can see
# the connected hosts that are ready for MPI work
while sleep 1
do
# shellcheck disable=SC2086
ssh -T -o "StrictHostKeyChecking no" \
-i "${USER_HOME}/.ssh/id_rsa" \
${USER}@${MPI_MASTER_SERVICE_NAME} \
"tail -f /dev/null"
done
;;
*)
echo 'role argument only accepts "master" or "worker"'
esac

61
site/startup.sh

@ -0,0 +1,61 @@
#!/bin/bash
#if [ ! -f $HOME/.vnc/passwd ] ; then
#
# if [ -z "$PASSWORD" ] ; then
# PASSWORD=`pwgen -c -n -1 12`
# echo -e "PASSWORD = $PASSWORD" > $HOME/password.txt
# fi
#
# echo "$USER:$PASSWORD" | chpasswd
#
# # Set up vncserver
# su $USER -c "mkdir $HOME/.vnc && echo '$PASSWORD' | vncpasswd -f > $HOME/.vnc/passwd && chmod 600 $HOME/.vnc/passwd && touch $HOME/.Xresources"
##vncpasswd -f <<<"write"$'\n'"view" >"$HOME/.vnc/passwd"
#vncpasswd -f >"$HOME/.vnc/passwd" <<EOF
#$PASSWORD
#$PASSWORDVIEW
#EOF
#
# chown -R $USER:$USER $HOME
#
# if [ ! -z "$SUDO" ]; then
# case "$SUDO" in
# [yY]|[yY][eE][sS])
# adduser $USER sudo
# esac
# fi
#
#else
#
# VNC_PID=`find $HOME/.vnc -name '*.pid'`
# if [ ! -z "$VNC_PID" ] ; then
# vncserver -kill :1
# rm -rf /tmp/.X1*
# fi
#
#fi
#
#if [ ! -z "$NGROK" ] ; then
# case "$NGROK" in
# [yY]|[yY][eE][sS])
# su ubuntu -c "$HOME/ngrok/ngrok http 6080 --log $HOME/ngrok/ngrok.log --log-format json" &
# sleep 5
# NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "http://.*?ngrok.io" -oh`
# su ubuntu -c "echo -e 'Ngrok URL = $NGROK_URL/vnc.html' > $HOME/ngrok/Ngrok_URL.txt"
# esac
#fi
#
#if [ "$SERVERROLE" == "master" ] ; then
#nslookup tasks.$SERVICENAME | grep Addr | cut -d':' -f2 | grep -v 127.0. > /tmp/hoststmp
#echo "" > /home/ubuntu/vnc.config.d/token.list
#c=1
#while read -r line;
# do
# echo "s$c: $line:5901" >> /home/ubuntu/vnc.config.d/token.list
# ((c++))
#done < /tmp/hoststmp
#fi
#
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf

10
site/supervisor.conf

@ -0,0 +1,10 @@
[program:apache2]
command=bash -c 'sleep 5 && /usr/sbin/apache2 -DFOREGROUND'
autorestart=true
[program:sshd]
#command=bash -c 'sleep 5 && /usr/sbin/sshd -D'
command=/usr/sbin/sshd -D
stdout_logfile=/var/log/sshd.log
autorestart=true
Loading…
Cancel
Save