Skip to content

Commit 12fecad

Browse files
authored
Merge branch 'openvpn-update' into dependabot/pip/urllib3-2.6.3
2 parents bb2646b + e8cbe91 commit 12fecad

13 files changed

+1508
-563
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ lib/__pycache__/
99
.gitignore
1010
.shellcheckrc
1111
.github
12+
.env
13+
.env.local
14+
.env.*.local
15+
*.key
16+
*.pem

Pipfile.lock

Lines changed: 55 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/convert_to_torbox

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#!/bin/bash
2+
3+
# This file is part of TorBox, an easy to use anonymizing router based on Raspberry Pi.
4+
# Copyright (C) 2025 radio24
5+
# Contact: anonym@torbox.ch
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it is useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
# DESCRIPTION
21+
# THIS SCRIPT IS INTENDED TO BE USED BY THE DEVELOPERS ONLY!
22+
# This script converts a TorBox mini installation to a default TorBox installation.
23+
# Important: This script must be run locally and not via a network connection.
24+
#
25+
# SYNTAX
26+
# sudo bash convert_to_torbox
27+
#
28+
#
29+
##### SET VARIABLES ######
30+
#
31+
# SIZE OF THE MENU
32+
#
33+
#Set the the variables for the menu
34+
MENU_WIDTH=80
35+
MENU_HEIGHT_15=15
36+
37+
#Colors
38+
RED='\033[1;31m'
39+
YELLOW='\033[1;93m'
40+
NOCOLOR='\033[0m'
41+
42+
# What main version is installed
43+
DEBIAN_VERSION=$(sed 's/\..*//' /etc/debian_version)
44+
45+
# Where is the config.txt?
46+
if [ "$DEBIAN_VERSION" -gt "11" ]; then
47+
CONFIGFILE="/boot/firmware/config.txt"
48+
else
49+
CONFIGFILE="/boot/config.txt"
50+
fi
51+
52+
# Where is the cmdline.txt?
53+
if [ "$DEBIAN_VERSION" -gt "11" ]; then
54+
CMDLINEFILE="/boot/firmware/cmdline.txt"
55+
else
56+
CMDLINEFILE="/boot/cmdline.txt"
57+
fi
58+
59+
#Other variables
60+
TORBOX_PATH="/home/torbox/torbox"
61+
RUNFILE="run/torbox.run"
62+
63+
##############################
64+
######## FUNCTIONS ###########
65+
66+
#include lib
67+
. /home/torbox/torbox/lib/torbox.lib
68+
69+
INPUT=$(cat text/convert_to_torbox-text)
70+
if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH); then
71+
cd $TORBOX_PATH
72+
73+
# Reinstalling kernel-headers and dkms
74+
clear
75+
echo -e "${RED}[+] Reinstalling kernel-headers and dkms....${NOCOLOR}"
76+
echo ""
77+
78+
# Fixing and cleaning
79+
echo -e "${RED}[+] Fixing and cleaning${NOCOLOR}"
80+
echo ""
81+
sudo apt --fix-broken install
82+
sudo apt-get -y clean; sudo apt-get -y autoclean; sudo apt-get -y autoremove
83+
go clean -cache
84+
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/obfs4proxy
85+
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@default.service
86+
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@.service
87+
sudo systemctl daemon-reload
88+
89+
# Updating the system
90+
echo -e "${RED}[+] Updating the system...${NOCOLOR}"
91+
echo ""
92+
sudo apt-get -y update
93+
sudo apt-get -y dist-upgrade
94+
sudo apt-get -y clean
95+
sudo apt-get -y autoclean
96+
sudo apt-get -y autoremove
97+
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/obfs4proxy
98+
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@default.service
99+
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@.service
100+
sudo systemctl daemon-reload
101+
102+
# NEW v.0.5.5: This is necessary for installing linux-headers, which replaces raspberrypi-kernel-headers on Debian Trixie
103+
LINUX_HEADERS="linux-headers-$(uname -r)"
104+
sudo apt-get install $LINUX_HEADERS dkms
105+
106+
# Set up WiFi AP (Hostapd) - the files should already be there, but to be sure
107+
sudo cp etc/default/hostapd /etc/default/
108+
sudo cp etc/hostapd/hostapd.conf /etc/hostapd/
109+
110+
# Set up DHCP (Removes the IP Pool for 192.168.44.x)
111+
sudo cp etc/dhcp/dhcpd.conf /etc/dhcp/
112+
sudo cp etc/default/isc-dhcp-server /etc/default/
113+
114+
# Assign the correct IPs for the server and the client (192.168.44.x —> 192.168.42.x) - activated after the reboot
115+
sudo cp etc/network/interfaces /etc/network/
116+
117+
# Set the correct routing for wlan0 and 192.168.42.x - activated after the reboot
118+
sudo cp etc/iptables.ipv4.nat /etc/
119+
120+
# Necessary boot-script to activate etc/iptables.ipv4.nat after the reboot
121+
sudo cp etc/rc.local /etc/
122+
123+
INPUT=$(cat text/convert_to_torbox-question-text)
124+
if (whiptail --title "TorBox - INFO" --yesno --defaultno "$INPUT" $MENU_HEIGHT_20 $MENU_WIDTH); then
125+
if sudo [ ! -e /etc/modprobe.d/brcmfmac.conf ] || sudo [ ! -s /etc/modprobe.d/brcmfmac.conf ]; then
126+
echo "options brcmfmac roamoff=1 feature_disable=0x82000" | sudo tee /etc/modprobe.d/brcmfmac.conf
127+
elif ! grep "options brcmfmac roamoff=1 feature_disable=0x82000" /etc/modprobe.d/brcmfmac.conf ; then
128+
sudo sed -i "s/^options brcmfmac/options brcmfmac roamoff=1 feature_disable=0x82000/g" /etc/modprobe.d/brcmfmac.conf
129+
fi
130+
sudo update-initramfs -u
131+
# In rc.local it is tested if the hostapd interface is up. Only in this case, hostapd will be startet.
132+
# That could lead to problems, if the interface is not up when running the test, for exemple on a slow Raspberry Pi 2 W
133+
if ! grep -qF "(sleep 15; systemctl restart hostapd) &" /etc/rc.local; then
134+
sudo sed -i '/exit 0/i # Added by convert_to_torbox' /etc/rc.local
135+
sudo sed -i '/exit 0/i (sleep 15; systemctl restart hostapd) &' /etc/rc.local
136+
fi
137+
fi
138+
139+
# Setting up the correct runtime variables (used by rc.local)
140+
sudo sed -i "s/^TORBOX_MINI_DEFAULT=.*/TORBOX_MINI_DEFAULT=0/" ${RUNFILE}
141+
sudo sed -i "s/^TORBOX_MINI=.*/TORBOX_MINI=0/" ${RUNFILE}
142+
# Forgot that - could be the reason that it didn’t work (it doesn’t matter if the interfaces are available or not - it will autoconfigure after the reboot and your choices in the main menu)
143+
sudo sed -i "s/^INTERNET_IFACE=.*/INTERNET_IFACE=eth0/" ${RUNFILE}
144+
sudo sed -i "s/^CLIENT_IFACE=.*/CLIENT_IFACE=wlan0 eth1/" ${RUNFILE}
145+
146+
# Set up systemctl services
147+
sudo systemctl unmask hostapd
148+
sudo systemctl enable hostapd
149+
sudo systemctl start hostapd
150+
sudo systemctl daemon-reload
151+
152+
# Remove Ethernet-Gadget capabilities
153+
if grep "modules-load=dwc2,g_ether" "dwc2,g_ether" ${CMDLINEFILE}; then
154+
sudo sed -i "s|modules-load=dwc2,g_ether ||g" ${CMDLINEFILE}
155+
elif grep "dwc2,g_ether" ${CMDLINEFILE}; then
156+
sudo sed -i "s|dwc2,g_ether ||g" ${CMDLINEFILE}
157+
fi
158+
if grep "dtoverlay=dwc2,dr_mode=peripheral" ${CONFIGFILE}; then
159+
sudo sed -i "/^dtoverlay=dwc2,dr_mode=peripheral/d" /boot/firmware/config.txt
160+
fi
161+
clear
162+
echo -e "${RED}[+]TorBox is now configured to be used in a Raspberry Pi Zero 2 W${NOCOLOR}"
163+
fi
164+
165+
# Reboot
166+
recommended_reboot

