forked from trimstray/multitor
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·85 lines (55 loc) · 2.67 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·85 lines (55 loc) · 2.67 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
#!/usr/bin/env bash
readonly _dir="$(dirname "$(readlink -f "$0")")"
# shellcheck disable=SC2034
_arg="$1"
if [[ "$1" == "install" ]] ; then
printf "%s\\n" "Create symbolic link to /usr/local/bin"
if [[ -e "${_dir}/bin/multitor" ]] ; then
if [[ ! -e "/usr/local/bin/multitor" ]] ; then
ln -s "${_dir}/bin/multitor" /usr/local/bin
fi
fi
printf "%s\\n" "Create man page to /usr/local/man/man8"
if [[ -e "${_dir}/static/man8/multitor.8" ]] ; then
if [[ ! -e "/usr/local/man/man8/multitor.8.gz" ]] ; then
mkdir -p /usr/local/man/man8
cp "${_dir}/static/man8/multitor.8" /usr/local/man/man8
gzip /usr/local/man/man8/multitor.8
fi
fi
# Install Python dependencies for custom_lb
printf "\\n%s\\n" "Checking and installing Python dependencies (requests, pysocks)..."
if command -v apt-get &> /dev/null; then
if dpkg -s python3-requests &> /dev/null && dpkg -s python3-pysocks &> /dev/null && dpkg -s tor &> /dev/null; then
printf "%s\\n" "Python and Tor dependencies already satisfied."
else
printf "%s\\n" "Attempting to install tor, python3-requests, and python3-pysocks..."
# Run update once
apt-get update -qq
if apt-get install -y tor python3-requests python3-pysocks; then
printf "%s\\n" "Successfully installed tor, python3-requests, and python3-pysocks."
elif apt-get install -y tor python3-requests python3-socks; then
printf "%s\\n" "Successfully installed tor, python3-requests, and python3-socks (used python3-socks as fallback for python3-pysocks)."
else
printf "%s\\n" "WARNING: Failed to install some dependencies (tor, python3-requests, python3-pysocks/python3-socks). Required features may not work."
printf "%s\\n" "Please try installing them manually (e.g., sudo apt-get install tor python3-requests python3-pysocks or python3-socks)."
fi
fi
else
printf "%s\\n" "WARNING: 'apt-get' not found. Cannot automatically install Python dependencies."
printf "%s\\n" "Please ensure 'python3-requests' and 'python3-pysocks' (or 'python3-socks') are installed for custom_lb functionality."
fi
printf "%s\\n" "--------------------------------------------------------------------"
elif [[ "$1" == "uninstall" ]] ; then
printf "%s\\n" "Remove symbolic link from /usr/local/bin"
if [[ -L "/usr/local/bin/multitor" ]] ; then
unlink /usr/local/bin/multitor
fi
printf "%s\\n" "Remove man page from /usr/local/man/man8"
if [[ -e "/usr/local/man/man8/multitor.8.gz" ]] ; then
rm /usr/local/man/man8/multitor.8.gz
fi
else
printf "Usage:\\n ./setup.sh install (Install)\\n ./setup.sh uninstall (Uninstall)\\n"
fi
exit 0