-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
76 lines (67 loc) · 2.41 KB
/
setup.sh
File metadata and controls
76 lines (67 loc) · 2.41 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
69
70
71
72
73
74
75
76
#!/bin/bash
WARNING='\033[0;91m'
HIGHLIGHT='\033[0;93m'
INFO='\033[0;36m'
NC='\033[0m' # No Color
current_dir=$(pwd)
repo_dir=$(dirname "${BASH_SOURCE[0]}")
printf "${HIGHLIGHT}This script MUST be run from within the cloned repository's directory.${NC}\n"
sleep 2s
if [ "$current_dir" != "$repo_dir" ]; then
while true; do
printf "${HIGHLIGHT}%s${NC}${WARNING}%s${NC}\n" "DIRECTORY SCRIPT IS RUNNING FROM: " "$current_dir"
sleep 1s
printf "${WARNING}%s${NC}\n" "CHECK ABOVE TO ENSURE YOU ARE RUNNING THIS SCRIPT IN THE CORRECT DIRECTORY."
sleep 1s
read -rp "$(echo -e "\n${HIGHLIGHT}Is ${WARNING}$current_dir${HIGHLIGHT} the correct directory you cloned the PentestonBash repository to?\nType [Y] to continue with setup, or [N] to exit.\n${WARNING}[Y/n]: ${NC}")" yn
case $yn in
[Yy]*)
printf "${INFO}Installing PentestonBash plugin...${NC}\n"
break
;;
[Nn]*)
printf "${WARNING}This script must be run from the cloned repository directory.${NC}\n"
printf "${INFO}Change to the repository's directory before attempting to run this setup.sh script again.${NC}\n"
exit 1
break
;;
*)
printf "${WARNING}It's a Y/n question, provide a Y/n answer.${NC}\n"
;;
esac
done
fi
if [ -f "./.pentestonbash" ]; then
cp ./.pentestonbash ~/.pentestonbash
printf "${INFO}File .pentestonbash found. Copying to user's home directory.${NC}\n"
sleep 1s
else
printf "${WARNING}File .pentestonbash not found. Please ensure the repository is cloned correctly and that you are following the plugin's install instructions.${NC}\n" && exit 1
fi
printf "${INFO}Sourcing .pentestonbash in user's .bashrc file...${NC}\n"
# Check if file is already sourced
if grep -q "source ~/.pentestonbash" ~/.bashrc; then
printf "${INFO}File is already sourced. No need to source a second time...${NC}\n"
else
echo -e "\nsource ~/.pentestonbash\n" >> ~/.bashrc
fi
printf "${INFO}Install complete!${NC}\n"
sleep 1s
while true; do
printf "\n"
read -rp "$(echo -e "${HIGHLIGHT}Cleanup and remove the setup.sh script? [Y/n]: ${NC}")" yn
case $yn in
[Yy]*)
printf "${INFO}Removing setup.sh script...${NC}\n"
rm -f setup.sh
break
;;
[Nn]*)
printf "${INFO}Leaving setup.sh script in place. You can run it again to repeat the setup process.${NC}\n"
break
;;
*)
printf "${WARNING}It's a Y/n question, provide a Y/n answer.${NC}\n"
;;
esac
done