-
Notifications
You must be signed in to change notification settings - Fork 0
/
ngxdissite
executable file
·57 lines (50 loc) · 1.78 KB
/
ngxdissite
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
#!/usr/bin/env bash
SCRIPT_NAME="ngxdissite"
INSTALL_PATH="/usr/local/bin/$SCRIPT_NAME"
REMOTE_URL="https://raw.githubusercontent.com/mnofresno/git-status-checker/master/bin/ngx/ngxdissite"
COMMON_LIB_PATH="/usr/local/lib/ngx_common.sh"
COMMON_LIB_URL="https://raw.githubusercontent.com/mnofresno/git-status-checker/master/bin/ngx/ngx_common.sh"
if [ ! -f "$COMMON_LIB_PATH" ]; then
echo "Downloading ngx_common.sh..."
curl -s "$COMMON_LIB_URL" -o "$COMMON_LIB_PATH"
chmod +x "$COMMON_LIB_PATH"
fi
source "$COMMON_LIB_PATH"
check_root $SCRIPT_NAME
detect_run_mode() {
if [ -t 0 ]; then
echo "Running manually..."
if [ "$1" == "--install" ]; then
install_script "$SCRIPT_NAME" "$INSTALL_PATH" "$REMOTE_URL"
generate_autocomplete "$SCRIPT_NAME" "/etc/nginx/sites-enabled"
echo "Installation and autocompletion setup complete."
exit 0
elif [ "$1" == "--upgrade" ]; then
upgrade_script "$SCRIPT_NAME" "$INSTALL_PATH" "$REMOTE_URL"
generate_autocomplete "$SCRIPT_NAME" "/etc/nginx/sites-enabled"
echo "Upgrade and autocompletion setup complete."
exit 0
fi
else
echo "Running via curl... Installing $SCRIPT_NAME."
install_script "$SCRIPT_NAME" "$INSTALL_PATH" "$REMOTE_URL"
generate_autocomplete "$SCRIPT_NAME" "/etc/nginx/sites-enabled"
exit 0
fi
}
detect_run_mode "$1"
if [ -z "$1" ]; then
echo "Please choose a site."
exit 1
else
echo "Disabling site $1..."
if [ ! -h "/etc/nginx/sites-enabled/$1" ] && [ ! -f "/etc/nginx/sites-enabled/$1" ]; then
echo "$1 is not enabled."
exit 1
else
rm "/etc/nginx/sites-enabled/$1"
echo "Disabled $1"
reload_nginx
exit 0
fi
fi