#!/bin/bash
export http_port=7618
workdir=$(dirname $(readlink -f "$0"))
# 修改gpaas初始化脚本
sed -i "s/export http_port=\S*$/export http_port=${http_port}/g" $workdir/../scripts/initialize/gpaas/init.sh
# 放行防火墙端口
firewall-cmd --zone=public --add-port="$http_port"/tcp --permanent
firewall-cmd --reload
runtimedir=$workdir/../runtime
mkdir -p $runtimedir
chmod -R +x $workdir/../scripts/ && $workdir/../scripts/k8s/shell/install-kernel.sh && cd $runtimedir && $workdir/prestart
if [ $? -eq 0 ]; then
  echo '正在启动安装器...'
  cd $runtimedir && nohup $workdir/singularity >> /dev/null 2>&1 &
  sleep 10
  tail -12 $runtimedir/logs/default.log
else
  exit 1
fi