summaryrefslogtreecommitdiff
path: root/package/ids
diff options
context:
space:
mode:
authorJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:48:04 +0200
committerJannis Hoffmann <jannis@fehcom.de>2024-07-03 15:48:04 +0200
commit89b7b67a13ebb7965cc7f13ad0595e2194a2d34c (patch)
tree25efd77a90ae87236e6730d8ea3846bbe0fd126f /package/ids
add sqmail-4.2.29asqmail-4.2
Diffstat (limited to 'package/ids')
-rwxr-xr-xpackage/ids106
1 files changed, 106 insertions, 0 deletions
diff --git a/package/ids b/package/ids
new file mode 100755
index 0000000..7b18788
--- /dev/null
+++ b/package/ids
@@ -0,0 +1,106 @@
+#!/bin/sh
+shout() { echo "$0: $@" >&2; }
+barf() { shout "fatal: $@"; exit 111; }
+safe() { "$@" || barf "cannot $@"; }
+
+here=`env - PATH=$PATH pwd`
+mypwd=${here%package}
+mypwd=${mypwd%/}
+home=`head -1 $mypwd/conf-home`
+
+if [ -f $mypwd/conf-ids ]
+then
+ sqmailids=`grep -v "^#" $mypwd/conf-ids | grep ":" | tr ' ' '_'`
+else
+ barf "Can't open file '$mypwd/conf-ids' with sqmail ids!"
+fi
+
+unix=`uname -a | cut -d' ' -f1 | tr [a-z] [A-Z]`
+
+if [ "$unix" = "LINUX" ]
+then
+ qshl="/bin/false"
+ shout "Linux (Shell: $qshl):"
+
+ for line in $sqmailids
+ do
+ if [ `echo $line | grep "group"` ]
+ then
+ qgid=`echo "$line" | cut -d":" -f1`
+ qgrp=`echo "$line" | cut -d":" -f2`
+ if [ `grep -c ^$qgrp /etc/group` -eq 0 ]
+ then
+ safe groupadd -g $qgid $qgrp
+ else
+ shout "Group '$qgrp' already existing!"
+ fi
+ fi
+
+ if [ `echo $line | grep "user"` ]
+ then
+ quid=`echo "$line" | cut -d":" -f1`
+ qusr=`echo "$line" | cut -d":" -f2`
+ qcom=`echo "$line" | cut -d":" -f3 | tr "_" " "`
+ qgrp=`echo "$line" | cut -d":" -f4`
+ qdir="$home/`echo "$line" | cut -d":" -f5`"
+ if [ `grep -c $qusr /etc/passwd` -eq 0 ]
+ then
+ shout "Generating user: $qusr:$quid - $qgr - $qdir - $qshl - $qcom"
+ safe useradd -u $quid -g $qgrp -d $qdir $qusr -s $qshl -c "$qcom"
+ else
+ shout "User '$qusr' already existing!"
+ fi
+ fi
+ done
+
+elif [ `echo "$unix" | grep "BSD"` ]
+then
+ qshl="/sbin/nologin"
+ shout "BSD ($unix) (Shell: $qshl):"
+
+ for line in $sqmailids
+ do
+ if [ `echo $line | grep "group"` ]
+ then
+ qgid=`echo "$line" | cut -d":" -f1`
+ qgrp=`echo "$line" | cut -d":" -f2`
+ if [ `grep -c ^$qgrp /etc/group` -eq 0 ]
+ then
+ if [ `echo "$unix" | grep "OPENBSD"` ]
+ then
+ safe groupadd -g $qgid $qgrp
+ else
+ safe pw groupadd $qgrp -g $qgid $qgrp
+ fi
+ else
+ shout "Group '$qgrp' already existing!"
+ fi
+ fi
+ if [ `echo $line | grep "user"` ]
+ then
+ quid=`echo "$line" | cut -d":" -f1`
+ qusr=`echo "$line" | cut -d":" -f2`
+ qcom=`echo "$line" | cut -d":" -f3 | tr "_" " "`
+ qgrp=`echo "$line" | cut -d":" -f4`
+ qdir="$home/`echo "$line" | cut -d":" -f5`"
+ if [ `grep -c $qusr /etc/passwd` -eq 0 ]
+ then
+ shout "Generating user: $qusr:$quid - $qgrp - $qdir - $qshl - $qcom"
+ if [ `echo "$unix" | grep "OPENBSD"` ]
+ then
+ safe useradd -u $quid -g $qgrp -d $qdir -s $qshl -c "$qcom" $qusr
+ else
+ safe pw useradd $qusr -u $quid -g $qgrp -d $qdir -s $qshl -c "$qcom"
+ fi
+ else
+ shout "User '$qusr' already existing!"
+ fi
+ fi
+ done
+
+else
+ shout "Unix OS not recognized; please install s/qmail user/groups manually \\
+ and continue with installation step-by-step."
+fi
+
+exit 0