[syslog-ng] [Bug 103] Refresh of files in contrib/cygwin-packaging

Corinna Vinschen vinschen at redhat.com
Tue Jan 11 16:04:07 CET 2011


On Jan 11 11:35, bugzilla at wwwold.balabit.com wrote:
> https://bugzilla.balabit.com/show_bug.cgi?id=103
> 
> 
> 
> 
> 
> --- Comment #3 from Balazs Scheidler <bazsi at balabit.hu>  2011-01-11 11:35:27 ---
> Thanks for your contribution. Could you please sign-off the patch as described by my post on the mailing list?

signed-off by Corinna Vinschen <vinschen at redhat.com>

diff --git a/contrib/cygwin-packaging/cygwin-postinstall b/contrib/cygwin-packaging/cygwin-postinstall
index e812ead..d96fecf 100755
--- a/contrib/cygwin-packaging/cygwin-postinstall
+++ b/contrib/cygwin-packaging/cygwin-postinstall
@@ -1,9 +1,10 @@
-#!/bin/sh
-DESTDIR=""
-if [ -n "$1" ]
+#!/bin/bash
+if [ -z "$1" ]
 then
-  DESTDIR=$1
+  echo "Usage: $0 DESTDIR"
+  exit 1
 fi
+DESTDIR="$1"
 if [ ! -d "contrib/cygwin-packaging" ]
 then
   echo "Please run 'contrib/cygwin-packaging/cygwin-postinstall' from the top-level source directory."
@@ -20,12 +21,23 @@ then
   echo "Have a look into 'contrib/cygwin-packaging/cygwin-postinstall' how to do it."
   exit 3
 fi
