-
Notifications
You must be signed in to change notification settings - Fork 448
/
setup.sh
executable file
·76 lines (67 loc) · 2.41 KB
/
setup.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
#!/bin/bash
CURRENT_WHATWAF_VERSION=$(cat ./lib/settings.py | grep 'VERSION = ' | cut -d' ' -f 3 | cut -d'"' -f 2)
function helpPage {
echo -e "\n./setup.sh {install|remove}\n";
}
function banner {
echo -e " ,------. ";
echo -e " ' .--. ' ";
echo -e " ,--. .--. ,--. .--.| | | | ";
echo -e " | | | | | | | |'--' | | ";
echo -e " | | | | | | | | __. | ";
echo -e " | |.'.| | | |.'.| | | .' ";
echo -e " | | | | |___| ";
echo -e " | ,'. |hat| ,'. |af .---. ";
echo -e " '--' '--' '--' '--' '---' ";
echo -e "\"/><sCRIPT>ALeRt(\\\"WhatWaf?<|>v$CURRENT_WHATWAF_VERSION\\\");</scRiPT>";
}
function install {
home="$HOME/.whatwaf";
exec_dir="$home/.install/bin";
exec_filename="$exec_dir/whatwaf"
copy_dir="$home/.install/etc";
mkdir $home;
mkdir $home/.install
mkdir $exec_dir;
mkdir $copy_dir;
chmod +x ./trigger.py
echo "copying files over..";
rsync -drq . $copy_dir
echo "creating executable";
cat << EOF > $exec_filename
#!/bin/bash
# this is the execution script for whatwaf
# created by the whatwaf installer on $(date +%F)
# this execution script was designed with version $CURRENT_WHATWAF_VERSION
# installation. If you have any issues with this execution script or this
# installation please report them here: https://github.com/Ekultek/WhatWaf/issues/new
cd $copy_dir
exec python whatwaf.py \$@
EOF
echo "editing file stats";
chmod +x $exec_filename;
echo "export PATH=\"$PATH:$exec_dir\"" >> $HOME/.bash_profile;
echo "installed, you need to run: source ~/.bash_profile if you notice that the installation does not work as expected";
}
function uninstall {
rm -rf ~/.trigger
echo "home directory removed, manually remove the export PATH pertaining to $HOME/.whatwaf/bin"
}
function main {
echo "deprecated in favor of setup.py (USAGE: python setup.py install) this script will be removed by version 3.0";
echo "to continue with this type of installation press enter, otherwise CNTRL-C";
read;
banner;
if [[ "$1" == "install" ]]; then
echo -e " Installing:";
install;
echo -e "Successfully installed WhatWaf v$CURRENT_WHATWAF_VERSION";
elif [[ "$1" == "remove" ]]; then
echo -e " Uninstalling:";
uninstall;
echo -e "Successfully uninstalled WhatWaf";
else
helpPage;
fi;
}
main $@;