added cyan to machine color in prompt

added write permission flag to acl script
added pass through options from share_dir to the acladduser
master
Kebler Network System Administrator 2021-04-14 10:51:17 -07:00
parent 5d2ccc7c4f
commit 4ad1946952
2 changed files with 19 additions and 9 deletions

View File

@ -30,7 +30,10 @@ case $TERM in
;; ;;
esac esac
local UC=WHITE # user's color local UC=WHITE # user's color
local MC=CYAN # machine color
[[ $SSH_SESSION == "true" ]] && UC=LIGHT_PURPLE && MC=WHITE # remote machine color
[ $UID -eq "0" ] && UC=LIGHT_RED # root's color [ $UID -eq "0" ] && UC=LIGHT_RED # root's color
# PS1="$PARENTBASE\[${UC}\]\u@\h: \[${COLOR_LIGHT_GREEN}\]→\[${COLOR_NC}\] " # PS1="$PARENTBASE\[${UC}\]\u@\h: \[${COLOR_LIGHT_GREEN}\]→\[${COLOR_NC}\] "
@ -41,7 +44,7 @@ local dir
local branch local branch
local promptc local promptc
user="$(c $UC)\u$(c GREY)@$(c NC)" user="$(c $UC)\u$(c GREY)@$(c NC)"
machine="$(c CYAN)\h$(c GREY):$(c NC)" machine="$(c $MC)\h$(c GREY):$(c NC)"
dir="$(c YELLOW)[${PARENTBASE}]$(c NC)" dir="$(c YELLOW)[${PARENTBASE}]$(c NC)"
branch=$(c LIGHT_BLUE)'$(parse_git_branch)'$(c NC) branch=$(c LIGHT_BLUE)'$(parse_git_branch)'$(c NC)
promptc=$(c GREEN)' $ '$(c NC) promptc=$(c GREEN)' $ '$(c NC)

View File

@ -15,21 +15,25 @@ acladduserdir() {
local uid local uid
local usesudo local usesudo
local del local del
local write
local spec local spec
local dir local dir
local cmd="-R -m " local opts
local cmdd="-dR -m" local optsd
declare OPTION declare OPTION
declare OPTARG declare OPTARG
declare OPTIND declare OPTIND
while getopts 'ds' OPTION; do while getopts 'wds' OPTION; do
# echo $OPTION $OPTARG # echo $OPTION $OPTARG
case "$OPTION" in case "$OPTION" in
d) d)
del=true del=true
;; ;;
w)
write="w"
;;
s) s)
usesudo="sudo" usesudo="sudo"
;; ;;
@ -49,7 +53,7 @@ acladduserdir() {
else else
opts="-R -m " opts="-R -m "
optsd="-dR -m" optsd="-dR -m"
spec="u:$1:rwX" spec="u:$1:r${write}X"
fi fi
[[ ! $2 ]] && echo acluserdir: both user and direcotory must be passed && return 1 [[ ! $2 ]] && echo acluserdir: both user and direcotory must be passed && return 1
dir=$2 dir=$2
@ -90,13 +94,15 @@ share_dir() {
[[ ! $(sudo -l -U $USER 2>/dev/null) ]] && echo current user does not have sudo privilges, aborting && return 4 [[ ! $(sudo -l -U $USER 2>/dev/null) ]] && echo current user does not have sudo privilges, aborting && return 4
local group local group
local owner=$USER local owner=$USER
local opts=""
[[ $(getent group users) ]] && group=users || group=$USER [[ $(getent group users) ]] && group=users || group=$USER
declare OPTION declare OPTION
declare OPTARG declare OPTARG
declare OPTIND declare OPTIND
while getopts 'g:o:' OPTION; do
while getopts 'wsg:o:' OPTION; do
# echo $OPTION $OPTARG # echo $OPTION $OPTARG
case "$OPTION" in case "$OPTION" in
o) o)
@ -106,7 +112,8 @@ share_dir() {
group=$OPTARG group=$OPTARG
;; ;;
*) *)
echo unknown option $OPTION # echo adding pass through option $OPTION
opts="${opts} -${OPTION}"
;; ;;
esac esac
done done
@ -121,7 +128,7 @@ share_dir() {
confirm share directory $dir with users: $@ ? confirm || return 6 confirm share directory $dir with users: $@ ? confirm || return 6
for user in "$@"; do for user in "$@"; do
echo adding acl user $user echo adding acl user $user
acladduserdir -s $user $dir acladduserdir -s $opts $user $dir
done done
echo done adding acl users $@ echo done adding acl users $@
echo these are the chown/chmod commands that you will run echo these are the chown/chmod commands that you will run