install/convert_to_torbox_mini

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ RUNFILE="run/torbox.run"
6363
##############################
6464
######## FUNCTIONS ###########
6565

66+
#include lib
67+
. /home/torbox/torbox/lib/torbox.lib
68+
6669
INPUT=$(cat text/convert_to_torbox_mini-text)
6770
if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH); then
68-
cd
69-
cd torbox
70-
#These packages are not necessary anymore
71+
72+
cd $TORBOX_PATH
73+
74+
# These packages are not necessary anymore
7175
clear
7276
echo -e "${RED}[+] These packages are not necessary anymore....${NOCOLOR}"
7377
echo ""
@@ -76,7 +80,8 @@ if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_1
7680
# NEW v.0.5.5: This is necessary for installing linux-headers, which replaces raspberrypi-kernel-headers on Debian Trixie
7781
LINUX_HEADERS="linux-headers-$(uname -r)"
7882
(sudo apt-get -y purge $LINUX_HEADERS dkms) 2>/dev/null
79-
#Fixing and cleaning
83+
84+
# Fixing and cleaning
8085
echo -e "${RED}[+] Fixing and cleaning${NOCOLOR}"
8186
echo ""
8287
sudo apt --fix-broken install
@@ -86,6 +91,7 @@ if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_1
8691
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@default.service
8792
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@.service
8893
sudo systemctl daemon-reload
94+
8995
# Updating the system
9096
echo -e "${RED}[+] Updating the system...${NOCOLOR}"
9197
echo ""
@@ -94,6 +100,12 @@ if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_1
94100
sudo apt-get -y clean
95101
sudo apt-get -y autoclean
96102
sudo apt-get -y autoremove
103+
sudo setcap 'cap_net_bind_service=+ep' /usr/bin/obfs4proxy
104+
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@default.service
105+
sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@.service
106+
sudo systemctl daemon-reload
107+
108+
# Set up the system
97109
echo -e "${RED}[+] Set up the system...${NOCOLOR}"
98110
sudo cp $TORBOX_PATH/etc/dhcp/dhcpd-mini.conf /etc/dhcp/dhcpd.conf
99111
sudo cp $TORBOX_PATH/etc/iptables.ipv4-mini.nat /etc/iptables.ipv4.nat
@@ -120,3 +132,6 @@ if (whiptail --title "TorBox - INFO" --defaultno --yesno "$INPUT" $MENU_HEIGHT_1
120132
clear
121133
echo -e "${RED}[+]TorBox is now configured to be used in a Raspberry Pi Zero 2 W${NOCOLOR}"
122134
fi
135+
136+
# Reboot
137+
recommended_reboot

0 commit comments

Comments
 (0)