江苏省吴江市双板桥路3号兴源网络

0512-63028342

ly@wjxy.net.cn

linux 一键部署kms服务器脚本

源自git hub:dakkidaze/one-key-kms

https://github.com/Wind4/vlmcsd
centos 安装:

下载:vlmcsd

#! /bin/bash
#One-key-kms script by Dakkidaze <gioku@docomo.net.cn>
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear
start(){
yum install gcc git make -y
mkdir /usr/local/kms
cd /usr/local/kms
git clone https://github.com/Wind4/vlmcsd.git
cd vlmcsd
make
cd bin
mv vlmcsd /usr/local/kms/kms
cd /usr/local/kms/
rm -rf ./vlmcsd/
mv kms vlmcsd
clear
echo "Succeeded."
echo "The executable file lies in /usr/local/kms/"
echo "Remember that the server is not running right now."
echo "Please use -h to find possible usage for the executable or visit vlmcsd on Github."
echo "https://github.com/Wind4/vlmcsd"
echo "Addtionally, you may want to get a script to manage it."
echo "In this case, you may download a script at the one-key-kms repository."
echo "Thanks for your using!"
echo "Dakkidaze <gioku@docomo.net.cn>"
}
echo "This script will automatically download and compile KMS Server program for you."
echo "For more information, please visit https://github.com/Wind4/vlmcsd"
echo "Scrpit written by Dakkidaze <gioku@docomo.net.cn>"
echo "READY TO START?"
read -p "y/n:" choice
case $choice in
"y")
start
;;
"n")
exit 0;
;;
*)
echo "Please enter y or n!"
;;
esac

运行:


#!/bin/bash
# Author: Dakkidaze <gioku@docomo.net.cn
DAEMON=/usr/local/kms/vlmcsd
STAT=2
check_running(){
PID=`ps -ef | grep -v grep | grep -i "vlmcsd" | awk '{print $2}'`
if [ ! -z $PID ]; then
STAT=0
else
STAT=1
fi
}

do_restart() {
check_running
if [ $STAT = 0 ]; then
echo "Restarting KMS Server..."
kill $PID
elif [ $STAT = 1 ]; then
echo "Not started, starting now"
fi
$DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
check_running
if [ $STAT = 0 ]; then
echo "Succeeded."
elif [ $STAT = 1 ]; then
echo "Failed."
fi
}
do_stop() {
check_running
if [ $STAT = 0 ]; then
echo "Shutting down KMS Server..."
kill $PID
check_running
if [ $STAT = 0 ]; then
echo "Failed."
elif [ $STAT = 1 ]; then
echo "Succeeded."
fi
elif [ $STAT = 1 ]; then
echo "Not running, no kill."
fi
}
do_status() {
check_running
if [ $STAT = 0 ]; then
echo "KMS Server is running."
elif [ $STAT = 1 ]; then
echo "KMS Server is not running."
fi
}

do_start() {
check_running
if [ $STAT = 0 ]; then
echo "KMS Server is already running."
exit 0;
elif [ $STAT = 1 ]; then
echo "KMS Server is not running, starting now..."
$DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
fi
check_running
if [ $STAT = 0 ]; then
echo "Succeeded."
elif [ $STAT = 1 ]; then
echo "Failed."
fi
}

case "$1" in
start|stop|restart|status)
do_$1
;;
*)
echo "Usage: $0 start | stop | restart | status "
;;
esac

发表评论

邮箱地址不会被公开。 必填项已用*标注