基于动态IP的WWW服务器

由 sschenri 在 04-09-2003 23:52 发表:

基于动态IP的WWW服务器

基于动态ip的服务器同样可以开设www服务接受客户端的访问,这可以通过以下的脚本来实现.请先建立PPP连接,配置好Httpd,测试它可以工作.

建立如下的脚本程序:

  • web_up: 上载网页的脚本.

  • web_down: 断开连接的脚本.

  • update_uppage: Perl 脚本创建包含更新IP地址的HTML页面.

  • up.HTML_source; 固定部分的页面.

  • down.HTML: 连接断开时使用的页面.

  • /etc/add, /etc/last_add: 存放IP地址的文件.

  • ip-down, ip-up: PPP连接断开和连接时拒绝上载的文件.

scripts web_up:

#!/bin/sh

#check new ip

new_ip()

{

if [ -f /etc/add ] ; then

if [ -f /etc/last-add ] ; then

if /usr/bin/diff /etc/add /etc/last_add >/dev/null ; then

exit 1

else

return 0

fi

else

return 0

fi

else

exit 1

fi

}

#check whether maroon is connected

try_connect()

{

if ping -c4 -13 128.101.118.21 2>& | grep "0 packets" > /dev/null

then

return 1

else

return 0

fi

fi

}

if try_connect

then

touch /var/run/maroon_connected

else

rm -f /var/run/maroon_connected

fi

FTP to update page

if [ -f /var/run/maroon_connected ] && new_ip

then

update_uppage is perl scripts, exit status is opposite of shell

if ( ! /home/honglu/public_HTML/update_uppage )

then

cd /home/honglu/public_HTML

if echo "put up.HTML /nlhome/m508/luxxx012/dynamic.HTML" | /usr/bin/FTP maroon

then

rm -f /etc/last_add

cp /etc/add /etc/last_add

exit 0

else

exit 1

fi

fi

else

exit 1

fi

scripts web_down

FTP to send down.HTML page

if [ -f /var/run/maroon_connected ]

then

cd /home/honglu/public_HTML

if echo "put down.HTML /nlhome/m508/luxxx012/dynamic.HTML" | /usr/bin/FTP maroon

then

rm -f /etc/last_add

else

exit 1

fi

else

exit 1

fi

执行如下脚本:

#!/bin/sh

if web_down

then

shutdown -h now

else

echo "can not web_down"

exit 1

fi

上面是我在图书馆借得<<组建linux服务器>> (马小光,邵谦谦)书上面的

我有些不懂,就抄上来,希望有大哥能揭示一下,或者看看可不可以这样做


由 dsj 在 04-11-2003 23:35 发表:


呵呵,现在才看到!


闲聊空间:

http://www.wonyen.net/bbs/mboard.asp


由 yaan 在 08-01-2003 14:36 发表:

呵呵。

看不懂啊。是不是不需要任何域名解晰软件吗?真可以办到吗?


由 hu-do 在 08-24-2003 20:28 发表:

**if ping -c4 -13 128.101.118.21 2 >& | grep "0 packets" > /dev/null **

这一段是干什么啊?


胡国钧


由 Glue 在 08-24-2003

Published At
Categories with 服务器类
Tagged with
comments powered by Disqus