我使用旧的 Linux RedHat 4.1 发行版。在其他 GNU/Linux 发行版上,文件的位置可能不同,但原理是相同的 (Unix System V 惯例)。
创建文件 /etc/rc.d/init.d/plip
,内容如下
#!/bin/sh ############################## # file /etc/rc.d/init.d/plip # ############################## # See how we were called. case "$1" in start) # Start daemons. /bin/echo "Starting plip interface: " /bin/echo "Doing /sbin/ifconfig plip0 source pointopoint target netmask 255.255.255.255 up" /sbin/ifconfig plip0 source pointopoint target netmask 255.255.255.255 up /bin/echo "Doing /bin/ping -q -c 4 target" /bin/ping -q -c 4 target /bin/echo "Starting plip interface: done" ;; stop) # Stop daemons. /bin/echo "Shutting down plip interface:" /bin/echo "Doing /sbin/ifconfig plip0 source pointopoint target netmask 255.255.255.255 down" /sbin/ifconfig plip0 source pointopoint target netmask 255.255.255.255 down /bin/echo "Doing /sbin/modprobe -r plip " /sbin/modprobe -r plip /bin/echo "Shutting down plip interface: done" ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0 # === End of File ===
只有 ifconfig 行是绝对必要的。如果您不使用 kerneld
或新内核 2.2.x 的 kmod
功能,您可能需要添加一些 modprobe
命令。
在 rc*.d
目录中创建符号链接
$ cd /etc/rc.d/rc0.d/ $ ln -s ../init.d/plip K97plip $ cd /etc/rc.d/rc1.d/ $ ln -s ../init.d/plip K92plip $ cd /etc/rc.d/rc3.d/ $ ln -s ../init.d/plip S11plip $ cd /etc/rc.d/rc5.d/ $ ln -s ../init.d/plip S11plip
您可以选择其他数字。确保 'K' 后的两位数字大于停止依赖 plip 的服务的每个其他文件的数字。
确保 'S' 后的两位数字小于启动依赖 plip 的服务的每个其他文件的数字:nfs、nis、ftp、http 等。
更新 /etc/conf.modules
文件,选择正确的 IRQ 号码(我的号码是 7,您的可能不同)
# /etc/conf.modules ... alias parport_lowlevel parport_pc post-install parport_pc echo 7 > /proc/parport/0/irq ...
测试 plip shell
$ /etc/rc.d/init.d/plip Usage: /etc/rc.d/init.d/plip {start|stop} $ /etc/rc.d/init.d/plip stop Shutting down plip interface: Doing /sbin/ifconfig plip0 source pointopoint target netmask 255.255.255.255 down Doing /sbin/modprobe -r plip Shutting down plip interface: done $ /etc/rc.d/init.d/plip start Starting plip interface: Doing /sbin/ifconfig plip0 source pointopoint target netmask 255.255.255.255 up Doing /bin/ping -q -c 4 target PING target (192.168.0.1): 56 data bytes --- target ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 4.4/8.3/14.0 ms Starting plip interface: done
更新启动脚本是重启 Unix 系统以检查修改的好机会。请执行重启
$ init 6 # or "shutdown -r now" or "reboot"
更新文件 /etc/init.d/network
#! /bin/sh ####################### # /etc/init.d/network # ####################### ifconfig lo 127.0.0.1 route add -net 127.0.0.0 ifconfig plip1 192.168.0.1 pointopoint 192.168.0.2 netmask 255.255.255.255 up route add -host 192.168.0.2 dev plip1
就这些,因为 parport 功能直接在内核中。
更新启动脚本是重启 Unix 系统以检查修改的好机会。请执行重启
$ init 6