#!/bin/bash

# 克隆仓库
git clone https://git.nia.ink/brnet/softether.git

# 检查克隆是否成功
if [ $? -ne 0 ]; then
    echo "克隆仓库失败，请检查网络或仓库地址。"
    exit 1
fi

# 移动 softether.service 到 /etc/systemd/system 目录
sudo mv ./softether/softether.service /etc/systemd/system/

# 检查移动是否成功
if [ $? -ne 0 ]; then
    echo "移动 softether.service 文件失败。"
    exit 1
fi

# 移动 softether 目录到根目录
sudo mv ./softether/ /

# 检查移动是否成功
if [ $? -ne 0 ]; then
    echo "移动 softether 目录到根目录失败。"
    exit 1
fi

# 启动 softether 服务
sudo systemctl start softether.service

# 检查服务是否启动成功
if [ $? -ne 0 ]; then
    echo "启动 softether 服务失败。"
    exit 1
fi

# 设置 softether 服务开机自启
sudo systemctl enable softether.service

# 检查设置是否成功
if [ $? -ne 0 ]; then
    echo "设置 softether 服务开机自启失败。"
    exit 1
fi

echo "SoftEther 服务已成功安装、启动并设置为开机自启。"
    