Skip to content

Commit 118d186

Browse files
committed
helpers: add apache-set-user script
1 parent 958e619 commit 118d186

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env sh
2+
3+
4+
set -e
5+
6+
7+
arg=${1}
8+
9+
10+
if [ $# -ne 1 ]; then
11+
(>&2 echo "Usage:\n user[:group]")
12+
exit 1
13+
fi
14+
15+
if [ $(echo "${arg}" | grep ":") ]; then
16+
user="$(echo "${arg}" | cut -d: -f1)"
17+
group="$(echo "${arg}" | cut -d: -f2-)"
18+
else
19+
user="${arg}"
20+
group=$(id -gn "${user}")
21+
fi
22+
23+
24+
sed -i "s|User apache|User ${user}|" /etc/apache2/httpd.conf
25+
sed -i "s|Group apache|Group ${group}|" /etc/apache2/httpd.conf

0 commit comments

Comments
 (0)