From 445aee0ba17e7d9c803187f233428802d3721374 Mon Sep 17 00:00:00 2001 From: Peter Ludikovsky Date: Thu, 8 Sep 2016 17:13:07 +0200 Subject: * Debianized everything * Corrects/improves SystemD Unit * Disabling logging to /var/log --- debian/changelog | 11 +++++++++++ debian/compat | 1 + debian/control | 15 +++++++++++++++ debian/copyright | 28 ++++++++++++++++++++++++++++ debian/junker.install | 1 + debian/junker@.service | 13 +++++++++++++ debian/rules | 32 ++++++++++++++++++++++++++++++++ debian/source/format | 1 + junker.sh | 30 +++++------------------------- junker@.service | 11 ----------- 10 files changed, 107 insertions(+), 36 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/junker.install create mode 100644 debian/junker@.service create mode 100755 debian/rules create mode 100644 debian/source/format delete mode 100644 junker@.service diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..5b747f1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,11 @@ +junker (0.0.1-2) jessie; urgency=low + + * Adaptions for systemd + + -- Peter Ludikovsky Thu, 08 Sep 2016 14:44:17 +0000 + +junker (0.0.1-1) jessie; urgency=low + + * Initial release + + -- Peter Ludikovsky Thu, 08 Sep 2016 13:32:17 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..593e7b5 --- /dev/null +++ b/debian/control @@ -0,0 +1,15 @@ +Source: junker +Section: mail +Priority: optional +Maintainer: Peter Ludikovsky +Build-Depends: debhelper (>= 9), dh-systemd +Standards-Version: 3.9.6 +#Vcs-Git: git://anonscm.debian.org/collab-maint/junker.git +Vcs-Browser: https://ludikovsky.name/cgit/junker.git/ + +Package: junker +Architecture: all +Depends: ${misc:Depends}, spamassassin, inotify-utils, bash (>= 4.0) +Description: inotfy-based spam/ham learner + junker is a small, inotify-based, spam/ham learner, that will submit all + mails in a users Junk mdir to spamassassin via spamc. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..6948cff --- /dev/null +++ b/debian/copyright @@ -0,0 +1,28 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: junker +Source: https://ludikovsky.name/cgit/junker.git/ + +Files: * +Copyright: 2016 Peter Ludikovsky +License: GPL-3.0+ + +Files: debian/* +Copyright: 2016 Peter Ludikovsky +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/junker.install b/debian/junker.install new file mode 100644 index 0000000..d51401e --- /dev/null +++ b/debian/junker.install @@ -0,0 +1 @@ +debian/junker@.service lib/systemd/system diff --git a/debian/junker@.service b/debian/junker@.service new file mode 100644 index 0000000..f7f3eef --- /dev/null +++ b/debian/junker@.service @@ -0,0 +1,13 @@ +[Unit] +Description=inotfy-based spam/ham learner +Requires=spamassassin.service + +[Service] +Type=simple +ExecStart=/usr/bin/junker %i +ExecReload=/bin/kill -HUP $MAINPID +User=%i +Group=nogroup + +[Install] +WantedBy=multi-user.target diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..1395143 --- /dev/null +++ b/debian/rules @@ -0,0 +1,32 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#DH_VERBOSE = 1 + +# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/default.mk + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +# main packaging script based on dh7 syntax +%: + dh $@ --with-systemd + +# debmake generated override targets +# This is example for Cmake (See http://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) + + + + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/junker.sh b/junker.sh index 964f406..3314ada 100755 --- a/junker.sh +++ b/junker.sh @@ -8,7 +8,6 @@ BASE="${HOME}"/Maildir INOTIFY='/usr/bin/inotifywait' INOTIFY_EVENTS='moved_to,moved_from' INOTIFY_OPTIONS='--monitor --recursive --event'" ${INOTIFY_EVENTS}" -LOG=/var/log/junker/${USER}.log SPAMC='/usr/bin/spamc' JUNK="${BASE}/Junk" @@ -22,22 +21,12 @@ then . "${HOME}/.junkerrc" fi -function OpenLog { - exec 3>>"${LOG}" - exec 1>&3 - exec 2>&3 - Log "Log opened" -} -function CloseLog { - Log "Log closed" - exec 3>&- -} function Log { echo -e "$( date +'%Y%m%d %H:%M:%S' )\t$@" } function Cleanup { - CloseLog + Log "Exiting" exit 0 } @@ -61,21 +50,11 @@ function Learn { exec 9<&- } -function Reload { - CloseLog - OpenLog -} - if [ ! -d "${BASE}" ] then echo "Error: Mail directory not found at ${BASE}, exiting" >&2 exit 1 fi -if [ ! -d "$( dirname ${LOG} )" ] -then - echo "Error: Log directory not found at ${LOG}, exiting" >&2 - exit 1 -fi if [ ! -x ${INOTIFY} ] then echo "Error: inotifywait not found, check path" >&2 @@ -87,14 +66,15 @@ then exit 1 fi checkfile=$( mktemp ) -${SPAMC} --learntype forget <$checkfile +echo ${RANDOM} >${checkfile} +${SPAMC} --learntype forget <${checkfile} >/dev/null 2>&1 if [ $? -eq 74 ] then echo "Error: spamd doesn't allow connections, needs --allow-tell" >&2 + rm -f ${checkfile} exit 1 fi - -OpenLog +rm -f ${checkfile} trap "Cleanup" EXIT SIGINT SIGTERM trap "Reload" SIGHUP diff --git a/junker@.service b/junker@.service deleted file mode 100644 index fe68add..0000000 --- a/junker@.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=inotfy-based spam/ham learner - -[Service] -Type=simple -ExecStart=/usr/bin/junker.sh %i -ExecReload=/bin/kill -HUP $MAINPID - -[Install] -WantedBy=multi-user.target -Requires=spamassassin.service -- cgit v1.2.3