-
Notifications
You must be signed in to change notification settings - Fork 0
/
permit.sh
33 lines (32 loc) · 824 Bytes
/
permit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/bash
echo "Type of User(Account/Branch Manager/CEO)"
read type
if [[ "$type" == "Account" ]]; then
echo "Enter Account Name(ACC0001)"
read name
setfacl -m u:$name:rx -R /home/$name
elif [[ "$type" == "Branch Manager" ]]; then
echo "Enter Branch Name(Eg. Branch1)"
read branch
arr=($(find /home -type d -name "$branch"))
var=${#arr[@]}
for (( c=0 ; c<$var ; c++ ))
do
setfacl -m u:$branch:rwx -R ${arr[$c]}
done
elif [[ "$type" == "CEO" ]]; then
echo "Name of CEO(Same as User Account)"
read ceo
a=($(find /home -type d -name "ACC*"))
b=($(find /home -type d -name "Branch*"))
var_a=${#a[@]}
var_b=${#b[@]}
for (( c=0 ; c<$var_a ; c++ ))
do
setfacl -m u:$ceo:rx -R ${a[$c]}
done
for (( c=0 ; c<$var_b ; c++ ))
do
setfacl -m u:$ceo:rwx -R ${b[$c]}
done
fi