-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix.sh
executable file
·66 lines (54 loc) · 1.58 KB
/
fix.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
#!/bin/bash
#
# Script to apply multiple actions from .sh files in order to
# remove and fix various bugs on the current SamuraiWTF version,
# until the next version is released.
#
# NOTE: Run this script with root privileges using "sudo".
#
# Author: Raul Siles (raul _AT_ taddong _DOT_ com) - Taddong
# Date: September 11, 2012
# Version: 0.1
#
VERSION="0.1"
FIXES_ALREADY_APPLIED_LOG=".fixes_already_applied.log"
DIR="./fixes"
PREFIX="fix_"
echo
echo "This script fixes multiple bugs in the current SamuraiWTF 2.0 version."
echo
echo "Remember to run this script using sudo!"
echo "Press any key to continue..."
read KEY
# Go through the DIR directory and apply all fixes that have not
# been applied yet in previous executions of this same script.
cd $DIR
for i in $(ls $PREFIX*)
do
# Check if the fix has been previously applied.
# If so, do not apply it again.
echo -n $i
# Check if log file already exists, and create it if does not
if [ ! -f $FIXES_ALREADY_APPLIED_LOG ]; then
touch $FIXES_ALREADY_APPLIED_LOG
fi
# If 0 fix has been applied before
# If 1 fix has not been applied before (fix string not found)
grep -q $i $FIXES_ALREADY_APPLIED_LOG >/dev/null 2>&1
CHECK=$(echo $?)
if [ $CHECK -eq 1 ]; then
# Record the fix name in the already applied fixes log file
echo $i >> $FIXES_ALREADY_APPLIED_LOG
# Status
echo " (applying fix...)"
# Executing fix file
sudo ./$i
elif [ $CHECK -eq 0 ]; then
#Status
echo " (fix already applied)"
else
# Error - Eg. CHECK == 2
echo " ()"
echo "*** Unexpected error ($CHECK)"
fi
done