#!/bin/bash

if [ ! -e /usr/bin/nmap ]; then
    apt update
    apt install nmap	
fi

ebox_path=/home/pi/ebox-java
rm -rf "${ebox_path}"
mkdir "${ebox_path}"
chmod 777 "${ebox_path}"
cd "${ebox_path}"

#获取启动脚本  服务脚本
curl -o ebox-java.sh "https://local.vrmaker.vip:1443/ebox-java/ebox-java-${1}.sh"
curl -O "https://local.vrmaker.vip:1443/ebox-java/ebox-java.service"

# 赋予执行权限
chmod 777 ebox-java.service
chmod 777 ebox-java.sh

rm -f /etc/systemd/system/ebox-java.service

cp ebox-java.service /etc/systemd/system/

# 安装服务
systemctl disable ebox-java.service
systemctl enable ebox-java.service

# java 命令软链接
if [ ! -e /usr/local/bin/java ];then
	ln -s "${JAVA_HOME}/bin/java" /usr/local/bin/
fi

