- This topic has 11개 답변, 3명 참여, and was last updated 10 years, 10 months 전에 by
딱털서어. This post has been viewed 31 times
-
게시글
-
네임서버 구축에 관련된 쉘 스크립트를 작성해 놓았는데, 이 스크립트 안에 데몬 띄우는 init 스크립트 내용이 들어갑니다.
cat > /etc/init.d/named <<EOT
init 스크립트 내용.....
EOT이렇게요. 그런데 init 스크립트 내용에 $2, $0와 같은 스트링이 들어가는데, 네임서버구축 스크립트를 실행하게 되면 이 부분이 처리될 때 스트링이 문자로 처리되어야 하는데, 해당 변수로 처리되거든요.
변수처리되지 않고 스트링 자체를 글자로 인식되게 끔 하려면 어떻게 처리해 주어야 하나요?
좀 더 자세한 이해를 위해서 해당 부분의 스크립트를 첨부합니다.
## INIT Scrypt
cat > /etc/init.d/named <<EOT
#!/bin/bash
#
# named This shell script takes care of starting and stopping
# named (BIND DNS server).
#
# chkconfig: 345 55 45
# description: named (BIND) is a Domain Name Server (DNS) \
# that is used to resolve host names to IP addresses.
# probe: false# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: $named
# Required-Start: $network
# Required-Stop: $network
# Should-Start: mysqld postgresql ldap
# Should-Stop: mysqld postgresql ldap
# Default-Start: 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop BIND
# Description: named (BIND) is a Domain Name Server (DNS).
### END INIT INFO# Source function library.
. /etc/rc.d/init.d/functions# Source networking configuration.
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/networkRETVAL=0
prog="named"# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0[ -f /etc/sysconfig/named ] && . /etc/sysconfig/named
[ -f /usr/sbin/named ] || exit 0
[ -f /var/named/etc/named.conf ] || exit 0
start() {
# Start daemons.
if [ -n "`/sbin/pidof named`" ]; then
gprintf "$prog: already running"
echo
return 1
fi
gprintf "Starting %s: " $prog# prepare the chroot if needed
[ -e /var/named/dev/null ] || mknod -m 0666 /var/named/dev/null c 1 3
[ -e /var/named/dev/random ] || mknod -m 0666 /var/named/dev/random c 1 8
[ -e /var/named/dev/urandom ] || mknod -m 0666 /var/named/dev/urandom c 1 8# better always copy localtime so it respects the system's timezone
install -m 0644 -o root -g root /etc/localtime /var/named/etc/[ -d /var/named/proc ] || mkdir -p /var/named/proc
if ! egrep -q '^/proc[[:space:]]+'/var/named'/proc' /proc/mounts; then
mount --bind /proc /var/named/proc -o ro >/dev/null 2>&1
fidaemon named -u named -t /var/named ${OPTIONS}
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/named
echo
return $RETVAL
}
stop() {
# Stop daemons.
gprintf "Stopping %s: " $prog
/usr/sbin/rndc -c /var/named/etc/rndc.conf stop "$1"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named || {
killproc named
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named
echo
return $RETVAL
}if egrep -q '^/proc[[:space:]]+'/var/named'/proc' /proc/mounts; then
umount /var/named/proc >/dev/null 2>&1
fisuccess
echo
return $RETVAL
}
status() {
/usr/sbin/rndc -c /var/named/etc/rndc.conf status
return $?
}
restart() {
stop
# wait a couple of seconds for the named to finish closing down
sleep 2
start
}
reload() {
/usr/sbin/rndc -c /var/named/etc/rndc.conf reload "$1" >/dev/null 2>&1 || /usr/bin/killall -HUP named
return $?
}# See how we were called.
case "$1" in
start)
start
;;
stop)
stop "$2"
;;
status)
status
;;
restart)
restart
;;
condrestart)
[ -f /var/lock/subsys/named ] && restart
;;
reload)
reload "$2"
;;
*)
gprintf "Usage: %s {start|stop|status|restart|condrestart|reload|probe}\n" $0
exit 1
esac
EOT리눅스를 더 가까이 - No1.Linux
- 답변은 로그인 후 가능합니다.