-mkdir -p "${DESTDIR}/usr/bin"
-#mkdir -p "${DESTDIR}/usr/share/doc/syslog-ng"
+pushd "${DESTDIR}" || exit 4
+mkdir -p etc/defaults/etc etc/postinstall
+mv etc/syslog-ng etc/defaults/etc
+cd usr/lib
+rm *.a *.la
+if [ -d bin ]
+then
+  mv bin/* syslog-ng
+  rmdir bin
+fi
+cd syslog-ng
+rm *.a *.la *.so
+ln -s cygafsocket-tls.dll cygafsocket.dll
+popd
+cp contrib/cygwin-packaging/syslog-ng-config "${DESTDIR}/usr/bin/"
+cp contrib/cygwin-packaging/syslog-ng.sh "${DESTDIR}/etc/postinstall/"
 mkdir -p "${DESTDIR}/usr/share/doc/Cygwin"
-cp contrib/cygwin-packaging/syslog-ng-config "${DESTDIR}/usr/bin"
-#cp -rp doc/examples/syslog-ng.conf.s* doc/reference/syslog-ng.[tx]* "${DESTDIR}/usr/share/doc/syslog-ng"
-#tar xzfC doc/reference/syslog-ng.html.tar.gz "${DESTDIR}/usr/share/doc/syslog-ng"
 cat > "${DESTDIR}/usr/share/doc/Cygwin/syslog-ng.README" <<'EOF'
 If you want to use syslog-ng, just run the /usr/bin/syslog-ng-config
 script.  This script will create a default configuration file
@@ -38,20 +50,18 @@ The syslog-ng-config script, as well as the latest version of the
 syslogd-config script are taking care of this when requested to install
 as service.
 
-The syslog-ng package has been built using the following command
+The syslog-ng package has been created using the following command
 sequence from the top level source dir:
 
 ./configure \
         --prefix=/usr \
-        --sysconfdir=/etc \
-        --libexecdir='$(prefix)/sbin' \
-        --localstatedir=/var \
-        --datadir='$(prefix)/share' \
-        --mandir='$(prefix)/share/man' \
-        --infodir='$(prefix)/share/info' \
-	--enable-dynamic-linking \
-	--with-pidfile-dir=/var
-make
-make install-strip
-contrib/cygwin-packaging/cygwin-postinstall
+        --sysconfdir=/etc/syslog-ng \
+        --libexecdir='${prefix}/lib' \
+        --localstatedir=/var/lib/syslog-ng \
+        --datadir='${prefix}/share/syslog-ng'
+make
+mkdir /tmp/syslog-ng
+make install-strip DESTDIR=/tmp/syslog-ng
+contrib/cygwin-packaging/cygwin-postinstall /tmp/syslog-ng
+tar -cjf syslog-ng-VERSION.tar.bz2 -C /tmp/syslog-ng etc usr
 EOF
diff --git a/contrib/cygwin-packaging/syslog-ng-config b/contrib/cygwin-packaging/syslog-ng-config
index 34e389c..3196246 100755
--- a/contrib/cygwin-packaging/syslog-ng-config
+++ b/contrib/cygwin-packaging/syslog-ng-config
@@ -1,19 +1,24 @@
 #!/bin/sh
 #
-# syslog-ng-config, Copyright 2005, 2006 Corinna Vinschen
+# syslog-ng-config, Copyright 2005, 2006, 2010 Corinna Vinschen
 #
 # This file is part of the Cygwin port of syslog-ng.
 
 # set -x
 
 # Subdirectory where the new package is being installed
-PREFIX=/usr
+PREFIX="/usr"
 
 # Directory where the config files are stored
-SYSCONFDIR=/etc
-DEVDIR=/dev
-LOGDIR=/var/log
-RUNDIR=/var/run
+SYSCONFDIR="/etc/syslog-ng"
+
+# Paths of the config files starting with 3.2.1.
+SYSCONFFILE="${SYSCONFDIR}/syslog-ng.conf"
+SCLFILE="${SYSCONFDIR}/scl.conf"
+MODULESFILE="${SYSCONFDIR}/modules.conf"
+
+# Directory in which the templates are stored.
+DEFAULTDIR="/etc/defaults"
 
 progname=$0
 auto_answer=""
@@ -96,149 +101,55 @@ fi
 
 # Create it if necessary
 
+[ ! -e "${SYSCONFDIR}" ] && mkdir -p "${SYSCONFDIR}"
 if [ ! -e "${SYSCONFDIR}" ]
 then
-  mkdir "${SYSCONFDIR}"
-  if [ ! -e "${SYSCONFDIR}" ]
-  then
-    echo
-    echo "Creating ${SYSCONFDIR} directory failed."
-    echo
-    exit 1
-  fi
-fi
-setfacl -m u:system:rwx "${SYSCONFDIR}"
-
-# Check for ${DEVDIR} directory
-
-if [ -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 1
-fi
-
-# Create it if necessary
-
-if [ ! -e "${DEVDIR}" ]
-then
-  mkdir "${DEVDIR}"
-  if [ ! -e "${DEVDIR}" ]
-  then
-    echo
-    echo "Creating ${DEVDIR} directory failed."
-    echo
-    exit 1
-  fi
-fi
-setfacl -m u:system:rwx "${DEVDIR}"
-
-# Check for ${LOGDIR} directory
-
-if [ -e "${LOGDIR}" -a ! -d "${LOGDIR}" ]
-then
   echo
-  echo "${LOGDIR} is existant but not a directory."
-  echo "syslogging using syslog-ng will not work."
+  echo "Creating ${SYSCONFDIR} directory failed."
   echo
   exit 1
 fi
+setfacl -m u:system:rwx "${SYSCONFDIR}"
 
-# Create it if necessary
-
-if [ ! -e "${LOGDIR}" ]
-then
-  mkdir -p "${LOGDIR}"
-  if [ ! -e "${LOGDIR}" ]
-  then
-    echo
-    echo "Creating ${LOGDIR} directory failed."
-    echo
-    exit 1
-  fi
-fi
-setfacl -m u:system:rwx "${LOGDIR}"
-
-# Check for ${RUNDIR} directory
+# Only offer to overwrite if template files exist.
 
-if [ -e "${RUNDIR}" -a ! -d "${RUNDIR}" ]
+if [ -f "${DEFAULTDIR}${SYSCONFFILE}" ]
 then
-  echo
-  echo "${RUNDIR} is existant but not a directory."
-  echo "syslogging using syslog-ng will not work."
-  echo
-  exit 1
-fi
 
-# Create it if necessary
+  # Check if syslog-ng.conf exists. If yes, ask for overwriting
 
-if [ ! -e "${RUNDIR}" ]
-then
-  mkdir -p "${RUNDIR}"
-  if [ ! -e "${RUNDIR}" ]
+  if [ -f "${SYSCONFFILE}" ]
   then
-    echo
-    echo "Creating ${RUNDIR} directory failed."
-    echo
-    exit 1
+    if request "Overwrite existing ${SYSCONFFILE} file?"
+    then
+      mv -f "${SYSCONFFILE}" "${SYSCONFFILE}.old"
+      if [ -f "${SYSCONFFILE}" ]
+      then
+	echo "Can't overwrite. ${SYSCONFFILE} is write protected."
+      else
+	echo "${SYSCONFFILE} has been renamed to ${SYSCONFFILE}.old."
+      fi
+    fi
   fi
-fi
-setfacl -m u:system:rwx "${RUNDIR}"
 
-# Check if syslog-ng.conf exists. If yes, ask for overwriting
-
-if [ -f "${SYSCONFDIR}/syslog-ng.conf" ]
-then
-  if request "Overwrite existing ${SYSCONFDIR}/syslog-ng.conf file?"
+  if [ ! -f "${SYSCONFFILE}" ]
   then
-    rm -f "${SYSCONFDIR}/syslog-ng.conf"
-    if [ -f "${SYSCONFDIR}/syslog-ng.conf" ]
+    echo "Creating default syslog-ng configuration files in ${SYSCONFDIR}"
+    cp "${DEFAULTDIR}${SYSCONFFILE}" "${SYSCONFFILE}"
+    setfacl -m u:system:rw- "${SYSCONFFILE}"
+    if [ -f "${DEFAULTDIR}${SCLFILE}" ]
+    then
+      cp "${DEFAULTDIR}${SCLFILE}" "${SCLFILE}"
+      setfacl -m u:system:rw- "${SCLFILE}"
+    fi
+    if [ -f "${DEFAULTDIR}${MODULESFILE}" ] 
     then
-      echo "Can't overwrite. ${SYSCONFDIR}/syslog-ng.conf is write protected."
+      cp "${DEFAULTDIR}${MODULESFILE}" "${MODULESFILE}"
+      setfacl -m u:system:rw- "${MODULESFILE}"
     fi
   fi
-fi
-
-if [ ! -f "${SYSCONFDIR}/syslog-ng.conf" ]
-then
-  echo "Creating default ${SYSCONFDIR}/syslog-ng.conf file"
-  cat > ${SYSCONFDIR}/syslog-ng.conf << EOF
- at version: 3.0
-options {
-  keep_hostname(yes);
-  owner("system");
-  group("root");
-  perm(0664);
-  flush_lines(0);
-};
-
-source applications {
-  unix-dgram("/dev/log");
-  internal();
-};
-
-source kernel {
-  file("/dev/kmsg", program_override("kernel: "));
-};
-
-destination messages {
-  file("/var/log/messages");
-};
-
-log {
-  source(applications);
-  destination(messages);
-};
 
-log {
-  source(kernel);
-  destination(messages);
-};
-EOF
 fi
-setfacl -m u:system:rw- "${SYSCONFDIR}/syslog-ng.conf"
 
 # Check if syslogd is installed and remove on user request.
 if cygrunsrv -Q syslogd > /dev/null 2>&1
@@ -262,7 +173,7 @@ then
   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 --fd-limit 256"
+    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."
diff --git a/contrib/cygwin-packaging/syslog-ng.sh b/contrib/cygwin-packaging/syslog-ng.sh
new file mode 100755
index 0000000..029c669
--- /dev/null
+++ b/contrib/cygwin-packaging/syslog-ng.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# syslog-ng.sh, postinstall script for Cygwin
+#
+# This file is part of the Cygwin port of syslog-ng.
+
+# Directory where the config files are stored
+SYSCONFDIR="/etc/syslog-ng"
+
+# Old config file, up to 3.0.1.
+OLDSYSCONFFILE="/etc/syslog-ng.conf"
+
+# Paths of the config files starting with 3.2.1.
+SYSCONFFILE="${SYSCONFDIR}/syslog-ng.conf"
+SCLFILE="${SYSCONFDIR}/scl.conf"
+MODULESFILE="${SYSCONFDIR}/modules.conf"
+
+# Directory in which the templates are stored.
+DEFAULTDIR="/etc/defaults"
+
+# Directory to keep state information
+LOCALSTATEDIR=/var/lib/syslog-ng
+
+# If an old syslog-ng.conf file exists, but no new one, move the old
+# one over to the new configuration directory.
+if [ -f "${OLDSYSCONFFILE}" -a ! -f "${SYSCONFFILE}" ]
+then
+  # Check for ${SYSCONFDIR} directory, create it if necessary.
+  [ -e "${SYSCONFDIR}" -a ! -d "${SYSCONFDIR}" ] && exit 1
+  [ ! -e "${SYSCONFDIR}" ] && mkdir -p "${SYSCONFDIR}"
+  [ ! -e "${SYSCONFDIR}" ] && exit 2
+  setfacl -m u:system:rwx "${SYSCONFDIR}"
+  mv -f "${OLDSYSCONFFILE}" "${SYSCONFFILE}"
+  setfacl -m u:system:rw- "${SYSCONFFILE}"
+  # Always copy template files to ${SYSCONFDIR} and add a ".new" suffix
+  # to the ${SYSCONFFILE} template so the admin knows something has changed.
+  cp "${DEFAULTDIR}${SYSCONFFILE}" "${SYSCONFFILE}.new"
+  cp "${DEFAULTDIR}${SCLFILE}" "${SCLFILE}"
+  cp "${DEFAULTDIR}${MODULESFILE}" "${MODULESFILE}"
+fi
+
+# Make sure /var/lib/syslog-ng exists.
+if [ -e "${LOCALSTATEDIR}" -a ! -d "${LOCALSTATEDIR}" ]
+then
+  rm -f "${LOCALSTATEDIR}"
+  [ -e "${LOCALSTATEDIR}" ] && exit 3
+fi
+[ ! -e "${LOCALSTATEDIR}" ] && mkdir -p "${LOCALSTATEDIR}"
+[ ! -d "${LOCALSTATEDIR}" ] && exit 4
+setfacl -m u:system:rwx "${LOCALSTATEDIR}"
+exit 0


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


More information about the syslog-ng mailing list