-
Notifications
You must be signed in to change notification settings - Fork 0
/
chmodown.sh
executable file
·43 lines (41 loc) · 957 Bytes
/
chmodown.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
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# if argument empty - set current folder
if [ -z "$1" ]
then
set -- $(pwd)
fi
read -r -p "Chose action for $1 in
[M/m] - chmod for all dirs to 775 and for files 664
[O/o] - chown $USER:www-data
[Y/y] - both chmod + chown
[N/n] - Cancel
" input
case $input in
[yY])
echo "chown $USER:www-data "$1
sudo chown -R $USER:www-data $1
echo "chmod directories 775"
sudo find $1/. -type d -exec chmod 775 {} \;
echo "chmod files 664"
sudo find $1/. -type f -exec chmod 664 {} \;
echo "chown and chmod - DONE for $1"
;;
[mM])
echo "chmod directories 775"
sudo find $1/. -type d -exec chmod 775 {} \;
echo "chmod files 664"
sudo find $1/. -type f -exec chmod 664 {} \;
echo "chmod - DONE for $1"
;;
[oO])
echo "chown $USER:www-data "$1
sudo chown -R $USER:www-data $1
echo "chown - DONE for $1"
;;
[nN])
echo "Operation Canceled. Permissions and owners don't changed for $1"
;;
*)
echo "Invalid input..."
;;
esac