workshops/eda-workshop-lsf/templates/03-login-server-dcv.yaml [240:330]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                echo "${!user_name}:${!user_pass}" | chpasswd
                echo "Created user ${!user_name}"

              }

              function cr_post_reboot {

                if [[ ! -d /opt/dcv-install ]]; then
                  mkdir /opt/dcv-install
                fi

              cat << EOF > /opt/dcv-install/post_reboot.sh
              #!/usr/bin/env bash

              function stop_disable_svc() {
                systemctl stop \$1
                systemctl disable \$1
              }

              stop_disable_svc firewalld
              stop_disable_svc libvirtd
              systemctl isolate multi-user.target
              systemctl isolate graphical.target
              DISPLAY=:0 XAUTHORITY=\$(ps aux | grep "X.*\\-auth" | grep -v grep | awk -F"-auth " '{print \$2}' | awk '{print \$1}') xhost | grep "SI:localuser:dcv$"
              dcv create-session --type=virtual --owner ${!user_name} --user ${!user_name} virt
              dcv list-sessions

              my_wait_handle="${!my_wait_handle}"

              if [[ ! -f /tmp/wait-handle-sent ]]; then
                exit 0
              else
                wait_handle_status=\$(cat /tmp/wait-handle-sent)
                if [[ \${!wait_handle_status} == "true" ]]; then
                  rm /tmp/wait-handle-sent
                  exit 0
                elif [[ \${!wait_handle_status} == "false" && \${!my_wait_handle} != "" ]] ; then
                  echo "Sending success to wait handle"
                  curl -X PUT -H 'Content-Type:' --data-binary '{ "Status" : "SUCCESS",  "Reason" : "instance launched",  "UniqueId" : "inst001",  "Data" : "instance launched."}' "\${!my_wait_handle}"
                  echo "true" > /tmp/wait-handle-sent
                fi
              fi

              EOF

              chmod 744 /opt/dcv-install/post_reboot.sh

              }

              function cr_service {

              cat << EOF > /etc/systemd/system/post-reboot.service
              [Unit]
              Description=Post reboot service

              [Service]
              ExecStart=/opt/dcv-install/post_reboot.sh

              [Install]
              WantedBy=multi-user.target
              EOF

              chmod 664 /etc/systemd/system/post-reboot.service
              systemctl daemon-reload
              systemctl enable post-reboot.service

              }

              function stop_disable_svc() {
                systemctl stop $1
                systemctl disable $1
              }

              function main {

              install_prereqs
              install_dcv
              add_user
              cr_post_reboot
              cr_service

              systemctl enable dcvserver
              echo "false" > /tmp/wait-handle-sent
              stop_disable_svc firewalld
              stop_disable_svc libvirtd
              echo "*** END LOGIN SERVER BOOTSTRAP. REBOOTING... ***"
              reboot

              }

              main
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



workshops/eda-workshop-lsf/templates/eda-lsf-simple-workshop.yaml [624:715]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                echo "${!user_name}:${!user_pass}" | chpasswd
                echo "Created user ${!user_name}"

              }

              function cr_post_reboot {

                if [[ ! -d /opt/dcv-install ]]; then
                  mkdir /opt/dcv-install
                fi

              cat << EOF > /opt/dcv-install/post_reboot.sh
              #!/usr/bin/env bash

              function stop_disable_svc() {
                systemctl stop \$1
                systemctl disable \$1
              }

              stop_disable_svc firewalld
              stop_disable_svc libvirtd
              systemctl isolate multi-user.target
              systemctl isolate graphical.target
              DISPLAY=:0 XAUTHORITY=\$(ps aux | grep "X.*\\-auth" | grep -v grep | awk -F"-auth " '{print \$2}' | awk '{print \$1}') xhost | grep "SI:localuser:dcv$"
              dcv create-session --type=virtual --owner ${!user_name} --user ${!user_name} virt
              dcv list-sessions

              my_wait_handle="${!my_wait_handle}"

              if [[ ! -f /tmp/wait-handle-sent ]]; then
                exit 0
              else
                wait_handle_status=\$(cat /tmp/wait-handle-sent)
                if [[ \${!wait_handle_status} == "true" ]]; then
                  rm /tmp/wait-handle-sent
                  exit 0
                elif [[ \${!wait_handle_status} == "false" && \${!my_wait_handle} != "" ]] ; then
                  echo "Sending success to wait handle"
                  curl -X PUT -H 'Content-Type:' --data-binary '{ "Status" : "SUCCESS",  "Reason" : "instance launched",  "UniqueId" : "inst001",  "Data" : "instance launched."}' "\${!my_wait_handle}"
                  echo "true" > /tmp/wait-handle-sent
                fi
              fi

              EOF

              chmod 744 /opt/dcv-install/post_reboot.sh

              }

              function cr_service {

              cat << EOF > /etc/systemd/system/post-reboot.service
              [Unit]
              Description=Post reboot service

              [Service]
              ExecStart=/opt/dcv-install/post_reboot.sh

              [Install]
              WantedBy=multi-user.target
              EOF

              chmod 664 /etc/systemd/system/post-reboot.service
              systemctl daemon-reload
              systemctl enable post-reboot.service

              }

              function stop_disable_svc() {
                systemctl stop $1
                systemctl disable $1
              }


              function main {

              install_prereqs
              install_dcv
              add_user
              cr_post_reboot
              cr_service

              systemctl enable dcvserver
              echo "false" > /tmp/wait-handle-sent
              stop_disable_svc firewalld
              stop_disable_svc libvirtd
              echo "*** END LOGIN SERVER BOOTSTRAP. REBOOTING... ***"
              reboot

              }

              main
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



