📄 syslog-ng-config
字号:
#!/bin/sh## syslog-ng-config, Copyright 2005, 2006 Corinna Vinschen## This file is part of the Cygwin port of syslog-ng.# set -x# Subdirectory where the new package is being installedPREFIX=/usr# Directory where the config files are storedSYSCONFDIR=/etcDEVDIR=/devLOGDIR=/var/logRUNDIR=/var/runprogname=$0auto_answer=""request(){ if [ "${auto_answer}" = "yes" ] then return 0 elif [ "${auto_answer}" = "no" ] then return 1 fi answer="" while [ "X${answer}" != "Xyes" -a "X${answer}" != "Xno" ] do echo -n "$1 (yes/no) " read answer done if [ "X${answer}" = "Xyes" ] then return 0 else return 1 fi}# Check optionswhile :do case $# in 0) break ;; esac option=$1 shift case "$option" in -d | --debug ) set -x ;; -y | --yes ) auto_answer=yes ;; -n | --no ) auto_answer=no ;; *) echo "usage: ${progname} [OPTION]..." echo echo "This script creates a basic syslog-ng configuration." echo echo "Options:" echo " --debug -d Enable shell's debug output." echo " --yes -y Answer all questions with \"yes\" automatically." echo " --no -n Answer all questions with \"no\" automatically." echo exit 1 ;; esacdone# Check for ${SYSCONFDIR} directoryif [ -e "${SYSCONFDIR}" -a ! -d "${SYSCONFDIR}" ]then echo echo "${SYSCONFDIR} is existant but not a directory." echo "Cannot create global configuration files." echo exit 1fi# Create it if necessaryif [ ! -e "${SYSCONFDIR}" ]then mkdir "${SYSCONFDIR}" if [ ! -e "${SYSCONFDIR}" ] then echo echo "Creating ${SYSCONFDIR} directory failed." echo exit 1 fifisetfacl -m u:system:rwx "${SYSCONFDIR}"# Check for ${DEVDIR} directoryif [ -e "${DEVDIR}" -a ! -d "${DEVDIR}" ]then echo echo "${DEVDIR} is existant but not a directory." echo "syslogging using syslog-ng will not work." echo exit 1fi# Create it if necessaryif [ ! -e "${DEVDIR}" ]then mkdir "${DEVDIR}" if [ ! -e "${DEVDIR}" ] then echo echo "Creating ${DEVDIR} directory failed." echo exit 1 fifisetfacl -m u:system:rwx "${DEVDIR}"# Check for ${LOGDIR} directoryif [ -e "${LOGDIR}" -a ! -d "${LOGDIR}" ]then echo echo "${LOGDIR} is existant but not a directory." echo "syslogging using syslog-ng will not work." echo exit 1fi# Create it if necessaryif [ ! -e "${LOGDIR}" ]then mkdir -p "${LOGDIR}" if [ ! -e "${LOGDIR}" ] then echo echo "Creating ${LOGDIR} directory failed." echo exit 1 fifisetfacl -m u:system:rwx "${LOGDIR}"# Check for ${RUNDIR} directoryif [ -e "${RUNDIR}" -a ! -d "${RUNDIR}" ]then echo echo "${RUNDIR} is existant but not a directory." echo "syslogging using syslog-ng will not work." echo exit 1fi# Create it if necessaryif [ ! -e "${RUNDIR}" ]then mkdir -p "${RUNDIR}" if [ ! -e "${RUNDIR}" ] then echo echo "Creating ${RUNDIR} directory failed." echo exit 1 fifisetfacl -m u:system:rwx "${RUNDIR}"# Check if syslog-ng.conf exists. If yes, ask for overwritingif [ -f "${SYSCONFDIR}/syslog-ng.conf" ]then if request "Overwrite existing ${SYSCONFDIR}/syslog-ng.conf file?" then rm -f "${SYSCONFDIR}/syslog-ng.conf" if [ -f "${SYSCONFDIR}/syslog-ng.conf" ] then echo "Can't overwrite. ${SYSCONFDIR}/syslog-ng.conf is write protected." fi fifiif [ ! -f "${SYSCONFDIR}/syslog-ng.conf" ]then echo "Creating default ${SYSCONFDIR}/syslog-ng.conf file" cat > ${SYSCONFDIR}/syslog-ng.conf << EOFoptions { keep_hostname(yes); chain_hostnames(no); owner("system"); group("root"); perm(0664); sync(0);};source applications { unix-dgram("/dev/log"); internal();};source kernel { file("/dev/kmsg", log_prefix("kernel: "));};destination messages { file("/var/log/messages");};log { source(applications); destination(messages);};log { source(kernel); destination(messages);};EOFfisetfacl -m u:system:rw- "${SYSCONFDIR}/syslog-ng.conf"# Check if running on NT_sys="`uname`"_nt=`expr "${_sys}" : "CYGWIN_NT"`# On NT ask if syslog-ng should be installed as serviceif [ ${_nt} -gt 0 ]then # Check if syslogd is installed and remove on user request. if cygrunsrv -Q syslogd > /dev/null 2>&1 then echo "Warning: The syslogd service is already installed. You can not" echo "run both, syslogd and syslog-ng in parallel." echo if request "Do you want to deinstall the syslogd service in favor of syslog-ng?" then cygrunsrv -E syslogd cygrunsrv -R syslogd fi fi # Install syslog-ng service if it is not already installed if ! cygrunsrv -Q syslog-ng > /dev/null 2>&1 then echo echo echo "Warning: The following function requires administrator privileges!" echo echo "Do you want to install syslog-ng as service?" if request "(Say \"no\" if it's already installed as service)" then if cygrunsrv -I syslog-ng -d "CYGWIN syslog-ng" -p /usr/sbin/syslog-ng -a -F then echo echo "The service has been installed under LocalSystem account." echo "To start the service, call \`net start syslog-ng' or \`cygrunsrv -S syslog-ng'." echo echo "Check ${SYSCONFDIR}/syslog-ng.conf first, if it suits your needs." fi fi fifiechoecho "Configuration finished. Have fun!"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -