diff options
author | Willy Tarreau <w@1wt.eu> | 2006-07-16 15:09:46 +0200 |
---|---|---|
committer | Willy Tarreau <willy@wtap.(none)> | 2006-07-26 12:03:28 +0200 |
commit | faff05383ae2a99c326dc3994cfa449caa777a34 (patch) | |
tree | 551e5c0fce63724cab0a5ea85b1aa5501ef89b4d | |
parent | [RELEASE] init-scripts-0.3.8 (diff) | |
download | init-scripts-0.3.9.tar.gz |
[RELEASE] init-scripts-0.3.9v0.3.9
-rw-r--r-- | .flxfiles | 1 | ||||
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rwxr-xr-x | sbin/init.d/functions | 34 | ||||
-rwxr-xr-x | sbin/init.d/squid | 43 | ||||
-rwxr-xr-x | sbin/init.d/syslog-ng | 17 |
6 files changed, 88 insertions, 15 deletions
@@ -7,6 +7,7 @@ sbin/init.d/monitor sbin/init.d/mouse sbin/init.d/network sbin/init.d/ntp +sbin/init.d/squid sbin/init.d/sshd sbin/init.d/stat sbin/init.d/syslog-ng @@ -1,3 +1,8 @@ +2003/06/05 +- petits correctifs et quelques mises à jour +- plusieurs scripts comprennent dorénavant l'option nice +- script squid +- droits un peu moins restrictifs sur certains fichiers 2003/02/18 - création de /var/state (utilisé par dhcp par exemple) - correction de mouse : utilise /usr/sbin/gpm et redirige std* vers /dev/null @@ -0,0 +1,3 @@ +- prendre en compte l'option nice en global +- ajouter une option chroot globale si c'est possible +- ajouter les options 'chain' et 'need' en global diff --git a/sbin/init.d/functions b/sbin/init.d/functions index 8d46897..2d5954f 100755 --- a/sbin/init.d/functions +++ b/sbin/init.d/functions @@ -1,5 +1,13 @@ #!/bin/bash +# +# sbin/init.d/functions - Formilux init script - version 0.3.9 - 2003-06-05 +# +# Copyright (C) 2001-2003 Benoit Dolez & Willy Tarreau +# mailto: benoit@ant-computing.com,willy@ant-computing.com +# +# This program is licenced under GPLv2 ( http://www.gnu.org/licenses/gpl.txt ) + # not used ? ## DEBUG FILE # not used ? #DEBUG=/tmp/.flx.$PID.$RANDOM # not used ? #[ -e "$DEBUG" ] && rm -f $DEBUG && touch $DEBUG @@ -85,11 +93,12 @@ function logit { # returns the value for a given parameter in a config file. The value is both # echoed and set to the REPLY variable. +# The value is found this way : +# [ \t]*<parameter>[:= \t]*<value>[#]*<comment>$ + # usage: valueof CONFIGFILE PARAMETER function valueof { - REPLY=$( awk 'BEGIN { FS="[:= \\t]+"} {gsub("#.*", "", $0); \ - if (match($1, "^'$2'$")) { \ - gsub("^[:= \\t]*'$2'[:= \\t]+", "", $0); print $0 } }' $1 ) + REPLY=$(grep $'^[ \t]*'"$2"'[:= \t]*' $1|sed s,'^\('$'[ \t]*'"$2"$'[ \t:=]*''\)\([^#]*\).*$,\2,') echo $REPLY } @@ -836,6 +845,12 @@ function load_config { return $STATUS_RET } +# abort the process after displaying an error message. +die() { + echo $* >&2 + exit 1 +} + ################################## # ALWAYS LOADED WHEN SOURCED # ################################## @@ -851,15 +866,15 @@ while [ $# -gt 0 ] ; do case "$1" in -f|--file) # use this configuration file export CONFIG=$2 - shift 2 + shift 2 || die "Error: missing arg for --file, try --help." ;; --auto) # only start services which don't have a "no autostart" statement SVC_AUTO_START=1 - shift 1 + shift ;; --force) # force start or stop disregarding current status FORCE_START_STOP=1 - shift 1 + shift ;; --list_sections) # list all known sections MUST_LIST_SECTIONS=1 @@ -868,13 +883,14 @@ while [ $# -gt 0 ] ; do ;; --filter_option) # display only this option in list_options OPTION_FILTER=$2 - shift 2 + shift 2 || die "Error: missing arg for --filter_option, try --help." ;; - -o|--option) # force options : -o "opt=val,opt=val..." + -o|--option) # force options : -o "opt=val,opt=val..." FORCE_OPTIONS=$2 - shift 2 + shift 2 || die "Error: missing arg for --option, try --help." ;; -*) + echo "Common commands : start, stop, restart, status, check, list_options." echo "Global options :" grep $'^[ \t]*-[-a-z0-9_|]*)[ \t]*# ' $PPATH/functions | \ sed -e $'s/^\\([ \t]*\\)\\([^)]*\\)\\([ \t#)]*\\)\\(.*\\)/ \\2\t\t\\4/' diff --git a/sbin/init.d/squid b/sbin/init.d/squid new file mode 100755 index 0000000..cdb32f1 --- /dev/null +++ b/sbin/init.d/squid @@ -0,0 +1,43 @@ +#!/bin/bash + +. `dirname $0`/functions + +option config standard_option /etc/opt/squid/squid.conf +option httpport standard_option +option icpport standard_option +option usesyslog boolean_option 0 +option createswap boolean_option 0 +option catchsignals boolean_option 1 +option dnstest boolean_option 1 +option waitrebuild boolean_option 0 +option reuseaddr boolean_option 1 +option doublecheck boolean_option 0 +option vhostaccel boolean_option 0 +option bin reserved_option /opt/sbin/squid + +function fct_end_section { + local chroot + # try to find pidfile from the config file if unspecified + if [ -z "$pidfile" ]; then + valueof ${opt_config:-/etc/opt/squid/squid.conf} chroot >/dev/null 2>&1 + chroot=$REPLY + valueof ${opt_config:-/etc/opt/squid/squid.conf} pid_filename >/dev/null 2>&1 + pidfile=$chroot/${REPLY:-/var/log/squid.pid} + pidfile=${pidfile//\/\//\/} # clear double slashes + fi + + # let's add the options to the command line + cmdline="$cmdline ${opt_config:+-f $opt_config} ${opt_httpport:+-a $opt_httpport}" + cmdline="$cmdline ${opt_icpport:+-u $opt_icpport}" + [ "$opt_usesyslog" = "1" ] && cmdline="$cmdline -s" + [ "$opt_createswap" = "1" ] && cmdline="$cmdline -z" + [ "$opt_catchsignals" != "1" ] && cmdline="$cmdline -C" + [ "$opt_dnstest" != "1" ] && cmdline="$cmdline -D" + [ "$opt_reuseaddr" != "1" ] && cmdline="$cmdline -R" + [ "$opt_waitrebuild" = "1" ] && cmdline="$cmdline -F" + [ "$opt_doublecheck" = "1" ] && cmdline="$cmdline -S" + [ "$opt_vhostaccel" = "1" ] && cmdline="$cmdline -V" +} + +load_config + diff --git a/sbin/init.d/syslog-ng b/sbin/init.d/syslog-ng index d1824b9..bfe45d6 100755 --- a/sbin/init.d/syslog-ng +++ b/sbin/init.d/syslog-ng @@ -3,25 +3,30 @@ . `dirname $0`/functions option config standard_option /etc/syslog-ng/syslog-ng.conf +option nice standard_option 0 +option chain standard_option option pidfile reserved_option /var/run/syslog-ng.pid option bin reserved_option /sbin/syslog-ng -option cmdline reserved_option '$bin -f $opt_config -p $pidfile' +option cmdline reserved_option 'nice -n $opt_nice $bin -f $opt_config -p $pidfile' -# perform a forced synchronisation before starting the daemon +# we might want to start klogd right after syslog-ng function fct_post_start { - /sbin/init.d/klogd start >/dev/null 2>&1 || echo "Error starting klogd." + if [ -n "$opt_chain" ]; then + /sbin/init.d/$opt_chain start >/dev/null 2>&1 || echo "Error starting $opt_chain." + fi } -# perform a forced synchronisation before stopping the daemon function fct_pre_stop { - /sbin/init.d/klogd stop >/dev/null 2>&1 || echo "Error stopping klogd." + if [ -n "$opt_chain" ]; then + /sbin/init.d/$opt_chain stop >/dev/null 2>&1 || echo "Error stopping $opt_chain." + fi } function do_update { if [ -e $pidfile ] ; then read < $pidfile - [ "$pidfile" ] && kill -HUP $REPLY > /dev/null 2>&1 + [ "$REPLY" ] && kill -HUP $REPLY > /dev/null 2>&1 fi } |