summaryrefslogtreecommitdiff
path: root/volinit-netatalk
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2001-12-13 17:00:32 +0000
committerJonas Smedegaard <dr@jones.dk>2001-12-13 17:00:32 +0000
commitc9d1b77034eceb7325fac46b3c3bd2c82171e0ca (patch)
treedf1b4f4af4d8e19fb159e30f65d0424c6940ae5d /volinit-netatalk
parent71f00e0988ca7f453968beedddfb528eb1d8e446 (diff)
volinit-netatalk: Improve uid check and fallback to default user and group.
Diffstat (limited to 'volinit-netatalk')
-rwxr-xr-xvolinit-netatalk42
1 files changed, 29 insertions, 13 deletions
diff --git a/volinit-netatalk b/volinit-netatalk
index f81bad8..3307851 100755
--- a/volinit-netatalk
+++ b/volinit-netatalk
@@ -11,6 +11,10 @@
# NDIR="/var/local/netatalk"
#
+# Fallback to this uid and gid if group uid doesn't exist
+GRP_UID="admin"
+GRP_GID="admin"
+
[ -f /etc/local/volumes ] || exit 1
. /etc/local/volumes
[ "x$NDIR" = "x" ] && exit 1
@@ -18,28 +22,40 @@
if [ $# -eq 0 ]; then
echo "Usage: $0 <base directory> <read user/group> <write user/group> [create]"
exit 1
- fi
+fi
if [ "x$1" = "x" ]; then
- echo "$0: base directory missing"
+ echo "$0: base directory missing - exiting..."
exit 1
- fi
+fi
VOL=$NDIR/$1
if [ "x$2" = "x" ]; then
- echo "$0: read group missing"
+ echo "$0: read group missing - exiting..."
exit 1
- fi
+fi
ALL=$2
+#if [ `getent passwd "$ALL" | awk -F: '{print $1}';` ]; then
+if [ `getent passwd "$ALL"` ]; then
+ ALL_UID=$ALL
+ ALL_GID=$ALL
+else
+ echo "$0: User id $ALL doesn't exist - exiting..."
+ exit 1
+fi
if [ "x$3" = "x" ]; then
- echo "$0: write group missing"
+ echo "$0: write group missing - exiting..."
exit 1
- fi
+fi
GRP=$3
-
-GRPUSER="admin"
-id $GRP >/dev/null && GRPUSER=$GRP
+#if [ `getent passwd "$GRP" | awk -F: '{print $1}';` = "" ]; then
+if [ `getent passwd "$GRP"` ]; then
+ GRP_UID=$GRP
+ GRP_GID=$GRP
+else
+ echo "User id $GRP doesn't exist - using $GRP_UID:$GRP_GID instead"
+fi
if [ "x$4" != "x" ]; then
if [ "x$4" == "xcreate" ]; then
@@ -53,15 +69,15 @@ fi
test -d $VOL/$ALL/$GRP || exit
test -d $VOL/$ALL/$GRP/.AppleDouble || mkdir $VOL/$ALL/$GRP/.AppleDouble
test -d $VOL/$ALL/$GRP/.AppleDesktop || mkdir $VOL/$ALL/$GRP/.AppleDesktop
-chown root:$ALL $VOL/$ALL
-chown $GRPUSER:$ALL $VOL/$ALL/$GRP
+chown root:$ALL_GID $VOL/$ALL
+chown $GRP_UID:$ALL_GID $VOL/$ALL/$GRP
chmod u=rwX,g=rXs,o= $VOL/$ALL
chmod u=rwX,g=rXs,o= $VOL/$ALL/$GRP
echo "People in group $GRP has read/write access through AppleShare"
test $GRP = $ALL || echo "People in group $ALL has read access through AppleShare"
echo "Others have no access"
echo -n "Checking permissions..."
-chown -R :$GRP $VOL/$ALL/$GRP \
+chown -R .$GRP_GID $VOL/$ALL/$GRP \
&& chmod -R u=rwX,g=rwXs,o=rX $VOL/$ALL/$GRP \
&& chmod u=rwX,g=rXs,o=rX $VOL/$ALL/$GRP
echo "."