|
@@ -1,11 +1,11 @@
|
1
|
1
|
#!/bin/sh
|
2
|
2
|
|
3
|
|
-BASE_DIR=$(dirname "`readlink -f "$0"`")
|
4
|
|
-PYTHONPATH=$BASE_DIR
|
|
3
|
+BASE_DIR="$(dirname -- "`readlink -f -- "$0"`")"
|
|
4
|
+PYTHONPATH="$BASE_DIR"
|
5
|
5
|
SEARX_DIR="$BASE_DIR/searx"
|
6
|
|
-ACTION=$1
|
|
6
|
+ACTION="$1"
|
7
|
7
|
|
8
|
|
-cd "$BASE_DIR"
|
|
8
|
+cd -- "$BASE_DIR"
|
9
|
9
|
|
10
|
10
|
update_packages() {
|
11
|
11
|
pip install --upgrade pip
|
|
@@ -24,12 +24,12 @@ install_geckodriver() {
|
24
|
24
|
set -e
|
25
|
25
|
geckodriver -V > /dev/null 2>&1 || NOTFOUND=1
|
26
|
26
|
set +e
|
27
|
|
- if [ -z $NOTFOUND ]; then
|
|
27
|
+ if [ -z "$NOTFOUND" ]; then
|
28
|
28
|
return
|
29
|
29
|
fi
|
30
|
30
|
GECKODRIVER_VERSION="v0.18.0"
|
31
|
|
- PLATFORM=`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`
|
32
|
|
- case $PLATFORM in
|
|
31
|
+ PLATFORM="`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`"
|
|
32
|
+ case "$PLATFORM" in
|
33
|
33
|
"linux 32bit" | "linux2 32bit") ARCH="linux32";;
|
34
|
34
|
"linux 64bit" | "linux2 64bit") ARCH="linux64";;
|
35
|
35
|
"windows 32 bit") ARCH="win32";;
|
|
@@ -47,15 +47,15 @@ install_geckodriver() {
|
47
|
47
|
fi
|
48
|
48
|
else
|
49
|
49
|
GECKODRIVER_DIR="$1"
|
50
|
|
- mkdir -p "$GECKODRIVER_DIR"
|
|
50
|
+ mkdir -p -- "$GECKODRIVER_DIR"
|
51
|
51
|
fi
|
52
|
52
|
|
53
|
53
|
echo "Installing $GECKODRIVER_DIR/geckodriver from\n $GECKODRIVER_URL"
|
54
|
54
|
|
55
|
|
- FILE=`mktemp`
|
56
|
|
- wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C "$GECKODRIVER_DIR" -f $FILE geckodriver
|
57
|
|
- rm $FILE
|
58
|
|
- chmod 777 "$GECKODRIVER_DIR/geckodriver"
|
|
55
|
+ FILE="`mktemp`"
|
|
56
|
+ wget -qO "$FILE" -- "$GECKODRIVER_URL" && tar xz -C "$GECKODRIVER_DIR" -f "$FILE" geckodriver
|
|
57
|
+ rm -- "$FILE"
|
|
58
|
+ chmod 777 -- "$GECKODRIVER_DIR/geckodriver"
|
59
|
59
|
}
|
60
|
60
|
|
61
|
61
|
pep8_check() {
|
|
@@ -73,14 +73,14 @@ unit_tests() {
|
73
|
73
|
|
74
|
74
|
py_test_coverage() {
|
75
|
75
|
echo '[!] Running python test coverage'
|
76
|
|
- PYTHONPATH=`pwd` python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \
|
|
76
|
+ PYTHONPATH="`pwd`" python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \
|
77
|
77
|
&& coverage report \
|
78
|
78
|
&& coverage html
|
79
|
79
|
}
|
80
|
80
|
|
81
|
81
|
robot_tests() {
|
82
|
82
|
echo '[!] Running robot tests'
|
83
|
|
- PYTHONPATH=`pwd` python "$SEARX_DIR/testing.py" robot
|
|
83
|
+ PYTHONPATH="`pwd`" python "$SEARX_DIR/testing.py" robot
|
84
|
84
|
}
|
85
|
85
|
|
86
|
86
|
tests() {
|
|
@@ -113,11 +113,11 @@ styles() {
|
113
|
113
|
|
114
|
114
|
npm_packages() {
|
115
|
115
|
echo '[!] install NPM packages for oscar theme'
|
116
|
|
- cd $BASE_DIR/searx/static/themes/oscar
|
|
116
|
+ cd -- "$BASE_DIR/searx/static/themes/oscar"
|
117
|
117
|
npm install
|
118
|
118
|
|
119
|
119
|
echo '[!] install NPM packages for simple theme'
|
120
|
|
- cd $BASE_DIR/searx/static/themes/simple
|
|
120
|
+ cd -- "$BASE_DIR/searx/static/themes/simple"
|
121
|
121
|
npm install
|
122
|
122
|
}
|
123
|
123
|
|
|
@@ -133,7 +133,7 @@ locales() {
|
133
|
133
|
}
|
134
|
134
|
|
135
|
135
|
help() {
|
136
|
|
- [ -z "$1" ] || printf "Error: $1\n"
|
|
136
|
+ [ -z "$1" ] || printf 'Error: %s\n' "$1"
|
137
|
137
|
echo "Searx manage.sh help
|
138
|
138
|
|
139
|
139
|
Commands
|
|
@@ -156,4 +156,4 @@ Commands
|
156
|
156
|
|
157
|
157
|
[ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
|
158
|
158
|
&& help "action not found" \
|
159
|
|
- || $ACTION "$2"
|
|
159
|
+ || "$ACTION" "$2"
|