summaryrefslogtreecommitdiff
path: root/userforward
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2001-12-12 19:52:40 +0000
committerJonas Smedegaard <dr@jones.dk>2001-12-12 19:52:40 +0000
commitc81b7f986867db292d62a1757123723b5ef66518 (patch)
treea217cf2f481ab7b3099ef76b519a4cc8e1786096 /userforward
Initial revision
Diffstat (limited to 'userforward')
-rwxr-xr-xuserforward29
1 files changed, 29 insertions, 0 deletions
diff --git a/userforward b/userforward
new file mode 100755
index 0000000..5ca172f
--- /dev/null
+++ b/userforward
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+if [ $# -ne 2 ]; then
+ echo "Usage: userforward {account} {forward@address.somewhere}"
+ exit 1
+fi
+
+uid=$1
+addr=$2
+
+set -e
+
+homedir=`getent passwd $uid | awk -F: '{print $6}';`
+
+if [ -e $homedir/.forward ]; then
+ echo "User \"$uid\" already has a .forward - exiting..."
+ exit 1
+fi
+
+if [ -d $homedir ]; then
+ touch $homedir/.forward
+ echo "echo $addr>$homedir/.forward"
+ echo $addr>$homedir/.forward
+ chown $uid. $homedir/.forward
+ echo "Done!"
+else
+ echo "Problem with user \"$uid\": Homedir \"$homedir\" doesn't exist - exiting..."
+ exit 1
+fi