-
Notifications
You must be signed in to change notification settings - Fork 1
/
nbz.sh
executable file
·131 lines (118 loc) · 2.64 KB
/
nbz.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
#
# Author: <Zurdi>
# NBZ Launcher
function show_help {
echo "NBZ v1.0 - (C) 2017-2019 Zurdi Zurdo"
echo "Released under the GNU GLP"
echo ""
echo "NBZ is a tool to automate navigation and data extraction on the internet."
echo "It is configured by little scripts coded with nbz-script language. You can find the"
echo "documentation in the github wiki: https://github.com/zurdi15/nbz/wiki"
echo ""
echo "-h Show this help"
echo "-v Show the version"
echo "-s Set the .nbz script"
echo "-p Set the script parameters"
echo "-x Enable screen emulation (server) / hide browser screen (desktop)"
echo "-r Set custom resolution for screen emulation"
echo "-P Enable proxy"
echo "-d Enable debug mode"
}
function show_version {
echo "NBZ v1.0"
}
# - Parameters
script=""
display="false"
proxy="false"
debug="false"
resolution="default"
if [ ${#} = 0 ]; then
show_help
exit 0
else
while getopts "hvs:p:xr:Pd" opt
do
case ${opt} in
h)
show_help
exit 0
;;
v)
show_version
exit 0
;;
s)
ext=${OPTARG##*.}
if [ ${ext} = "nbz" ]
then
script=${OPTARG} >&2
else
echo "Error: Not compatible script (.${ext}). Extension must be .nbz"
exit 1
fi
;;
p)
if [ -z "$script_parameters" ]; then
script_parameters=("${OPTARG}")
else
script_parameters+=("${OPTARG}")
fi
;;
x)
display="true" >&2
;;
r)
resolution=${OPTARG}
;;
P)
proxy="true" >&2
;;
d)
debug="true" >&2
;;
\?)
echo "Error: invalid option -${OPTARG}" >&2
exit 1
;;
:)
echo "Error: option -${OPTARG} requires an argument" >&2
exit 1
;;
esac
done
shift $((OPTIND -1))
fi
if [ -z ${script} ]; then
echo "Error: Script required."
exit 1
else
if [ ! -f ${script} ]; then
echo -e "Error: script \"${script}\" does not exist."
exit 1
fi
fi
if [[ -z ${script_parameters[@]} ]]; then
script_parameters=""
fi
if [ -h "${BASH_SOURCE[0]}" ];then
NBZ_PATH="$(dirname "$(readlink -f "$0")")"
else
NBZ_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
PYTHON3=$(which python3)
YELLOW='\e[33m'; RED='\e[31m'; NC='\e[0m'
if [ -z "${PYTHON3}" ]; then
echo -e "${RED}NBZ - Error: Python 3 is not installed. Please install it in your system.${NC}"
exit 1
fi
# - Launch NBZ
TOILET=$(which toilet)
if [ -z "${TOILET}" ]; then
header=""
else
header=$(toilet -t -f mono12 -F gay " NBZ ")
fi
echo -e "${header}"
python3 -W ignore ${NBZ_PATH}/src/nbz_interface.py -script ${script} -script_parameters "${script_parameters[@]}" -display ${display} -proxy ${proxy} -resolution ${resolution} -debug ${debug}