-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrmsite.sh
executable file
·79 lines (68 loc) · 1.88 KB
/
rmsite.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
# Removes the site
# Copyright (C) 2020-2021 Seiden Group
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -euo pipefail
if [ -x /QOpenSys/pkgs/lib/siteadd/libsiteadd.sh ]; then
. /QOpenSys/pkgs/lib/siteadd/libsiteadd.sh --source-only
else
. ./libsiteadd.sh --source-only
fi
usage() {
echo "Usage: $0 [-r] site_name"
echo ""
echo "Removes a site entry, and optionally deletes its files."
echo ""
echo "Options:"
echo " -r: Delete the files too."
exit 255
}
# before anything could use i.e. M4
check_packages
DELETE_FILES=no
while getopts "r" o; do
case "${o}" in
"r")
DELETE_FILES=yes
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ "$#" -lt "1" ]; then
error_msg "Need a site name."
exit 1
fi
SITE_NAME=$1
PF_MEMBER="/QSYS.LIB/QUSRSYS.LIB/QATMHINSTC.FILE/$SITE_NAME.MBR"
# PHP conf is under here too
APACHEDIR="/www/$SITE_NAME/"
# Maybe check for PFM too, but could break -r
if [ ! -d "$APACHEDIR" ]; then
error_msg "The site directory doesn't exist."
exit 2
fi
banner_msg "Ending..."
# this is || true in case the server isn't running already
system ENDTCPSVR "SERVER(*HTTP)" "HTTPSVR($SITE_NAME)" || true
banner_msg "Deleting member..."
rm "$PF_MEMBER"
if [ "$DELETE_FILES" = "yes" ]; then
banner_msg "Deleting files..."
rm -rf "$APACHEDIR"
fi
banner_msg "Done."