-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TorBox mini: rc.local integration / raspberrypi-kernel-headers and dk…
…ms removed
- Loading branch information
Showing
5 changed files
with
168 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#!/bin/sh -e | ||
# | ||
# This file is a part of TorBox, an easy to use anonymizing router based on Raspberry Pi. | ||
# Copyright (C) 2024 Patrick Truffer | ||
# Contact: anonym@torbox.ch | ||
# Website: https://www.torbox.ch | ||
# Github: https://github.com/radio24/TorBox | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it is useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/local/go/bin | ||
sudo dmesg -D | ||
rfkill unblock all | ||
rfkill block bluetooth | ||
bash /home/torbox/torbox/bin/regset | ||
sudo systemctl stop hostapd | ||
|
||
if grep "TWEBSSH=1" /home/torbox/torbox/run/torbox.run ; then | ||
[ ! -f /etc/nginx/sites-available/webssh.conf ] && sudo cp /home/torbox/torbox/etc/nginx/sites-available/sample-webssh.conf /etc/nginx/sites-available/webssh.conf | ||
[ ! -L /etc/nginx/sites-enabled/webssh.conf ] && sudo ln -sf /etc/nginx/sites-available/webssh.conf /etc/nginx/sites-enabled/ | ||
(nohup sudo /home/torbox/torbox/lib/webssh/twebssh --unix-socket=/var/run/webssh.sock &) 2>/dev/null | ||
sudo ls /var/run | grep .*-onion-.*.sock | xargs -I {} -d"\n" sudo rm /var/run/{} | ||
sudo systemctl restart nginx | ||
fi | ||
|
||
# Change the MAC address if needed | ||
# List all available network interfaces | ||
AVAILABLE_INTERFACES=$(ip -o link show | awk -F': ' '{print $2}' | sed "/^lo/d" | sed "/^wwan/d") | ||
for INTERFACE in $AVAILABLE_INTERFACES ; do | ||
if grep "^MAC_$INTERFACE=permanent" /home/torbox/torbox/run/torbox.run || grep "^MAC_$INTERFACE=random" /home/torbox/torbox/run/torbox.run ; then | ||
# NEW v.0.5.3: We have only to put an interface down, if it is not already down | ||
# ATTENTION not connected interfaces have to put down, even the state is already down --> NO-CARRIER | ||
if ip link | grep "$INTERFACE" | grep -e "state UP" -e "NO-CARRIER" ; then | ||
sudo ip link set dev $INTERFACE down | ||
INTERFACE1_DOWN=1 | ||
sleep 2 | ||
fi | ||
# | ||
# NEW v.0.5.4: After a restart, the default MAC address is already set. Executing the comand result in a error. | ||
# if grep "^MAC_$INTERFACE=permanent" /home/torbox/torbox/run/torbox.run; then sudo macchanger -p $INTERFACE; fi | ||
if grep "^MAC_$INTERFACE=random" /home/torbox/torbox/run/torbox.run; then sudo macchanger -r $INTERFACE; fi | ||
# NEW v.0.5.3: We have only to put an interface up, if it was up before | ||
if [ "$INTERFACE1_DOWN" = "1" ]; then | ||
sudo ip link set dev $INTERFACE up | ||
INTERFACE1_DOWN=0 | ||
fi | ||
# | ||
else | ||
MAC_ADDRESS=$(grep "MAC_$INTERFACE=" /home/torbox/torbox/run/torbox.run | sed "s/.*=//g") | ||
# NEW v.0.5.3: We have only to put an interface down, if it is not already down | ||
# ATTENTION not connected interfaces have to put down, even the state is already down --> NO-CARRIER | ||
if ip link | grep "$INTERFACE" | grep -e "state UP" -e "NO-CARRIER" ; then | ||
sudo ip link set dev $INTERFACE down | ||
INTERFACE1_DOWN=1 | ||
sleep 2 | ||
fi | ||
sudo ip link set dev $INTERFACE address $MAC_ADDRESS | ||
# NEW v.0.5.3: We have only to put an interface up, if it was up before | ||
if [ "$INTERFACE1_DOWN" = "1" ]; then | ||
sudo ip link set dev $INTERFACE up | ||
INTERFACE1_DOWN=0 | ||
fi | ||
fi | ||
done | ||
|
||
# Let's check if we can auto-connect to a wireless network | ||
if ip link | grep wlan0 ; then | ||
if grep "INTERNET_IFACE=wlan0" /home/torbox/torbox/run/torbox.run ; then | ||
exitstatus=$(sudo /usr/bin/python3 /home/torbox/torbox/lib/torbox_wireless_manager.py -i wlan0 -a) | ||
if [ "$exitstatus" == "1" ]; then | ||
systemctl restart tor | ||
fi | ||
fi | ||
fi | ||
|
||
# If configured, turn TACA on | ||
if grep "LOGCHECK=1" /home/torbox/torbox/run/torbox.run ; then | ||
(nohup sudo /usr/bin/python3 /home/torbox/torbox/log_check.py &) 2>/dev/null | ||
fi | ||
|
||
# Start TFS and TCS, if configured | ||
if grep "^TFS-" /home/torbox/torbox/run/torbox.run ; then sudo /home/torbox/torbox/bin/start_tfs initial ; fi | ||
if grep "^TCS-" /home/torbox/torbox/run/torbox.run ; then sudo /home/torbox/torbox/bin/start_tcs initial ; fi | ||
|
||
sudo systemctl start dnsmasq | ||
sudo /bin/ping -c 1 "pool.ntp.org" >/dev/null 2>&1 && sudo /usr/sbin/ntpdate pool.ntp.org | ||
# NEW post-v.0.5.3 | ||
sudo systemctl stop dnsmasq | ||
|
||
# NEW v.0.5.3 | ||
# Starting domain exclusion, if activated | ||
if grep "^UNPROTECTED_DOMAIN=1" /home/torbox/torbox/run/torbox.run ; then | ||
if [ -f "/home/torbox/torbox/run/clearnet-list" ]; then | ||
sudo /sbin/ipset -q restore -file /home/torbox/torbox/run/clearnet-list -exist | ||
else | ||
sudo /sbin/ipset create clearnet-list hash:ip | ||
fi | ||
tun0up=$(sudo timeout 5 sudo route | grep -m 1 tun0 | tr -s " " | cut -d " " -f1) | ||
if [ ! -z "$tun0up" ] ; then | ||
if [ -f "/home/torbox/torbox/run/vpn-list" ]; then | ||
sudo ipset -q restore -file /home/torbox/torbox/run/vpn-list -exist | ||
fi | ||
fi | ||
fi | ||
sudo /sbin/iptables-restore < /etc/iptables.ipv4.nat | ||
|
||
# This function opens the ports, after a restart if bridge relay is on | ||
if grep "^BridgeRelay" /etc/tor/torrc ; then | ||
ORPORT=$(grep "^ORPort" /etc/tor/torrc | cut -d " " -f2) | ||
OBFS4PORT=$(grep "^ServerTransportListenAddr" /etc/tor/torrc | cut -d ":" -f2) | ||
(sudo /sbin/iptables -C INPUT -p tcp --dport $ORPORT -j ACCEPT) 2>/dev/null | ||
RULE_CHECK=$? | ||
if [ $RULE_CHECK = 1 ]; then | ||
(sudo /sbin/iptables -A INPUT -p tcp --dport $ORPORT -j ACCEPT) 2>/dev/null | ||
(sudo /sbin/iptables -A INPUT -p tcp --dport $OBFS4PORT -j ACCEPT) 2>/dev/null | ||
fi | ||
else | ||
if iptables-save | grep -e "-A INPUT -p tcp --dport $ORPORT -j ACCEPT" ; then (sudo /sbin/iptables -D INPUT -p tcp --dport $ORPORT -j ACCEPT) 2>/dev/null ; fi | ||
if iptables-save | grep -e "-A INPUT -p tcp --dport $OBFS4PORT -j ACCEPT" ; then (sudo /sbin/iptables -D INPUT -p tcp --dport $OBFS4PORT -j ACCEPT) 2>/dev/null ; fi | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters