Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/simpleping/install.sh

86 lines
2.0 KiB

10 months ago
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
ARCH=`uname -m`
sysName=`uname`
VERSION=$2
10 months ago
# 开启可以PING
10 months ago
# sysctl -w net.ipv4.ping_group_range="0 2147483647"
10 months ago
10 months ago
Install_App()
{
5 months ago
echo '正在安装脚本文件...'
10 months ago
mkdir -p $serverPath/source
mkdir -p $serverPath/source/simpleping
name=linux
if [ "$sysName" == "Darwin" ];then
name="darwin"
10 months ago
else
sysctl -w net.ipv4.ping_group_range="0 2147483647"
10 months ago
fi
10 months ago
if [ "$ARCH" == "x86_64" ];then
10 months ago
ARCH="amd64"
10 months ago
fi
10 months ago
FILE_TGZ=simpleping_${name}_${ARCH}.tar.gz
APP_DIR=$serverPath/source/simpleping
# https://github.com/midoks/simpleping/releases/download/1.0/simpleping_linux_amd64.tar.gz
if [ ! -f $APP_DIR/${FILE_TGZ} ];then
10 months ago
wget -O $APP_DIR/${FILE_TGZ} https://github.com/midoks/simpleping/releases/download/2.0/${FILE_TGZ}
10 months ago
fi
mkdir -p $serverPath/simpleping
cd $APP_DIR && tar -zxvf ${FILE_TGZ} -C $serverPath/simpleping
echo "${VERSION}" > $serverPath/simpleping/version.pl
cd ${rootPath} && python3 ${rootPath}/plugins/simpleping/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/simpleping/index.py initd_install
echo '安装SimplePing成功!'
}
Uninstall_App()
{
if [ -f /usr/lib/systemd/system/simpleping.service ];then
systemctl stop simpleping
systemctl disable simpleping
rm -rf /usr/lib/systemd/system/simpleping.service
systemctl daemon-reload
fi
if [ -f /lib/systemd/system/simpleping.service ];then
systemctl stop simpleping
systemctl disable simpleping
rm -rf /lib/systemd/system/simpleping.service
systemctl daemon-reload
fi
if [ -f $serverPath/simpleping/initd/simpleping ];then
$serverPath/simpleping/initd/simpleping stop
fi
if [ -d $serverPath/simpleping ];then
rm -rf $serverPath/simpleping
fi
echo "卸载SimplePing成功"
}
action=$1
if [ "${1}" == 'install' ];then
Install_App
else
Uninstall_App
fi