2021年9月1日星期三

vlmcsd kms 在pi-star上的安装

项目地址:https://github.com/Wind4/vlmcsd

1.使用git下载源码并编译
cd /tmp
git clone https://github.com/Wind4/vlmcsd
cd vlmcsd
make

2.编译完成,copy文件与手册
编译完成后,在bin目录下生成两个文件,vlmcs和vlmcsd,vlmcs用于测试kms服务器,vlmcsd用于开启kms服务。

执行rpi-rw,将pi-star磁盘置于可写模式
cp vlmcs* /usr/local/sbin
将man下的手册分别copy至/usr/share/man目录

3.修改pistar-firewall
pi-star使用的是iptables,我没有仔细看pi-star机制下的iptables,不能使用常规的方法修改防火墙,我修改的是/usr/local/sbin/pistar-firewall,可以生效

在# Allow Outbound System Ports (for updates mostly)后新增一行放行出站端口
iptables -A OUTPUT -p tcp --dport 1688 -j ACCEPT # KMS

在# Allow Inbound Services后新增一行放行入站端口
iptables -A INPUT -p tcp --dport 1688 -j ACCEPT # KMS

保存后,运行pistar-firewall,防火墙规即生效

4.在/etc/init.d/编写启动脚本vlmcsd,这不是我写的,摘自https://mananapr.github.io/microsoft_activation.html
代码如下:

#!/bin/sh ### BEGIN INIT INFO # Provides: vlmcsd # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: KMS server ### END INIT INFO # Do NOT "set -e" if [ `id -u` != 0 ]; then echo "Must be root to run this" exit 1 fi PATH=/usr/local/sbin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin DESC="Microsoft KMS daemon" NAME=vlmcsd DAEMON=/usr/local/sbin/$NAME PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME LOGFILE=syslog PORT=1688 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 DAEMON_ARGS="-l $LOGFILE -p $PIDFILE -P $PORT" # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present # and status_of_proc is working. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { status="0" pidofproc -p $PIDFILE $DAEMON >/dev/null || status="$?" if [ $status -eq 0 ]; then log_action_msg "already running" return 3 fi $DAEMON $DAEMON_ARGS $EXTRA_ARGS return $? } # # Function that stops the daemon/service # do_stop() { if [ ! -f $PIDFILE ]; then log_action_msg "service not running" return 4 fi kill `cat $PIDFILE` return $? } case "$1" in start) log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0) log_end_msg 0 ;; *) log_end_msg 1 ;; esac ;; stop) log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0) log_end_msg 0 ;; *) log_end_msg 1 ;; esac ;; restart|force-reload|reload) log_daemon_msg "Restarting $DESC" "$NAME" do_stop sleep 1 do_start case "$?" in 0) log_end_msg 0 ;; *) log_end_msg 1 ;; # Failed to start esac ;; status) status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|reload|restart|force-reload}" >&2 exit 3 ;; esac

保存后,修改vlmcsd脚本权限可执行
chmod +x /etc/init.d/vlmcsd

5.将vlmcsd加入系统启动进程
使用下列命令,将vlmcsd加入系统进程

systemctl enable vlmcsd
重启后,系统就会自动启动vlmcsd.

6.使用windows或office进行测试