Depend on bash and fix the shebang
This commit is contained in:
+12
-12
@@ -1,23 +1,23 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/bash
|
||||
shopt -s extglob
|
||||
|
||||
if [ -r /etc/sa-train.conf ]; then
|
||||
if [[ -r /etc/sa-train.conf ]]; then
|
||||
while read -r name value; do
|
||||
if [[ -n "$name" && ! "$name" =~ "$\w*#" ]]; then
|
||||
if [[ -n "$name" && ! "$name" =~ ^\s*# ]]; then
|
||||
typeset "$name=$value"
|
||||
fi
|
||||
done < /etc/sa-train.conf
|
||||
fi
|
||||
|
||||
if [ -r ~/.sa-train/config ]; then
|
||||
if [[ -r ~/.sa-train/config ]]; then
|
||||
while read -r name value; do
|
||||
if [[ -n "$name" && ! "$name" =~ "$\w*#" ]]; then
|
||||
if [[ -n "$name" && ! "$name" =~ ^\s*# ]]; then
|
||||
typeset "$name=$value"
|
||||
fi
|
||||
done < ~/.sa-train/config
|
||||
fi
|
||||
|
||||
local SPAMFOLDER=${spam_folder:-.Spam}
|
||||
SPAMFOLDER=${spam_folder:-Spam}
|
||||
typeset -i "MAX_AGE=${max_age:-90}"
|
||||
|
||||
function examine
|
||||
@@ -32,17 +32,17 @@ function examine
|
||||
|
||||
local action=${2:-ham}
|
||||
|
||||
echo Learning from $subdir as $action
|
||||
echo Learning from ${subdir:-Inbox} as $action
|
||||
pushd ${subdir}cur
|
||||
if [[ -f ~/.sa-train/last$1 ]]; then
|
||||
find -H . -type f -regex ".*,[^,]*S[^,]*$" -newer ~/.sa-train/last$1 -exec sa-learn --$action --no-sync {} \+;
|
||||
find -H . -type f -regex ".*:2,[a-zA-Z]*S[a-zA-Z]*$" -newer ~/.sa-train/last$1 -exec sa-learn --$action --no-sync {} \+;
|
||||
else
|
||||
find . -type f -regex ".,[^,]*S[^,]*$" -mtime -$MAX_AGE -exec sa-learn --$action --no-sync {} \+;
|
||||
find . -type f -regex ".*:2,[a-zA-Z]*S[a-zA-Z]*$" -mtime -$MAX_AGE -exec sa-learn --$action --no-sync {} \+;
|
||||
fi
|
||||
rm -f ~/.sa-train/last$1
|
||||
|
||||
if [[ $( ls *,*([!,])S*([!,]) 2>/dev/null ) ]]; then
|
||||
ln -s $( realpath $( ls -1t *,*([!,])S*([!,]) | head -1) ) ~/.sa-train/last$1;
|
||||
if [[ $( ls *\:2,*([a-zA-Z])S*([a-zA-Z]) 2>/dev/null ) ]]; then
|
||||
ln -s $( realpath $( ls -1t *\:2,*([a-zA-Z])S*([a-zA-Z]) | head -1) ) ~/.sa-train/last$1;
|
||||
fi
|
||||
popd
|
||||
}
|
||||
@@ -59,7 +59,7 @@ if [ -d ~/Maildir ]; then
|
||||
examine $(basename $inboxdir);
|
||||
done;
|
||||
|
||||
sa-learn --sync
|
||||
echo sa-learn --sync
|
||||
|
||||
popd
|
||||
fi
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/bash
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
@@ -6,7 +6,7 @@ fi
|
||||
|
||||
if [ -r /etc/sa-train.conf ]; then
|
||||
while read -r name value; do
|
||||
if [[ -n "$name" && ! "$name" =~ "$\w*#" ]]; then
|
||||
if [[ -n "$name" && ! "$name" =~ ^\s*# ]]; then
|
||||
typeset "$name=$value"
|
||||
fi
|
||||
done < /etc/sa-train.conf
|
||||
@@ -21,6 +21,6 @@ if [ -z "$SPAMMED_USERS" ]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
for USERNAME in "$SPAMMED_USERS"; do
|
||||
sudo -U $USERNAME -H /usr/bin/sa-train-user.sh
|
||||
for USERNAME in $SPAMMED_USERS; do
|
||||
sudo --login --non-interactive --user=$USERNAME /usr/bin/sa-train-user.sh
|
||||
done
|
||||
|
||||
+4
-2
@@ -5,9 +5,9 @@ Summary: Run sa-learn on all mailbox folders for users that are members o
|
||||
|
||||
License: GPL-v3
|
||||
URL: https://github.com/danieldemus/sa-train
|
||||
Source0: https://github.com/danieldemus/sa-train/archive/master.zip
|
||||
Source0: https://github.com/danieldemus/sa-train/archive/%{Version}.tar.gz
|
||||
|
||||
Requires: sudo coreutils findutils spamassassin
|
||||
Requires: bash sudo coreutils findutils spamassassin
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
@@ -40,6 +40,7 @@ install sa-train-user.sh %{buildroot}%{_bindir}/sa-train-user.sh
|
||||
|
||||
#README
|
||||
install -m644 README.md %{buildroot}%{_pkgdocdir}
|
||||
install -m644 LICENSE %{buildroot}%{_pkgdocdir}
|
||||
|
||||
#Config file
|
||||
install sa-train.conf %{buildroot}%{_sysconfdir}/sa-train.conf
|
||||
@@ -63,6 +64,7 @@ install -Dpm 644 sa-train-group.conf %{buildroot}%{_sysusersdir}/
|
||||
|
||||
%files
|
||||
%doc %{_pkgdocdir}/README.md
|
||||
%license %{_pkgdocdir}/LICENSE
|
||||
%defattr(0644,root,root,0755)
|
||||
%config(noreplace) %{_sysconfdir}/sa-train.conf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user