📄 rc.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 + -