⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chspcfg.cgi

📁 一个用于嵌入式的Mini Web Server.大小只有200k. 非常适合用于机顶盒等.
💻 CGI
字号:
#!/bin/sh
modify_ip()
{
	_IP=$1
	#echo "Modify the host ip as : $_IP"
	_REALIP=`echo "$_IP"|sed 's/\(.*\):\(.*\)/\1/g'`
	#echo "RealIp = $_REALIP"
	_ETHCFG=`cat /etc/sysconfig/network-scripts/ifcfg-eth0`
	_OUTPUT=`echo "$_ETHCFG"|sed "s/IPADDR=\(.*\)/IPADDR=$_REALIP/g"`
	echo "$_OUTPUT" >	/etc/sysconfig/network-scripts/ifcfg-eth0
}
##############################################################################
# Change the SP config .
#
#
##############################################################################
echo "Content-type: text/plain"
echo ""
#echo ""
#POST = "POST"

##############################################################################
#get the origin config 
ORIGINCFG=`cat .SpConfig.txt`
#echo "Origin config is :$ORIGINCFG"



##############################################################################
#echo "REQUEST_METHOD = $REQUEST_METHOD"
#if ["$REQUEST_METHOD" = "POST"]
#then
#	echo "RequestMethod is POST"
#else
#	echo "RequestMethod is not POST and it is:$REQUEST_METHOD"
#fi
#
if [ "$CONTENT_LENGTH" != "" ] ; then
    if [ "$CONTENT_LENGTH" -ne 0 ] ; then
	echo
	QUERY_STRING=`dd bs=1 count=$CONTENT_LENGTH`
#echo "$QUERY_STRING"
	echo
    fi
fi
#echo "The Oringal QueryString:$QUERY_STRING"
#echo ""
STRING=`sed 's/\&/  /g'$QUERCY_STRING|sed 's/%3A/:/g'|sed 's/\(.*\)Submit=\(.*\)/\1/g'`
#echo "The Modified Query String:$STRING"

OUTPUT=`cat .SpConfig.txt`
#echo "output is : $OUTPUT"
#Modify the config line by line
for ITEM in $STRING
do
	#echo "$ITEM"	
	NAME=`echo $ITEM|sed "s/\(.*\)=\(.*\)/\1/g"`
	VALUE=`echo $ITEM|sed "s/\(.*\)=\(.*\)/\2/g "`
	#echo "Name=$NAME,Value=$VALUE"
	if [ $NAME = "sp_address" ]
	then 
		modify_ip $VALUE
	fi
	RESULT=`echo "$OUTPUT"|sed "s/$NAME=\(.*\)/$NAME=$VALUE/g" `
	#echo "Result = $RESULT"
	OUTPUT=$RESULT
done
echo "$OUTPUT" >.SpConfig.txt

#copy the current config file to replace the real config file 
cp -rf .SpConfig.txt /usr/local/g2sp/whspcfg
echo ""
echo "You have modified the host config successfully, please restart the host later "
echo "

"









⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -