All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.home.bin.chowntree.sh Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
#! /bin/sh
# usage
#   chowntree newUser dir*

SCRIPT=$(basename $0)
NEWUSER=$1; shift

if [ -z "$NEWUSER" ]; then
    echo "$SCRIPT: missing newUser arguments" 1>&2
    exit 1
fi

if [ "$NEWUSER" = "root" ]
then
  echo "$SCRIPT: chown to root is not allowed" 1>&2
  exit 1
fi

if ! id "$NEWUSER" > /dev/null 2>&1; then
    echo "$SCRIPT: $NEWUSER: no such user" 1>&2
    exit 1
fi

while true ; do
    DIR=$1
    if [ -z $DIR ] ; then
        exit
    fi
    shift
    chown -R "$NEWUSER" "$DIR"
    RET=$?
    if [ ! $RET -eq 0 ]; then
        echo "FAILED: chown -R $NEWUSER $DIR"
        exit $RET
    fi
done




© 2015 - 2024 Weber Informatics LLC | Privacy Policy