mirror of
https://github.com/tsingui/softcenter-1.git
synced 2024-11-14 09:55:17 +00:00
fix kms
This commit is contained in:
parent
b318263582
commit
a486ffc93b
91
kms/kms/scripts/kms.sh
Normal file
91
kms/kms/scripts/kms.sh
Normal file
@ -0,0 +1,91 @@
|
||||
#!/bin/sh
|
||||
# load path environment in dbus databse
|
||||
eval `dbus export kms`
|
||||
source /jffs/softcenter/scripts/base.sh
|
||||
CONFIG_FILE=/tmp/etc/dnsmasq.user/kms.conf
|
||||
FIREWALL_START=/jffs/scripts/firewall-start
|
||||
|
||||
start_kms(){
|
||||
/jffs/softcenter/bin/vlmcsd
|
||||
echo "srv-host=_vlmcs._tcp.lan,`uname -n`.lan,1688,0,100" > $CONFIG_FILE
|
||||
nvram set lan_domain=lan
|
||||
nvram commit
|
||||
service restart_dnsmasq
|
||||
# creating iptables rules to firewall-start
|
||||
mkdir -p /jffs/scripts
|
||||
if [ ! -f $FIREWALL_START ]; then
|
||||
cat > $FIREWALL_START <<-EOF
|
||||
#!/bin/sh
|
||||
EOF
|
||||
fi
|
||||
|
||||
# creat start_up file
|
||||
if [ ! -L "/jffs/softcenter/init.d/S97Kms.sh" ]; then
|
||||
ln -sf /jffs/softcenter/scripts/kms.sh /jffs/softcenter/init.d/S97Kms.sh
|
||||
fi
|
||||
}
|
||||
stop_kms(){
|
||||
# clear start up command line in firewall-start
|
||||
killall vlmcsd
|
||||
rm $CONFIG_FILE
|
||||
service restart_dnsmasq
|
||||
}
|
||||
|
||||
open_port(){
|
||||
ifopen=`iptables -S -t filter | grep INPUT | grep dport |grep 1688`
|
||||
if [ -z "$ifopen" ];then
|
||||
iptables -t filter -I INPUT -p tcp --dport 1688 -j ACCEPT
|
||||
fi
|
||||
|
||||
if [ ! -f $FIREWALL_START ]; then
|
||||
cat > $FIREWALL_START <<-EOF
|
||||
#!/bin/sh
|
||||
EOF
|
||||
fi
|
||||
|
||||
fire_rule=$(cat $FIREWALL_START | grep 1688)
|
||||
if [ -z "$fire_rule" ];then
|
||||
cat >> $FIREWALL_START <<-EOF
|
||||
iptables -t filter -I INPUT -p tcp --dport 1688 -j ACCEPT
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
close_port(){
|
||||
ifopen=`iptables -S -t filter | grep INPUT | grep dport |grep 1688`
|
||||
if [ ! -z "$ifopen" ];then
|
||||
iptables -t filter -D INPUT -p tcp --dport 1688 -j ACCEPT
|
||||
fi
|
||||
|
||||
fire_rule=$(cat $FIREWALL_START | grep 1688)
|
||||
if [ ! -z "$fire_rule" ];then
|
||||
sed -i '/1688/d' $FIREWALL_START >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
case $ACTION in
|
||||
start)
|
||||
if [ "$kms_enable" == "1" ]; then
|
||||
logger "[软件中心]: 启动KMS!"
|
||||
start_kms
|
||||
[ "$kms_wan_port" == "1" ] && open_port
|
||||
else
|
||||
logger "[软件中心]: KMS未设置开机启动,跳过!"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
close_port >/dev/null 2>&1
|
||||
stop_kms
|
||||
;;
|
||||
*)
|
||||
if [ "$kms_enable" == "1" ]; then
|
||||
close_port >/dev/null 2>&1
|
||||
stop_kms
|
||||
start_kms
|
||||
[ "$kms_wan_port" == "1" ] && open_port
|
||||
else
|
||||
close_port
|
||||
stop_kms
|
||||
fi
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user