-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwpst.sh
executable file
·86 lines (75 loc) · 2.11 KB
/
wpst.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
80
81
82
83
84
85
86
#!/bin/bash
# --------------------------
# Lazy way to provide help and a wrapper to related tools.
# -------------------------
# Get current script directory
SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )"
WPST_VERSION="$(cat ${SCRIPT_DIR}/VERSION)"
SCRIPT_NAME="wpst"
GITHUB_URL="https://raw.githubusercontent.com/managingwp/wp-shelltools/main/"
source $SCRIPT_DIR/lib/functions.sh # Core Functions
source $SCRIPT_DIR/lib/functions-gp.sh # GP Functions
# ------------
# -- Variables
# ------------
GP_CMDS=$(wpst_gp_cmds)
# -- USAGE
USAGE=\
"WordPress Shell Tools - $WPST_VERSION - $SCRIPT_DIR
Commands:
wpst goaccess - Run goaccess on web server logs
wpst sql - Run common WordPress SQL Commands
wpst help - This help.
wpst attackscan - Run attackscan.sh
wpst ajaxlog - Place ajaxlog.php in wp-content/mu-plugins to log ajax requests
wpst dir - Change to wpst directory
GP Commands:
$GP_CMDS
Core Commands:
wpst check-update - Check for updates
"
# -- usage
usage () {
echo "$USAGE"
}
# ------------
# -- Main Loop
# ------------
ACTION="$1"
if [[ ! $ACTION ]]; then
usage
exit 1
elif [[ $ACTION = "help" ]]; then
usage
exit
elif [[ $ACTION = "goaccess" ]]; then
$SCRIPT_DIR/bin/wpst-goaccess.sh $@
exit
elif [[ $ACTION = "sql" ]]; then
$SCRIPT_DIR/bin/sql.sh $@
exit
elif [[ $ACTION = "attackscan" ]]; then
$SCRIPT_DIR/bin/attackscan.sh $@
exit
elif [[ $ACTION = "dir" ]]; then
echo "Changing to $SCRIPT_DIR"
cd "${SCRIPT_DIR}"
exit
elif [[ $ACTION = "ajaxlog" ]]; then
echo "Downloading ajaxlog.php to current directory"
# -- Get current working directory and check for mu-plugins
if [[ "$(basename "$PWD")" == "mu-plugins" ]]; then
curl -s https://raw.githubusercontent.com/managingwp/wordpress-code-snippets/main/ajaxlog/ajaxlog.php > ajaxlog.php
else
echo "Current directory is not mu-plugins"
exit 1
fi
# GP Commands
elif [[ $ACTION = gp-* ]]; then
cmd_$@
elif [[ $ACTION = "check-update" ]]; then
wpst_check_update
else
usage
exit 1
fi