Centos 2.6.32-179.9.1.el6.i686
您好,我的 noowbie 脚本有问题。这没用。当我尝试使用它时(例如,/etc/init.d/myscript start)什么也没发生。在此之前,我在其上制作 chkconfig --add myscript 和 chmod 777 。你能帮助我吗?
#!/bin/bash
#chkconfig: 2345 10 90
#description test
. /etc/init.d/functions
if [ ! -f /etc/sysconfig/network ]; then
exit 0
fi
. /etc/sysconfig/network
if [ -f /etc/sysconfig/network-scripts/ifcfg-eth1 ]; then
. /etc/sysconfig/network-scripts/ifcfg-eth1
fi
[ "${NETWORKING}"="no" ] && exit 0
[ -x -a /sbin/ifconfig ] || exit 1
case "$1" in
start)
echo "started"
ifconfig eth1 ${IPADDR} netmask ${NETMASK} up
echo 1 > /proc/sys/net/ipv4/ip_forward
;;
stop)
echo "stopping"
ifconfig eth1 ${IPADDR} netmask ${NETMASK} down
echo 0 > /proc/sys/net/ipv4/ip_forward
;;
status)
echo "showing status"
ifconfig
cat /proc/sys/net/ipv4/ip_forward
route -n
;;
esac
exit 0