added group_add and user_reload to basic functions

switched to acl functions loaded via module load
rysnc add ignore cache
add chmod_dirs to helpers
master
Kebler Network System Administrator 2021-02-11 18:29:28 -08:00
parent 3656f1420e
commit a21b588d08
4 changed files with 25 additions and 53 deletions

View File

@ -3,7 +3,21 @@
##-- functions which may be used by any of the alias file --#
function function_list() {
group_add() {
[[ ! $(getent group $1) ]] && echo "no group $1, aborting" && return 1
echo adding group $1 to $USER
sudo usermod -a -G $1 $USER
}
user_reload() {
save=$PWD
exec su -l $USER
cd $save
}
function function_list {
if [ $1 ]; then
# will list functions in passed file
local STR

View File

@ -1,51 +1 @@
#!/bin/bash
acluserdir() {
module_load confirm
local uid
local usesudo
local del
local spec
local cmd="-R -m "
local cmdd="-dR -m"
if [[ $1 == "-d" ]]; then
shift
echo deleting an acl entries for $1
opts="-R -x"
optsd="-dR -x"
spec="u:$1 $2"
else
opts="-R -m "
optsd="-dR -m"
spec="u:$1:rwX $2"
fi
[[ ! $2 ]] && echo acluserdir: both user and direcotory must be passed && return 1
uid=$(id -u $1 2>/dev/null)
[[ $uid -lt 1000 ]] && echo no such regular user $1 && return 2
[[ ! -d $2 ]] && echo no such directory $2 && return 3
if [[ ! -w $2 ]];then
echo $2 not writable by current user $USER
if [[ ! $(sudo -l -U $USER 2>/dev/null) ]]; then
echo user does not have sudo privilges, aborting
return 4
else
confirm "do you want to elevate to root and continue?" || return 5
usesudo="sudo"
fi
fi
echo this are the commands that you will run
echo '******************'
echo $usesudo setfacl $opts $spec
echo $usesudo setfacl $optsd $spec
echo '******************'
confirm Double Check. Do you want to continue? || return 6
$usesudo setfacl $opts $spec
$usesudo setfacl $optsd $spec
echo '*** new acl entries ***'
$usesudo getfacl -p --omit-header $2 | grep $1
}
module_load acl

View File

@ -9,5 +9,5 @@ function cprs () {
echo Command to run: rsync --progress -a -r -u "$1" "$2"
confirm Do you want to start the rsync copy? || return 0
echo copying.....
rsync --progress -a -r -u "$1" "$2"
rsync --exclude *[C]ache* --progress -a -r -u "$1" "$2"
}

View File

@ -22,4 +22,12 @@ adirname() {
echo "$(cd "$(dirname "$1")" >/dev/null 2>&1 ; pwd -P )"
}
chmod_dirs() {
# passed entire path
local usesudo
[[ $1 == -s ]] && usesudo="sudo" && shift 2
$usesudo find $1 -type f -exec chmod $2 {} +
}