-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfixowner.sh
More file actions
executable file
·22 lines (21 loc) · 801 Bytes
/
fixowner.sh
File metadata and controls
executable file
·22 lines (21 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# +----+----+----+----+
# | | | | |
# Author: Mark David Scott Cunningham | M | D | S | C |
# +----+----+----+----+
# Created: 2013-11-08
# Updated: 2014-04-27
#
#
#!/bin/bash
_fixowner(){
U=$(pwd | sed 's:^/chroot::' | cut -d/ -f3)
if [[ -z $2 ]]; then P='.'; else P=$2; fi
case $1 in
-u|--user) owner="$U:$U" ;;
-a|--apache) owner="apache:$U" ;;
-r|--root) owner="root:root" ;;
*|-h|--help) echo -e "\n Usage: fixowner [option] [path]\n -u | --user ..... Change ownership to $U:$U\n -a | --apache ... Change ownership to apache:$U\n -r | --root ..... Change ownership to root:root\n -h | --help ..... Show this help output\n"; return 0 ;;
esac
chown -R $owner $P && echo -e "\n Files owned to $owner\n"
}
_fixowner "$@"