Repository navigation
Expand file tree
/
Copy pathSetup.sh
More file actions
228 lines (193 loc) · 8.01 KB
/
Copy pathSetup.sh
File metadata and controls
228 lines (193 loc) · 8.01 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/usr/bin/env bash
set -uo pipefail
ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
RUN_SETTINGS=1
REQUIRED_ONLY=0
SKIP_SYSTEM_UPDATE=0
show_help() {
cat <<'HELP'
Usage: bash Setup.sh [options]
Supported platforms:
- Termux (Android)
- Ubuntu
- Kali Linux
- Linux Mint
- Other Debian/Ubuntu-family systems with apt-get (best effort)
Options:
--run Start the DedSec menu after setup (default).
--no-run, --update-only Install/update dependencies without opening the menu.
--required-only Install only the core runtime.
--skip-system-update Skip apt/pkg repository refresh and OS package upgrade.
--skip-repository-refresh Same as --skip-system-update.
-h, --help Show this help message.
Notes:
Desktop Linux uses a project-local .venv so distro-managed Python is not modified.
Termux keeps the project's original Termux-native dependency installer.
HELP
}
for arg in "$@"; do
case "$arg" in
--run) RUN_SETTINGS=1 ;;
--no-run|--update-only) RUN_SETTINGS=0 ;;
--required-only) REQUIRED_ONLY=1 ;;
--skip-system-update|--skip-repository-refresh) SKIP_SYSTEM_UPDATE=1 ;;
-h|--help) show_help; exit 0 ;;
*) printf '[error] Unknown option: %s\n\n' "$arg" >&2; show_help >&2; exit 2 ;;
esac
done
is_termux() {
[ -n "${TERMUX_VERSION:-}" ] || [ -x /data/data/com.termux/files/usr/bin/pkg ] || [[ "${PREFIX:-}" == *com.termux* ]]
}
# First-install legal approval is mandatory; declining has no setup side effects.
# shellcheck source=Compat/legal_consent.sh
source "$ROOT_DIR/Compat/legal_consent.sh"
dedsec_require_legal_acceptance || exit 1
# Preserve the mature Termux setup path unchanged.
if is_termux; then
args=()
[ "$RUN_SETTINGS" -eq 0 ] && args+=(--no-run)
[ "$REQUIRED_ONLY" -eq 1 ] && args+=(--required-only)
[ "$SKIP_SYSTEM_UPDATE" -eq 1 ] && args+=(--skip-system-update)
exec bash "$ROOT_DIR/Setup-Termux.sh" "${args[@]}"
fi
if ! command -v apt-get >/dev/null 2>&1; then
echo '[error] Desktop setup currently requires an apt-get based Linux distribution.' >&2
echo '[error] Supported desktop targets are Ubuntu, Kali Linux, and Linux Mint.' >&2
exit 1
fi
OS_ID='linux'
OS_NAME='Linux'
OS_LIKE=''
if [ -r /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
OS_ID="${ID:-linux}"
OS_NAME="${PRETTY_NAME:-${NAME:-Linux}}"
OS_LIKE="${ID_LIKE:-}"
fi
case " $OS_ID $OS_LIKE " in
*' ubuntu '*|*' debian '*|*' kali '*|*' linuxmint '*|*' mint '*) ;;
*) echo "[warning] $OS_NAME is not one of the primary tested targets; continuing because apt-get is available." ;;
esac
LOG_DIR="${HOME:-$ROOT_DIR}/.dedsec/logs"
mkdir -p "$LOG_DIR"
LOG_FILE="$LOG_DIR/setup-$(date +%Y%m%d-%H%M%S).log"
if command -v tee >/dev/null 2>&1; then
exec > >(tee -a "$LOG_FILE") 2>&1
fi
printf '[DedSec Setup] Log: %s\n' "$LOG_FILE"
echo "[DedSec Setup] Platform: $OS_NAME"
echo "[DedSec Setup] Project: $ROOT_DIR"
APT=(apt-get)
if [ "$(id -u)" -ne 0 ]; then
if command -v sudo >/dev/null 2>&1; then
APT=(sudo apt-get)
else
echo '[error] sudo is required for OS package installation when not running as root.' >&2
exit 1
fi
fi
apt_install_best_effort() {
local packages=("$@")
[ "${#packages[@]}" -eq 0 ] && return 0
DEBIAN_FRONTEND=noninteractive "${APT[@]}" install -y --no-install-recommends "${packages[@]}" || return 1
}
if [ "$SKIP_SYSTEM_UPDATE" -eq 0 ]; then
echo '[info] Refreshing apt package metadata...'
"${APT[@]}" update || echo '[warning] apt update reported an error; setup will continue.'
echo '[info] Upgrading installed packages...'
DEBIAN_FRONTEND=noninteractive "${APT[@]}" upgrade -y || echo '[warning] apt upgrade reported an error; setup will continue.'
fi
CORE_APT=(
bash ca-certificates curl git wget unzip zip openssl file
python3 python3-venv python3-pip
build-essential pkg-config libffi-dev libssl-dev
libjpeg-dev libpng-dev libxml2-dev libxslt1-dev libfreetype6-dev libcairo2-dev
libncurses-dev
)
OPTIONAL_APT=(
ffmpeg fzf iproute2 net-tools nmap nodejs npm openssh-client tor whois
espeak-ng xdg-utils xclip wl-clipboard libnotify-bin at procps psmisc
dnsutils iputils-ping traceroute avahi-utils snmp samba-common-bin
zsh neovim mpv sox sqlite3 jq ripgrep rsync
)
# Install core in one pass; retry individually so a distro-specific missing package
# does not hide which dependency failed.
echo '[info] Installing core desktop packages...'
if ! apt_install_best_effort "${CORE_APT[@]}"; then
echo '[warning] Bulk core install failed; retrying packages individually.'
for p in "${CORE_APT[@]}"; do
apt_install_best_effort "$p" || { echo "[error] Required package could not be installed: $p" >&2; exit 1; }
done
fi
if [ "$REQUIRED_ONLY" -eq 0 ]; then
echo '[info] Installing optional tool packages (best effort)...'
for p in "${OPTIONAL_APT[@]}"; do
apt_install_best_effort "$p" || echo "[warning] Optional package unavailable: $p"
done
fi
VENV_DIR="$ROOT_DIR/.venv"
if [ ! -x "$VENV_DIR/bin/python" ]; then
echo '[info] Creating project Python virtual environment...'
python3 -m venv "$VENV_DIR"
fi
PYTHON_BIN="$VENV_DIR/bin/python"
# Repair Unicode filenames if an older unzip extracted Greek names as #Uhhhh tokens.
REPAIR_UNICODE="$ROOT_DIR/Compat/repair_unicode_names.py"
if [ -f "$REPAIR_UNICODE" ]; then
"$PYTHON_BIN" "$REPAIR_UNICODE" "$ROOT_DIR" || echo '[warning] Unicode filename repair reported an error; setup will continue.'
fi
"$PYTHON_BIN" -m pip install --upgrade pip setuptools wheel
CORE_PY=(requests urllib3 flask flask-socketio werkzeug jinja2 cryptography qrcode)
TOOL_PY=(
beautifulsoup4 CairoSVG cloudscraper colorama python-dateutil dnspython
python-docx python-dotenv EbookLib ExifRead geopy httpx
Markdown MarkupSafe odfpy paramiko phonenumbers python-nmap python-pptx
psd-tools psutil py7zr pycountry PySocks pytz qrcode rarfile reportlab rich
pypdf
speedtest-cli striprtf tldextract validators websocket-client werkzeug python-whois zxcvbn
cryptography lxml numpy pillow scipy
)
echo '[info] Installing core Python packages into .venv...'
"$PYTHON_BIN" -m pip install --upgrade "${CORE_PY[@]}"
if [ "$REQUIRED_ONLY" -eq 0 ]; then
echo '[info] Installing tool Python packages into .venv...'
for p in "${TOOL_PY[@]}"; do
"$PYTHON_BIN" -m pip install --upgrade "$p" || echo "[warning] Optional Python package unavailable: $p"
done
fi
# Make desktop compatibility shims visible only for launches through Setup.sh/Run.sh.
export PATH="$ROOT_DIR/Compat/bin:$VENV_DIR/bin:$PATH"
export DEDSEC_ROOT="$ROOT_DIR"
export DEDSEC_PLATFORM="desktop-linux"
export DEDSEC_SAFE_CROSS_PLATFORM=1
chmod +x "$ROOT_DIR/Run.sh" "$ROOT_DIR/Compat/bin/"* 2>/dev/null || true
# Basic validation.
"$PYTHON_BIN" - <<'PY'
import importlib
required = ['requests', 'urllib3', 'flask', 'flask_socketio', 'werkzeug', 'jinja2', 'cryptography', 'qrcode']
missing=[]
for name in required:
try: importlib.import_module(name)
except Exception as exc: missing.append((name, str(exc)))
if missing:
for name, err in missing: print(f'[verify] MISSING {name}: {err}')
raise SystemExit(1)
print('[verify] Core Python imports are ready.')
PY
for cmd in bash git curl wget unzip zip openssl; do
command -v "$cmd" >/dev/null 2>&1 || { echo "[error] Required command unavailable: $cmd" >&2; exit 1; }
done
# Apply the saved menu autostart preference on first installation.
# If the profile is not writable, report it without hiding setup success.
"$PYTHON_BIN" "$ROOT_DIR/Scripts/Settings.py" --configure-menu-autostart || \
echo '[warning] Shell autostart needs manual enabling via Settings.'
echo '[complete] Desktop Linux dependencies are ready.'
echo "[note] Python environment: $VENV_DIR"
echo '[note] Android/Termux-only tools are detected and reported as unavailable on desktop rather than crashing.'
echo '[note] Sensitive credential/card/camera/location capture and Trojan tooling are not enabled by the desktop compatibility launcher.'
if [ "$RUN_SETTINGS" -eq 0 ]; then
exit 0
fi
cd "$ROOT_DIR" || exit 1
exec "$PYTHON_BIN" "$ROOT_DIR/Scripts/Settings.py"