-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsudo-wrapper
More file actions
39 lines (34 loc) · 756 Bytes
/
Copy pathsudo-wrapper
File metadata and controls
39 lines (34 loc) · 756 Bytes
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
#!/bin/bash
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
output_file=""
verbose=0
user=root
special=
while [ $# -ge 1 ] ; do
case "$1" in
-l) special=true ; shift ;;
-u|-iu)
case "$2" in
"") user='root' ; shift 2 ;;
*) user=$2 ; shift 2 ;;
esac ;;
-g)
case "$2" in
"") group='root' ; shift 2 ;;
*) group=$2 ; shift 2 ;;
esac ;;
-A|-b|-E|-H|-n|-P|-S) shift ;;
-C|-p|-r|-t) shift 2 ;;
*) break;
esac
done
if [ ! -z "${user:-}" ] && [ ! -z "${group:-}" ] ; then
usergroup="$user:$group"
else
usergroup="$user"
fi
if [ -z "${special:-}" ] ; then
/bin/gosu $usergroup "$@"
fi