]>
Commit | Line | Data |
---|---|---|
e9689537 ER |
1 | #!/bin/sh |
2 | webapps=/etc/webapps | |
3 | action="$1" | |
f21ce9bd | 4 | httpd="$2" |
e9689537 ER |
5 | app="$3" |
6 | ||
7 | webapp_register() { | |
5ec58d25 | 8 | ln -sf $webapps/$app/$httpd.conf /etc/$httpd/webapps.d/$app.conf |
e9689537 ER |
9 | } |
10 | ||
11 | webapp_unregister() { | |
5ec58d25 | 12 | rm -f /etc/$httpd/webapps.d/$app.conf |
e9689537 ER |
13 | } |
14 | ||
15 | usage() { | |
16 | cat >&2 <<EOF | |
f21ce9bd ER |
17 | Usage: $0 register httpd webapp |
18 | Usage: $0 unregister httpd webapp | |
19 | ||
a715016d | 20 | Where httpd is one of the webservers |
f21ce9bd ER |
21 | apache 1.x: apache |
22 | apache 2.x: httpd | |
23 | lighttpd: lighttpd | |
e9689537 ER |
24 | EOF |
25 | } | |
26 | ||
a715016d ER |
27 | die() { |
28 | echo >&2 "$0: $*" | |
29 | exit 1 | |
30 | } | |
31 | ||
32 | checkconfig() { | |
33 | # sanity check | |
34 | if [ ! -d "$webapps/$app" ]; then | |
35 | die "Missing directory: $webapps/$app" | |
36 | fi | |
5ec58d25 ER |
37 | if [ ! -d "/etc/$httpd/webapps.d" ]; then |
38 | die "Missing directory: /etc/$httpd/webapps.d" | |
a715016d ER |
39 | fi |
40 | } | |
41 | ||
e9689537 ER |
42 | case "$action" in |
43 | register) | |
a715016d | 44 | checkconfig |
d91deb44 | 45 | webapp_register |
e9689537 ER |
46 | ;; |
47 | unregister) | |
a715016d | 48 | checkconfig |
d91deb44 | 49 | webapp_unregister |
e9689537 ER |
50 | ;; |
51 | *) | |
52 | usage | |
53 | exit 1 | |
54 | esac |