-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-scan.sh
More file actions
executable file
·68 lines (59 loc) · 1.51 KB
/
Copy pathwp-scan.sh
File metadata and controls
executable file
·68 lines (59 loc) · 1.51 KB
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
#!/bin/bash
# WordPress Cleaner Script by lmt.ca
SITE_DIR=$1
URL=$2
STORAGE_DIR=$3/$URL
DATE=`date +%F`
SITE_BACKUP=$STORAGE_DIR/$URL-$DATE.tar
flight_check () {
if ! [ -x "$(command -v wp)" ]; then
# need fall back for wp to mysql db maybe?
echo "- wp-cli not installed can't continue"
exit
fi
}
help () {
echo "wp-scan.sh <site directory> <url> <storage directory>"
exit
}
directories () {
if [ ! -d $SITE_DIR ]; then
echo "- Site directory doesn't exist"
exit
fi
if [ ! -d $STORAGE_DIR ]; then
echo "- Report directory doesn't exist...creating"
mkdir $STORAGE_DIR
fi
}
backup () {
if [ ! -f $SITE_BACKUP ]; then
echo "- Backing up site files..."
tar -cf $SITE_BACKUP $SITE_DIR
#for the future, progress bar
#tar cf $SITE_BACKUP $SITE_DIR -P | pv -s $(du -sb $SITE_DIR | awk '{print $1}') | gzip > $SITE_BACKUP
else
echo "- Backup already exists for $SITE_BACKUP...exiting"
exit
fi
}
modified_files () {
echo "- Generating modified-time log..."
find $SITE_DIR -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r > $STORAGE_DIR/$URL-$DATE-modified-time.log
}
active_plugins () {
echo "- Generating active plugins log..."
wp --path=$SITE_DIR plugin list > ~/$STORAGE_DIR/$URL-$DATE-wp-plugin-list.log
}
if [ -z $SITE_DIR ]; then
help
elif [ -z $URL ]; then
help
elif [ -z $STORAGE_DIR ]; then
help
fi
flight_check
directories
backup
modified_files
active_plugins