-
Notifications
You must be signed in to change notification settings - Fork 0
/
ngxensite
executable file
·62 lines (55 loc) · 2 KB
/
ngxensite
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
#!/usr/bin/env bash
SCRIPT_NAME="ngxensite"
INSTALL_PATH="/usr/local/bin/$SCRIPT_NAME"
REMOTE_URL="https://raw.githubusercontent.com/mnofresno/git-status-checker/master/bin/ngx/ngxensite"
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-available"
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-available"
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-available"
exit 0
fi
}
detect_run_mode "$1"
if [ -z "$1" ]; then
echo "Please choose a site."
exit 1
else
echo "Enabling site $1..."
if [ -h "/etc/nginx/sites-enabled/$1" ] || [ -f "/etc/nginx/sites-enabled/$1" ]; then
echo "$1 is already enabled."
exit 1
else
if [ ! -f "/etc/nginx/sites-available/$1" ]; then
echo "Site $1 does not exist in /etc/nginx/sites-available."
exit 1
else
ln -s /etc/nginx/sites-available/$1 /etc/nginx/sites-enabled/$1
echo "Enabled $1"
reload_nginx
exit 0
fi
fi
fi