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

📄 rc.opendhcpd

📁 Linux下的DHCP服务器程序源代码, 实现DHCP Server端协议
💻 OPENDHCPD
字号:
#!/bin/bash#Start/stop opendhcpd#Originally Contributed by sharne, slightly modified.################################################################################################################################################################################################################ This file daemonizes the opendhcpd to start automatically when system starts#### Please do the following (todo)####  1) Add the following lines to /etc/rc.d/rc.inet2, at the end. Alternatively You can also add##     these lines to rc.local or inittab files.####	# Start the opendhcpd daemon:##	if [ -x /etc/rc.d/rc.opendhcpd ]; then##	  /etc/rc.d/rc.opendhcpd start##	fi####  2) Modify the opendhcpd_start() function in line 29 below, setting the file locations.####  3) Change the permissions of this file rc.opendhcpd to 755 after moving it to /etc/rc.d################################################################################################################################################################################################################pidnum=$( ps -eaf | grep -v grep | grep -v rc.opendhcpd | grep opendhcpd | awk '{ printf("%s %s\n",$3,$2) }' | sort | head -1 | awk '{ print $2 }' )# Start opendhcpd:opendhcpd_start() {##### Modify line below for location of executive and other files #####/opt/opendhcp/opendhcpd -i /opt/opendhcp/opendhcpd.ini -l /opt/opendhcp/opendhcpd.log -s /opt/opendhcp/opendhcpd.stateecho "Server opendhcpd started"}# Stop opendhcpd:opendhcpd_stop() {kill $pidnum  while [ true ]dopidnum=$( ps -eaf | grep -v grep | grep -v rc.opendhcpd | grep opendhcpd | awk '{ print $2 }' | head -1 )if [ -z "$pidnum" ]thenbreakfidoneecho "Server opendhcpd stopped"}case "$1" in'start')if [ -z "$pidnum" ]thenopendhcpd_startRETVAL=0elseecho "Server is already running - Try restart"RETVAL=1fi;;'stop')if [ -z "$pidnum" ]thenecho "Server is not running"RETVAL=1elseopendhcpd_stopRETVAL=0fi;;'restart')if [ -z "$pidnum" ]thenecho "Server is not running"opendhcpd_startelseopendhcpd_stopopendhcpd_startfiRETVAL=0;;'status')if [ -z "$pidnum" ]thenecho "Server is not running"RETVAL=1elseecho "Server is running - Pid : $pidnum"RETVAL=0fi;;*)echo "Usage $0 { start | stop | restart | status }"RETVAL=1;;esacexit $RETVAL# Enjoy!

⌨️ 快捷键说明

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