From f32a183a3ddf0b40b4f34e20e727b828ac8bc174 Mon Sep 17 00:00:00 2001 From: radio24 Date: Mon, 1 Apr 2024 09:34:55 +0200 Subject: [PATCH] TorBox mini: Added --continue_with_step / preventing executing hostapd commands if it is masked --- bin/change_MAC | 8 +- bin/hostapd_fallback_komplex_part_1 | 26 +- etc/rc.local.mini | 2 + install/run_install.sh | 2 +- install/run_install_mini.sh | 1275 ++++++++++++++------------- install/run_install_on_debian.sh | 4 +- install/run_install_on_ubuntu.sh | 4 +- menu-update | 32 +- requirements.txt | 2 +- text/torbox_mini_warning-text | 6 + 10 files changed, 718 insertions(+), 643 deletions(-) create mode 100644 text/torbox_mini_warning-text diff --git a/bin/change_MAC b/bin/change_MAC index 331b8643..06d47cd1 100755 --- a/bin/change_MAC +++ b/bin/change_MAC @@ -215,8 +215,12 @@ change_mac_address_finish() # I guess the old one was wrong # if [[ "$O_DEVICE" =~ "$CLIENT_IFACE" ]]; then if [[ "$CLIENT_IFACE" =~ "$O_DEVICE" ]]; then - echo -e "${RED}[+] Restarting hostapd!${NOCOLOR}" - sudo systemctl restart hostapd + # New v.0.5.4 avoid to run hostapd if it is masked + AP_STATUS=$(sudo systemctl is-enable hostapd) + if [ "$AP_STATUS" != "masked" ] ; then + echo -e "${RED}[+] Restarting hostapd!${NOCOLOR}" + sudo systemctl restart hostapd + fi elif [[ "$INTERNET_IFACE" == "$O_DEVICE" ]]; then echo echo -e "${YELLOW}[!] YOU MUST RECONNECT TO THE INTERNET IN THE MAIN MENU!${NOCOLOR}" diff --git a/bin/hostapd_fallback_komplex_part_1 b/bin/hostapd_fallback_komplex_part_1 index 8dac1f8f..7851bd22 100755 --- a/bin/hostapd_fallback_komplex_part_1 +++ b/bin/hostapd_fallback_komplex_part_1 @@ -135,18 +135,26 @@ fi # If wlan0 or wlan1 is not acting as AP then we have to do something about it! if ! grep "^interface=$INTERFACE1" ${HOSTAPD} ; then sudo sed -i "s/^interface=.*/interface=$INTERFACE1/" ${HOSTAPD} - sudo systemctl restart hostapd - sleep 5 - AP_STATUS=$(sudo systemctl is-active hostapd) - if [ $AP_STATUS = activating ] || [ $AP_STATUS = inactive ] ; then - sudo sed -i "s/^hw_mode=a/hw_mode=g/" ${HOSTAPD} - sudo sed -i "s/^channel=.*/channel=6/" ${HOSTAPD} - sudo sed -i "s/^ht_capab=[HT40-][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]/#ht_capab=[HT40-][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]/" ${HOSTAPD} - sudo sed -i "s/^vht_oper_chwidth=1/#vht_oper_chwidth=1/" ${HOSTAPD} - sudo sed -i "s/^vht_oper_centr_freq_seg0_idx=42/#vht_oper_centr_freq_seg0_idx=42/" ${HOSTAPD} + # New v.0.5.4 avoid to run hostapd if it is masked + AP_STATUS=$(sudo systemctl is-enable hostapd) + if [ "$AP_STATUS" != "masked" ] ; then sudo systemctl restart hostapd sleep 5 fi + # New v.0.5.4 avoid to run hostapd if it is masked + AP_STATUS=$(sudo systemctl is-enable hostapd) + if [ "$AP_STATUS" != "masked" ] ; then + AP_STATUS=$(sudo systemctl is-active hostapd) + if [ $AP_STATUS = activating ] || [ $AP_STATUS = inactive ] ; then + sudo sed -i "s/^hw_mode=a/hw_mode=g/" ${HOSTAPD} + sudo sed -i "s/^channel=.*/channel=6/" ${HOSTAPD} + sudo sed -i "s/^ht_capab=[HT40-][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]/#ht_capab=[HT40-][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]/" ${HOSTAPD} + sudo sed -i "s/^vht_oper_chwidth=1/#vht_oper_chwidth=1/" ${HOSTAPD} + sudo sed -i "s/^vht_oper_centr_freq_seg0_idx=42/#vht_oper_centr_freq_seg0_idx=42/" ${HOSTAPD} + sudo systemctl restart hostapd + sleep 5 + fi + fi fi # Is INTERFACE2 ready? diff --git a/etc/rc.local.mini b/etc/rc.local.mini index d8526f90..80d69486 100644 --- a/etc/rc.local.mini +++ b/etc/rc.local.mini @@ -26,6 +26,8 @@ rfkill unblock all rfkill block bluetooth bash /home/torbox/torbox/bin/regset sudo systemctl stop hostapd +sudo systemctl disable hostapd +sudo systemctl mask 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 diff --git a/install/run_install.sh b/install/run_install.sh index 88473d7f..06045b36 100755 --- a/install/run_install.sh +++ b/install/run_install.sh @@ -249,7 +249,7 @@ re-connect() echo -e "${RED}[+] Yes, we have Internet! :-)${NOCOLOR}" else echo -e "${YELLOW}[!] Hmmm, no we don't have Internet... :-(${NOCOLOR}" - echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" + echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" sleep 30 echo "" echo -e "${RED}[+] Trying again...${NOCOLOR}" diff --git a/install/run_install_mini.sh b/install/run_install_mini.sh index 7b9686d5..2606c402 100644 --- a/install/run_install_mini.sh +++ b/install/run_install_mini.sh @@ -29,7 +29,7 @@ # on the SD card running in the Raspberry Pi Zero 2 W. # # SYNTAX -# ./run_install.sh [-h|--help] [--randomize_hostname] [--select-tor] [--select-fork fork_owner_name] [--select-branch branch_name] [--step_by_step] +# ./run_install.sh [-h|--help] [--randomize_hostname] [--select-tor] [--select-fork fork_owner_name] [--select-branch branch_name] [--step_by_step] [--continue_with_step] # # The -h or --help option shows the help screen. # @@ -50,6 +50,10 @@ # The --step_by_step option execute the installation step by step, which # is ideal to find bugs. # +# The --continue_with_step In case of an aborted installation, this option +# allows to continue the installation with a certain step, skipping all other +# steps before. +# # IMPORTANT # Start the insatllation as user "torbox""! # Dont run it as root (no sudo)! @@ -57,8 +61,8 @@ ########################################################## # Table of contents for this script: -# 1a. Checking for Internet connection -# 1b. Adjusting time, if needed +# 0. Checking for Internet connection +# 1. Adjusting time, if needed # 2. Checking for the WLAN regulatory domain # 3. Updating the system # 4. Installing all necessary packages @@ -156,7 +160,7 @@ while true; do case "$1" in -h | --help ) echo "Copyright (C) 2023 Patrick Truffer, nyxnor (Contributor)" - echo "Syntax : run_install_debian.sh [-h|--help] [--randomize_hostname] [--select-tor] [--select-fork fork_name] [--select-branch branch_name] [--step_by_step]" + echo "Syntax : run_install_debian.sh [-h|--help] [--randomize_hostname] [--select-tor] [--select-fork fork_name] [--select-branch branch_name] [--step_by_step] [--continue_with_step]" echo "Options: -h, --help : Shows this help screen ;-)" echo " --randomize_hostname" echo " : Randomizes the hostname to prevent ISPs to see the default" @@ -166,6 +170,8 @@ while true; do echo " --select-branch branch_name" echo " : Let select a specific TorBox branch (default: master)" echo " --step_by_step : Executes the installation step by step" + echo " --continue_with_step" + echo " : Continue the installation with a certain step" echo "" echo "Please before starting the installation ensure that the user account \"torbox\" is already created" echo "and that you are logged in as such." @@ -187,6 +193,12 @@ while true; do shift 2 ;; --step_by_step ) STEP_BY_STEP="--step_by_step"; shift ;; + --continue_with_step ) + # shellcheck disable=SC2034 + CONTINUE_WITH_STEP="--select-branch" + [ ! -z "$2" ] && STEP_NUMBER="$2" || STEP_NUMBER="1" + shift 2 + ;; -- ) shift; break ;; * ) break ;; esac @@ -244,7 +256,7 @@ re-connect() echo -e "${RED}[+] Yes, we have Internet! :-)${NOCOLOR}" else echo -e "${YELLOW}[!] Hmmm, no we don't have Internet... :-(${NOCOLOR}" - echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" + echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" sleep 30 echo "" echo -e "${RED}[+] Trying again...${NOCOLOR}" @@ -521,499 +533,519 @@ fi # 1a. Checking for Internet connection clear -echo -e "${RED}[+] Step 1: Do we have Internet?${NOCOLOR}" +echo -e "${RED}[+] Step 0: Do we have Internet?${NOCOLOR}" echo -e "${RED}[+] Nevertheless, to be sure, let's add some open nameservers!${NOCOLOR}" # NEW v.0.5.3 re-connect -# 1b. Adjusting time, if needed -clear -if [ -f "/etc/timezone" ]; then - sudo mv /etc/timezone /etc/timezone.bak - (printf "Etc/UTC" | sudo tee /etc/timezone) 2>&1 -fi -sudo timedatectl set-timezone UTC -clear -echo -e "${YELLOW}[!] SYSTEM-TIME CHECK${NOCOLOR}" -echo -e "${RED}[!] Tor needs a correctly synchronized time.${NOCOLOR}" -echo -e "${RED} The system should display the current UTC time:${NOCOLOR}" -echo -echo -e " Date: ${YELLOW}$(date '+%Y-%m-%d')${NOCOLOR}" -echo -e " Time: ${YELLOW}$(date '+%H:%M')${NOCOLOR}" -echo -echo -e "${RED} You can find the correct time here: ${YELLOW}https://time.is/UTC${NOCOLOR}" -echo -while true -do - read -r -p $'\e[1;31m Do you want to adjust the system time [Y/n]? -> \e[0m' - # The following line is for the prompt to appear on a new line. - if [[ $REPLY =~ ^[YyNn]$ ]] ; then +if [ "$STEP_NUMBER" -le "1" ]; then + # 1b. Adjusting time, if needed + clear + if [ -f "/etc/timezone" ]; then + sudo mv /etc/timezone /etc/timezone.bak + (printf "Etc/UTC" | sudo tee /etc/timezone) 2>&1 + fi + sudo timedatectl set-timezone UTC + clear + echo -e "${YELLOW}[!] SYSTEM-TIME CHECK${NOCOLOR}" + echo -e "${RED}[!] Tor needs a correctly synchronized time.${NOCOLOR}" + echo -e "${RED} The system should display the current UTC time:${NOCOLOR}" + echo + echo -e " Date: ${YELLOW}$(date '+%Y-%m-%d')${NOCOLOR}" + echo -e " Time: ${YELLOW}$(date '+%H:%M')${NOCOLOR}" + echo + echo -e "${RED} You can find the correct time here: ${YELLOW}https://time.is/UTC${NOCOLOR}" + echo + while true + do + read -r -p $'\e[1;31m Do you want to adjust the system time [Y/n]? -> \e[0m' + # The following line is for the prompt to appear on a new line. + if [[ $REPLY =~ ^[YyNn]$ ]] ; then echo echo break + fi + done + if [[ $REPLY =~ ^[Yy]$ ]] ; then + echo "" + read -r -p $'\e[1;31mPlease enter the date (YYYY-MM-DD): \e[0m' DATESTRING + echo "" + echo -e "${RED}Please enter the UTC time (HH:MM)${NOCOLOR}" + read -r -p $'You can find the correct time here: https://time.is/UTC: ' TIMESTRING + # Check and set date + if [[ $DATESTRING =~ ^[1-2]{1}[0-9]{3}-[0-9]{2}-[0-9]{2}$ ]]; then + echo "" + sudo date -s "$DATESTRING" + echo -e "${RED}[+] Date set successfully!${NOCOLOR}" + if [[ $TIMESTRING =~ ^[0-9]{2}:[0-9]{2}$ ]]; then + echo "" + sudo date -s "$TIMESTRING" + echo -e "${RED}[+] Time set successfully!${NOCOLOR}" + sleep 5 + clear + else + echo "" + echo -e "${YELLOW}[!] INVALIDE TIME FORMAT!${NOCOLOR}" + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + fi + else + echo "" + echo -e "${YELLOW}[!] INVALIDE DATE FORMAT!${NOCOLOR}" + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + fi fi -done -if [[ $REPLY =~ ^[Yy]$ ]] ; then - echo "" - read -r -p $'\e[1;31mPlease enter the date (YYYY-MM-DD): \e[0m' DATESTRING - echo "" - echo -e "${RED}Please enter the UTC time (HH:MM)${NOCOLOR}" - read -r -p $'You can find the correct time here: https://time.is/UTC: ' TIMESTRING - # Check and set date - if [[ $DATESTRING =~ ^[1-2]{1}[0-9]{3}-[0-9]{2}-[0-9]{2}$ ]]; then - echo "" - sudo date -s "$DATESTRING" - echo -e "${RED}[+] Date set successfully!${NOCOLOR}" - if [[ $TIMESTRING =~ ^[0-9]{2}:[0-9]{2}$ ]]; then - echo "" - sudo date -s "$TIMESTRING" - echo -e "${RED}[+] Time set successfully!${NOCOLOR}" - sleep 5 - clear - else - echo "" - echo -e "${YELLOW}[!] INVALIDE TIME FORMAT!${NOCOLOR}" - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear - fi - else - echo "" - echo -e "${YELLOW}[!] INVALIDE DATE FORMAT!${NOCOLOR}" - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear - fi -fi - -# 2. Check the status of the WLAN regulatory domain to be sure WiFi will work -clear -echo -e "${RED}[+] Step 2: Check the status of the WLAN regulatory domain...${NOCOLOR}" -COUNTRY=$(sudo iw reg get | grep country | cut -d " " -f2) -if [ "$COUNTRY" = "00:" ]; then - echo -e "${YELLOW}[!] No WLAN regulatory domain set - that will lead to problems!${NOCOLOR}" - echo -e "${YELLOW}[!] Therefore we will set it to US! You can change it later.${NOCOLOR}" - sudo iw reg set US - INPUT="REGDOMAIN=US" - sudo sed -i "s/^REGDOMAIN=.*/${INPUT}/" /etc/default/crda -else - echo -e "${RED}[+] The WLAN regulatory domain is set correctly! ${NOCOLOR}" -fi -echo -e "${RED}[+] To be sure we will unblock wlan, now! ${NOCOLOR}" -sudo rfkill unblock wlan - -# 3. Updating the system -sleep 10 -clear -echo -e "${RED}[+] Step 3: Updating the system...${NOCOLOR}" -sudo apt-get -y update -sudo apt-get -y dist-upgrade -sudo apt-get -y clean -sudo apt-get -y autoclean -sudo apt-get -y autoremove - -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 -fi - -# 4. Installing all necessary packages -clear -echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" -# Installation of standard packages -# check_install_packages "hostapd isc-dhcp-server usbmuxd dnsmasq dnsutils tcpdump iftop vnstat debian-goodies apt-transport-https dirmngr python3-pip python3-pil imagemagick tesseract-ocr ntpdate screen git openvpn ppp python3-stem raspberrypi-kernel-headers dkms nyx apt-transport-tor qrencode nginx basez iptables ipset macchanger openssl ca-certificates lshw" -# NEW for TorBox mini: raspberrypi-kernel-headers dkms removed -check_install_packages "hostapd isc-dhcp-server usbmuxd dnsmasq dnsutils tcpdump iftop vnstat debian-goodies apt-transport-https dirmngr python3-pip python3-pil imagemagick tesseract-ocr ntpdate screen git openvpn ppp python3-stem nyx apt-transport-tor qrencode nginx basez iptables ipset macchanger openssl ca-certificates lshw" -# Installation of developper packages - THIS PACKAGES ARE NECESARY FOR THE COMPILATION OF TOR!! Without them, tor will disconnect and restart every 5 minutes!! -check_install_packages "build-essential automake libevent-dev libssl-dev asciidoc bc devscripts dh-apparmor libcap-dev liblzma-dev libsystemd-dev libzstd-dev quilt zlib1g-dev" -# IMPORTANT tor-geoipdb installs also the tor package -check_install_packages "tor-geoipdb" -sudo systemctl stop tor -sudo systemctl mask tor -# Both tor services have to be masked to block outgoing tor connections -sudo systemctl mask tor@default.service -# NEW post-v.0.5.3: Added -# An old version of easy-rsa was available by default in some openvpn packages -if [[ -d /etc/openvpn/easy-rsa/ ]]; then - rm -rf /etc/openvpn/easy-rsa/ fi -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear +if [ "$STEP_NUMBER" -le "2" ]; then + # 2. Check the status of the WLAN regulatory domain to be sure WiFi will work + clear + echo -e "${RED}[+] Step 2: Check the status of the WLAN regulatory domain...${NOCOLOR}" + COUNTRY=$(sudo iw reg get | grep country | cut -d " " -f2) + if [ "$COUNTRY" = "00:" ]; then + echo -e "${YELLOW}[!] No WLAN regulatory domain set - that will lead to problems!${NOCOLOR}" + echo -e "${YELLOW}[!] Therefore we will set it to US! You can change it later.${NOCOLOR}" + sudo iw reg set US + INPUT="REGDOMAIN=US" + sudo sed -i "s/^REGDOMAIN=.*/${INPUT}/" /etc/default/crda + else + echo -e "${RED}[+] The WLAN regulatory domain is set correctly! ${NOCOLOR}" + fi + echo -e "${RED}[+] To be sure we will unblock wlan, now! ${NOCOLOR}" + sudo rfkill unblock wlan fi -# Install wiringpi -clear -echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" -echo "" -echo -e "${RED}[+] Installing ${YELLOW}WiringPi${NOCOLOR}" -echo "" -wget $WIRINGPI_USED -sudo dpkg -i wiringpi-latest.deb -# Not nice, but working -sudo apt -y --fix-broken install -sudo dpkg -i wiringpi-latest.deb -sudo rm wiringpi-latest.deb - -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear +if [ "$STEP_NUMBER" -le "3" ]; then + # 3. Updating the system + sleep 10 + clear + echo -e "${RED}[+] Step 3: Updating the system...${NOCOLOR}" + sudo apt-get -y update + sudo apt-get -y dist-upgrade + sudo apt-get -y clean + sudo apt-get -y autoclean + sudo apt-get -y autoremove + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -# Additional installations for Python -clear -echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" -echo "" -echo -e "${RED}[+] Installing ${YELLOW}Python modules${NOCOLOR}" -echo "" - -# NEW v.0.5.3: For RaspberryPi OS based on Debian Bookworm needed -PYTHON_LIB_PATH=$(python3 -c "import sys; print(sys.path)" | cut -d ',' -f3 | sed "s/'//g" | sed "s/,//g" | sed "s/ //g") -if [ -f "$PYTHON_LIB_PATH/EXTERNALLY-MANAGED" ] ; then - sudo rm "$PYTHON_LIB_PATH/EXTERNALLY-MANAGED" -fi +if [ "$STEP_NUMBER" -le "4" ]; then + # 4. Installing all necessary packages + clear + echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" + # Installation of standard packages + # check_install_packages "hostapd isc-dhcp-server usbmuxd dnsmasq dnsutils tcpdump iftop vnstat debian-goodies apt-transport-https dirmngr python3-pip python3-pil imagemagick tesseract-ocr ntpdate screen git openvpn ppp python3-stem raspberrypi-kernel-headers dkms nyx apt-transport-tor qrencode nginx basez iptables ipset macchanger openssl ca-certificates lshw" + # NEW for TorBox mini: raspberrypi-kernel-headers dkms removed + check_install_packages "hostapd isc-dhcp-server usbmuxd dnsmasq dnsutils tcpdump iftop vnstat debian-goodies apt-transport-https dirmngr python3-pip python3-pil imagemagick tesseract-ocr ntpdate screen git openvpn ppp python3-stem nyx apt-transport-tor qrencode nginx basez iptables ipset macchanger openssl ca-certificates lshw" + # Installation of developper packages - THIS PACKAGES ARE NECESARY FOR THE COMPILATION OF TOR!! Without them, tor will disconnect and restart every 5 minutes!! + check_install_packages "build-essential automake libevent-dev libssl-dev asciidoc bc devscripts dh-apparmor libcap-dev liblzma-dev libsystemd-dev libzstd-dev quilt zlib1g-dev" + # IMPORTANT tor-geoipdb installs also the tor package + check_install_packages "tor-geoipdb" + sudo systemctl stop tor + sudo systemctl mask tor + # Both tor services have to be masked to block outgoing tor connections + sudo systemctl mask tor@default.service + # NEW post-v.0.5.3: Added + # An old version of easy-rsa was available by default in some openvpn packages + if [[ -d /etc/openvpn/easy-rsa/ ]]; then + rm -rf /etc/openvpn/easy-rsa/ + fi + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + fi + + # Install wiringpi + clear + echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" + echo "" + echo -e "${RED}[+] Installing ${YELLOW}WiringPi${NOCOLOR}" + echo "" + wget $WIRINGPI_USED + sudo dpkg -i wiringpi-latest.deb + # Not nice, but working + sudo apt -y --fix-broken install + sudo dpkg -i wiringpi-latest.deb + sudo rm wiringpi-latest.deb + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + fi + + # Additional installations for Python + clear + echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" + echo "" + echo -e "${RED}[+] Installing ${YELLOW}Python modules${NOCOLOR}" + echo "" -# NEW v.0.5.4: opencv-python-headless hangs when installed with pip -check_install_packages "python3-opencv" + # NEW v.0.5.3: For RaspberryPi OS based on Debian Bookworm needed + PYTHON_LIB_PATH=$(python3 -c "import sys; print(sys.path)" | cut -d ',' -f3 | sed "s/'//g" | sed "s/,//g" | sed "s/ //g") + if [ -f "$PYTHON_LIB_PATH/EXTERNALLY-MANAGED" ] ; then + sudo rm "$PYTHON_LIB_PATH/EXTERNALLY-MANAGED" + fi -# NEW v.0.5.3: New way to install and check Python requirements -# Important: mechanize 0.4.8 cannot correctly be installed under Raspberry Pi OS -# the folder /usr/local/lib/python3.9/distpackages/mechanize is missing -cd -wget --no-cache https://raw.githubusercontent.com/$TORBOXMENU_FORKNAME/TorBox/$TORBOXMENU_BRANCHNAME/requirements.txt -sudo pip3 install -r requirements.txt -sleep 5 + # NEW v.0.5.4: opencv-python-headless hangs when installed with pip + check_install_packages "python3-opencv" -clear -echo -e "${YELLOW}Following Python modules are installed:${NOCOLOR}" -if [ -f requirements.failed ]; then rm requirements.failed; fi -REPLY="Y" -while [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; do - REPLY="" - readarray -t REQUIREMENTS < requirements.txt - for REQUIREMENT in "${REQUIREMENTS[@]}"; do - if grep "==" <<< $REQUIREMENT ; then REQUIREMENT=$(sed s"/==.*//" <<< $REQUIREMENT); fi - VERSION=$(pip3 freeze | grep $REQUIREMENT | sed "s/${REQUIREMENT}==//" 2>&1) - echo -e "${RED}${REQUIREMENT} version: ${YELLOW}$VERSION${NOCOLOR}" - if [ -z "$VERSION" ]; then - # shellcheck disable=SC2059 - (printf "$REQUIREMENT\n" | tee -a requirements.failed) >/dev/null 2>&1 - fi - done - if [ -f requirements.failed ]; then - echo "" - echo -e "${YELLOW}Not alle required Python modules could be installed!${NOCOLOR}" - read -r -p $'\e[1;93mWould you like to try it again [Y/n]? -> \e[0m' - if [[ $REPLY =~ ^[YyNn]$ ]] ; then - if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then - sudo pip3 install -r requirements.failed - sleep 5 - rm requirements.failed - unset REQUIREMENTS - clear - fi - fi - fi -done + # NEW v.0.5.3: New way to install and check Python requirements + # Important: mechanize 0.4.8 cannot correctly be installed under Raspberry Pi OS + # the folder /usr/local/lib/python3.9/distpackages/mechanize is missing + cd + wget --no-cache https://raw.githubusercontent.com/$TORBOXMENU_FORKNAME/TorBox/$TORBOXMENU_BRANCHNAME/requirements.txt + sudo pip3 install -r requirements.txt + sleep 5 -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -fi + clear + echo -e "${YELLOW}Following Python modules are installed:${NOCOLOR}" + if [ -f requirements.failed ]; then rm requirements.failed; fi + REPLY="Y" + while [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; do + REPLY="" + readarray -t REQUIREMENTS < requirements.txt + for REQUIREMENT in "${REQUIREMENTS[@]}"; do + if grep "==" <<< $REQUIREMENT ; then REQUIREMENT=$(sed s"/==.*//" <<< $REQUIREMENT); fi + VERSION=$(pip3 freeze | grep -i $REQUIREMENT | sed "s/${REQUIREMENT}==//i" 2>&1) + echo -e "${RED}${REQUIREMENT} version: ${YELLOW}$VERSION${NOCOLOR}" + if [ -z "$VERSION" ]; then + # shellcheck disable=SC2059 + (printf "$REQUIREMENT\n" | tee -a requirements.failed) >/dev/null 2>&1 + fi + done + if [ -f requirements.failed ]; then + echo "" + echo -e "${YELLOW}Not alle required Python modules could be installed!${NOCOLOR}" + read -r -p $'\e[1;93mWould you like to try it again [Y/n]? -> \e[0m' + if [[ $REPLY =~ ^[YyNn]$ ]] ; then + if [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; then + sudo pip3 install -r requirements.failed + sleep 5 + rm requirements.failed + unset REQUIREMENTS + clear + fi + fi + fi + done -# Additional installation for go -clear -echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" -echo "" -echo -e "${RED}[+] Installing ${YELLOW}go${NOCOLOR}" -echo "" - -# NEW v.0.5.3: New way to download the current version of go -if uname -m | grep -q -E "arm64|aarch64"; then PLATFORM="linux-arm64" -else PLATFORM="linux-armv6l" -fi + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + fi -# Fetch the filename of the latest go version -GO_FILENAME=$(curl -s "$GO_DL_PATH" | grep "$PLATFORM" | grep -m 1 'class=\"download\"' | cut -d'"' -f6 | cut -d'/' -f3) -wget --no-cache "$GO_DL_PATH$GO_FILENAME" -DLCHECK=$? -# NEW v.0.5.3: if the download failed, install the package from the distribution -if [ "$DLCHECK" != "0" ] ; then - echo "" - echo -e "${YELLOW}[!] COULDN'T DOWNLOAD GO (for $PLATFORM)!${NOCOLOR}" - echo -e "${RED}[+] The go repositories may be blocked or offline!${NOCOLOR}" - echo -e "${RED}[+] We try to install the distribution package, instead.${NOCOLOR}" - echo - if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear - else - sleep 10 - fi - re-connect - sudo apt-get -y install golang - GO_PROGRAM="/usr/local/go/bin/go" - if [ -f $GO_PROGRAM ]; then - GO_VERSION_NR=$($GO_PROGRAM version | cut -d ' ' -f3 | cut -d '.' -f2) - else - GO_PROGRAM=go - #This can lead to command not found - ignore it - GO_VERSION_NR=$($GO_PROGRAM version | cut -d ' ' -f3 | cut -d '.' -f2) - fi - if [ "$GO_VERSION_NR" -lt "17" ]; then - echo "" - echo -e "${YELLOW}[!] TOO LOW GO VERSION NUMBER${NOCOLOR}" - echo -e "${RED}[+] At least go version 1.17 is needed to compile pluggable ${NOCOLOR}" - echo -e "${RED}[+] transports. We tried several ways to get a newer go version, ${NOCOLOR}" - echo -e "${RED}[+] but failed. Please, try it again later or install go manually. ${NOCOLOR}" - echo "" - exit 1 - fi -else - sudo tar -C /usr/local -xzvf $GO_FILENAME - sudo rm $GO_FILENAME -fi + # Additional installation for go + clear + echo -e "${RED}[+] Step 4: Installing all necessary packages....${NOCOLOR}" + echo "" + echo -e "${RED}[+] Installing ${YELLOW}go${NOCOLOR}" + echo "" -# NEW v.0.5.3: what if .profile doesn't exist? -if [ -f ".profile" ]; then - if ! grep "Added by TorBox (001)" .profile ; then - sudo printf "\n# Added by TorBox (001)\nexport PATH=$PATH:/usr/local/go/bin\n" | tee -a .profile - fi -else - sudo printf "\n# Added by TorBox (001)\nexport PATH=$PATH:/usr/local/go/bin\n" | tee -a .profile + # NEW v.0.5.3: New way to download the current version of go + if uname -m | grep -q -E "arm64|aarch64"; then PLATFORM="linux-arm64" + else PLATFORM="linux-armv6l" + fi + + # Fetch the filename of the latest go version + GO_FILENAME=$(curl -s "$GO_DL_PATH" | grep "$PLATFORM" | grep -m 1 'class=\"download\"' | cut -d'"' -f6 | cut -d'/' -f3) + wget --no-cache "$GO_DL_PATH$GO_FILENAME" + DLCHECK=$? + # NEW v.0.5.3: if the download failed, install the package from the distribution + if [ "$DLCHECK" != "0" ] ; then + echo "" + echo -e "${YELLOW}[!] COULDN'T DOWNLOAD GO (for $PLATFORM)!${NOCOLOR}" + echo -e "${RED}[+] The go repositories may be blocked or offline!${NOCOLOR}" + echo -e "${RED}[+] We try to install the distribution package, instead.${NOCOLOR}" + echo + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi + re-connect + sudo apt-get -y install golang + GO_PROGRAM="/usr/local/go/bin/go" + if [ -f $GO_PROGRAM ]; then + GO_VERSION_NR=$($GO_PROGRAM version | cut -d ' ' -f3 | cut -d '.' -f2) + else + GO_PROGRAM=go + #This can lead to command not found - ignore it + GO_VERSION_NR=$($GO_PROGRAM version | cut -d ' ' -f3 | cut -d '.' -f2) + fi + if [ "$GO_VERSION_NR" -lt "17" ]; then + echo "" + echo -e "${YELLOW}[!] TOO LOW GO VERSION NUMBER${NOCOLOR}" + echo -e "${RED}[+] At least go version 1.17 is needed to compile pluggable ${NOCOLOR}" + echo -e "${RED}[+] transports. We tried several ways to get a newer go version, ${NOCOLOR}" + echo -e "${RED}[+] but failed. Please, try it again later or install go manually. ${NOCOLOR}" + echo "" + exit 1 + fi + else + sudo tar -C /usr/local -xzvf $GO_FILENAME + sudo rm $GO_FILENAME + fi + + # NEW v.0.5.3: what if .profile doesn't exist? + if [ -f ".profile" ]; then + if ! grep "Added by TorBox (001)" .profile ; then + sudo printf "\n# Added by TorBox (001)\nexport PATH=$PATH:/usr/local/go/bin\n" | tee -a .profile + fi + else + sudo printf "\n# Added by TorBox (001)\nexport PATH=$PATH:/usr/local/go/bin\n" | tee -a .profile + fi + export PATH=$PATH:/usr/local/go/bin + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -export PATH=$PATH:/usr/local/go/bin -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' +if [ "$STEP_NUMBER" -le "5" ]; then + # 5. Installing tor clear -else - sleep 10 -fi + echo -e "${RED}[+] Step 5: Installing Tor...${NOCOLOR}" + select_and_install_tor -# 5. Installing tor -clear -echo -e "${RED}[+] Step 5: Installing Tor...${NOCOLOR}" -select_and_install_tor - -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 -fi - -# 6. Configuring Tor with its pluggable transports -clear -echo -e "${RED}[+] Step 6: Configuring Tor with its pluggable transports....${NOCOLOR}" -cd -git clone $OBFS4PROXY_USED -DLCHECK=$? -if [ $DLCHECK -eq 0 ]; then - export GO111MODULE="on" - cd obfs4proxy - go build -o obfs4proxy/obfs4proxy ./obfs4proxy - sudo cp ./obfs4proxy/obfs4proxy /usr/bin - cd - sudo rm -rf obfs4proxy - sudo rm -rf go* -else - echo "" - echo -e "${YELLOW}[!] COULDN'T CLONE THE OBFS4PROXY REPOSITORY!${NOCOLOR}" - echo -e "${RED}[+] The obfs4proxy repository may be blocked or offline!${NOCOLOR}" - echo -e "${RED}[+] Please try again later and if the problem persists, please report it${NOCOLOR}" - echo -e "${RED}[+] to ${YELLOW}anonym@torbox.ch${RED}. ${NOCOLOR}" - echo -e "${RED}[+] In the meantime, we install the distribution package, which may be outdated.${NOCOLOR}" - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - check_install_packages obfs4proxy - clear -fi -sudo setcap 'cap_net_bind_service=+ep' /usr/bin/obfs4proxy -(sudo mv /usr/local/bin/tor* /usr/bin) 2>/dev/null -sudo chmod a+x /usr/share/tor/geoip* -# Copying not moving! -(sudo cp /usr/share/tor/geoip* /usr/bin) 2>/dev/null -sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@default.service -sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@.service - -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -# 7. Install Snowflake -clear -echo -e "${RED}[+] Step 7: Installing Snowflake...${NOCOLOR}" -echo -e "${RED}[+] This can take some time, please be patient!${NOCOLOR}" -cd -git clone $SNOWFLAKE_USED -DLCHECK=$? -if [ $DLCHECK -eq 0 ]; then - export GO111MODULE="on" - cd snowflake/proxy - go get - go build - sudo cp proxy /usr/bin/snowflake-proxy - cd - cd snowflake/client - go get - go build - sudo cp client /usr/bin/snowflake-client - cd - sudo rm -rf snowflake - sudo rm -rf go* -else - echo "" - echo -e "${YELLOW}[!] COULDN'T CLONE THE SNOWFLAKE REPOSITORY!${NOCOLOR}" - echo -e "${RED}[+] The Snowflake repository may be blocked or offline!${NOCOLOR}" - echo -e "${RED}[+] Please try again later and if the problem persists, please report it${NOCOLOR}" - echo -e "${RED}[+] to ${YELLOW}anonym@torbox.ch${RED}. ${NOCOLOR}" - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -fi -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 +if [ "$STEP_NUMBER" -le "6" ]; then + # 6. Configuring Tor with its pluggable transports + clear + echo -e "${RED}[+] Step 6: Configuring Tor with its pluggable transports....${NOCOLOR}" + cd + git clone $OBFS4PROXY_USED + DLCHECK=$? + if [ $DLCHECK -eq 0 ]; then + export GO111MODULE="on" + cd obfs4proxy + go build -o obfs4proxy/obfs4proxy ./obfs4proxy + sudo cp ./obfs4proxy/obfs4proxy /usr/bin + cd + sudo rm -rf obfs4proxy + sudo rm -rf go* + else + echo "" + echo -e "${YELLOW}[!] COULDN'T CLONE THE OBFS4PROXY REPOSITORY!${NOCOLOR}" + echo -e "${RED}[+] The obfs4proxy repository may be blocked or offline!${NOCOLOR}" + echo -e "${RED}[+] Please try again later and if the problem persists, please report it${NOCOLOR}" + echo -e "${RED}[+] to ${YELLOW}anonym@torbox.ch${RED}. ${NOCOLOR}" + echo -e "${RED}[+] In the meantime, we install the distribution package, which may be outdated.${NOCOLOR}" + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + check_install_packages obfs4proxy + clear + fi + sudo setcap 'cap_net_bind_service=+ep' /usr/bin/obfs4proxy + (sudo mv /usr/local/bin/tor* /usr/bin) 2>/dev/null + sudo chmod a+x /usr/share/tor/geoip* + # Copying not moving! + (sudo cp /usr/share/tor/geoip* /usr/bin) 2>/dev/null + sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@default.service + sudo sed -i "s/^NoNewPrivileges=yes/NoNewPrivileges=no/g" /lib/systemd/system/tor@.service + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -# 8. Again checking connectivity -clear -echo -e "${RED}[+] Step 8: Re-checking Internet connectivity${NOCOLOR}" -# NEW v.0.5.3 -re-connect - -# 9. Downloading and installing TorBox -sleep 10 -clear -echo -e "${RED}[+] Step 9: Downloading and installing the latest version of TorBox...${NOCOLOR}" -echo -e "${RED}[+] Selected branch ${YELLOW}$TORBOXMENU_BRANCHNAME${RED}...${NOCOLOR}" -cd -wget $TORBOXURL -DLCHECK=$? -if [ $DLCHECK -eq 0 ] ; then - echo -e "${RED}[+] TorBox' menu sucessfully downloaded... ${NOCOLOR}" - echo -e "${RED}[+] Unpacking TorBox menu...${NOCOLOR}" - unzip $TORBOXMENU_BRANCHNAME.zip - echo "" - echo -e "${RED}[+] Removing the old one...${NOCOLOR}" - (rm -r torbox) 2>/dev/null - echo -e "${RED}[+] Moving the new one...${NOCOLOR}" - mv TorBox-$TORBOXMENU_BRANCHNAME torbox - echo -e "${RED}[+] Cleaning up...${NOCOLOR}" - (rm -r $TORBOXMENU_BRANCHNAME.zip) 2>/dev/null - echo "" -else - echo "" - echo -e "${YELLOW}[!] COULDN'T DOWNLOAD TORBOX!${NOCOLOR}" - echo -e "${RED}[+] The TorBox repositories may be blocked or offline!${NOCOLOR}" - echo -e "${RED}[+] Please try again later and if the problem persists, please report it${NOCOLOR}" - echo -e "${RED}[+] to ${YELLOW}anonym@torbox.ch${RED}. ${NOCOLOR}" - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - exit 0 +if [ "$STEP_NUMBER" -le "7" ]; then + # 7. Install Snowflake + clear + echo -e "${RED}[+] Step 7: Installing Snowflake...${NOCOLOR}" + echo -e "${RED}[+] This can take some time, please be patient!${NOCOLOR}" + cd + git clone $SNOWFLAKE_USED + DLCHECK=$? + if [ $DLCHECK -eq 0 ]; then + export GO111MODULE="on" + cd snowflake/proxy + go get + go build + sudo cp proxy /usr/bin/snowflake-proxy + cd + cd snowflake/client + go get + go build + sudo cp client /usr/bin/snowflake-client + cd + sudo rm -rf snowflake + sudo rm -rf go* + else + echo "" + echo -e "${YELLOW}[!] COULDN'T CLONE THE SNOWFLAKE REPOSITORY!${NOCOLOR}" + echo -e "${RED}[+] The Snowflake repository may be blocked or offline!${NOCOLOR}" + echo -e "${RED}[+] Please try again later and if the problem persists, please report it${NOCOLOR}" + echo -e "${RED}[+] to ${YELLOW}anonym@torbox.ch${RED}. ${NOCOLOR}" + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + fi + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 +if [ "$STEP_NUMBER" -le "8" ]; then + # 8. Again checking connectivity + clear + echo -e "${RED}[+] Step 8: Re-checking Internet connectivity${NOCOLOR}" + # NEW v.0.5.3 + re-connect fi -# 10. Installing all configuration files -clear -cd torbox -echo -e "${RED}[+] Step 10: Installing all configuration files....${NOCOLOR}" -echo "" -#(sudo cp /etc/default/hostapd /etc/default/hostapd.bak) 2>/dev/null -#sudo cp etc/default/hostapd /etc/default/ -#echo -e "${RED}[+]${NOCOLOR} Copied /etc/default/hostapd -- backup done" -(sudo cp /etc/default/isc-dhcp-server /etc/default/isc-dhcp-server.bak) 2>/dev/null -sudo cp etc/default/isc-dhcp-server /etc/default/ -echo -e "${RED}[+]${NOCOLOR} Copied /etc/default/isc-dhcp-server -- backup done" -(sudo cp /etc/dhcp/dhclient.conf /etc/dhcp/dhclient.conf.bak) 2>/dev/null -sudo cp etc/dhcp/dhclient.conf /etc/dhcp/ -echo -e "${RED}[+]${NOCOLOR} Copied /etc/dhcp/dhclient.conf -- backup done" -(sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak) 2>/dev/null -sudo cp etc/dhcp/dhcpd-mini.conf /etc/dhcp/dhcpd.conf -echo -e "${RED}[+]${NOCOLOR} Copied /etc/dhcp/dhcpd.conf -- backup done" -#(sudo cp /etc/hostapd/hostapd.conf /etc/hostapd/hostapd.conf.bak) 2>/dev/null -#sudo cp etc/hostapd/hostapd.conf /etc/hostapd/ -#echo -e "${RED}[+]${NOCOLOR} Copied /etc/hostapd/hostapd.conf -- backup done" -(sudo cp /etc/iptables.ipv4.nat /etc/iptables.ipv4.nat.bak) 2>/dev/null -sudo cp etc/iptables.ipv4-mini.nat /etc/iptables.ipv4.nat -echo -e "${RED}[+]${NOCOLOR} Copied /etc/iptables.ipv4.nat -- backup done" -(sudo cp /etc/motd /etc/motd.bak) 2>/dev/null -sudo cp etc/motd /etc/ -echo -e "${RED}[+]${NOCOLOR} Copied /etc/motd -- backup done" -(sudo cp /etc/network/interfaces /etc/network/interfaces.bak) 2>/dev/null -sudo cp etc/network/interfaces.mini /etc/network/interfaces -echo -e "${RED}[+]${NOCOLOR} Copied /etc/network/interfaces -- backup done" -sudo cp etc/systemd/system/rc-local.service /etc/systemd/system/rc-local.service -(sudo cp /etc/rc.local /etc/rc.local.bak) 2>/dev/null -sudo cp etc/rc.local.mini /etc/rc.local -sudo chmod a+x /etc/rc.local -echo -e "${RED}[+]${NOCOLOR} Copied /etc/rc.local -- backup done" -if grep -q "#net.ipv4.ip_forward=1" /etc/sysctl.conf ; then - sudo cp /etc/sysctl.conf /etc/sysctl.conf.bak - sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf - echo -e "${RED}[+]${NOCOLOR} Changed /etc/sysctl.conf -- backup done" -fi -(sudo cp /etc/tor/torrc /etc/tor/torrc.bak) 2>/dev/null -sudo cp etc/tor/torrc /etc/tor/ -echo -e "${RED}[+]${NOCOLOR} Copied /etc/tor/torrc -- backup done" -echo -e "${RED}[+]${NOCOLOR} Activating IP forwarding" -sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" -(sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak) 2>/dev/null -(sudo cp etc/nginx/nginx.conf /etc/nginx/) 2>/dev/null -echo -e "${RED}[+]${NOCOLOR} Copied /etc/nginx/nginx.conf -- backup done" -echo "" - -#Back to the home directory -cd -# NEW v.0.5.3: what if .profile doesn't exist? -if [ -f ".profile" ]; then - if ! grep "Added by TorBox (002)" .profile ; then - sudo printf "\n# Added by TorBox (002)\ncd torbox\n./menu\n" | tee -a .profile - fi -else - printf "\n# Added by TorBox (002)\ncd torbox\n./menu\n" | tee -a .profile +if [ "$STEP_NUMBER" -le "9" ]; then + # 9. Downloading and installing TorBox + sleep 10 + clear + echo -e "${RED}[+] Step 9: Downloading and installing the latest version of TorBox...${NOCOLOR}" + echo -e "${RED}[+] Selected branch ${YELLOW}$TORBOXMENU_BRANCHNAME${RED}...${NOCOLOR}" + cd + wget $TORBOXURL + DLCHECK=$? + if [ $DLCHECK -eq 0 ] ; then + echo -e "${RED}[+] TorBox' menu sucessfully downloaded... ${NOCOLOR}" + echo -e "${RED}[+] Unpacking TorBox menu...${NOCOLOR}" + unzip $TORBOXMENU_BRANCHNAME.zip + echo "" + echo -e "${RED}[+] Removing the old one...${NOCOLOR}" + (rm -r torbox) 2>/dev/null + echo -e "${RED}[+] Moving the new one...${NOCOLOR}" + mv TorBox-$TORBOXMENU_BRANCHNAME torbox + echo -e "${RED}[+] Cleaning up...${NOCOLOR}" + (rm -r $TORBOXMENU_BRANCHNAME.zip) 2>/dev/null + echo "" + else + echo "" + echo -e "${YELLOW}[!] COULDN'T DOWNLOAD TORBOX!${NOCOLOR}" + echo -e "${RED}[+] The TorBox repositories may be blocked or offline!${NOCOLOR}" + echo -e "${RED}[+] Please try again later and if the problem persists, please report it${NOCOLOR}" + echo -e "${RED}[+] to ${YELLOW}anonym@torbox.ch${RED}. ${NOCOLOR}" + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + exit 0 + fi + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -echo -e "${RED}[+] Make tor ready for Onion Services${NOCOLOR}" -(sudo mkdir /var/lib/tor/services) 2>/dev/null -sudo chown -R debian-tor:debian-tor /var/lib/tor/services -sudo chmod -R go-rwx /var/lib/tor/services -(sudo mkdir /var/lib/tor/onion_auth) 2>/dev/null -sudo chown -R debian-tor:debian-tor /var/lib/tor/onion_auth -sudo chmod -R go-rwx /var/lib/tor/onion_auth +if [ "$STEP_NUMBER" -le "10" ]; then + # 10. Installing all configuration files + clear + cd torbox + echo -e "${RED}[+] Step 10: Installing all configuration files....${NOCOLOR}" + echo "" + (sudo cp /etc/default/hostapd /etc/default/hostapd.bak) 2>/dev/null + sudo cp etc/default/hostapd /etc/default/ + echo -e "${RED}[+]${NOCOLOR} Copied /etc/default/hostapd -- backup done" + (sudo cp /etc/default/isc-dhcp-server /etc/default/isc-dhcp-server.bak) 2>/dev/null + sudo cp etc/default/isc-dhcp-server /etc/default/ + echo -e "${RED}[+]${NOCOLOR} Copied /etc/default/isc-dhcp-server -- backup done" + (sudo cp /etc/dhcp/dhclient.conf /etc/dhcp/dhclient.conf.bak) 2>/dev/null + sudo cp etc/dhcp/dhclient.conf /etc/dhcp/ + echo -e "${RED}[+]${NOCOLOR} Copied /etc/dhcp/dhclient.conf -- backup done" + (sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak) 2>/dev/null + sudo cp etc/dhcp/dhcpd-mini.conf /etc/dhcp/dhcpd.conf + echo -e "${RED}[+]${NOCOLOR} Copied /etc/dhcp/dhcpd.conf -- backup done" + (sudo cp /etc/hostapd/hostapd.conf /etc/hostapd/hostapd.conf.bak) 2>/dev/null + sudo cp etc/hostapd/hostapd.conf /etc/hostapd/ + echo -e "${RED}[+]${NOCOLOR} Copied /etc/hostapd/hostapd.conf -- backup done" + (sudo cp /etc/iptables.ipv4.nat /etc/iptables.ipv4.nat.bak) 2>/dev/null + sudo cp etc/iptables.ipv4-mini.nat /etc/iptables.ipv4.nat + echo -e "${RED}[+]${NOCOLOR} Copied /etc/iptables.ipv4.nat -- backup done" + (sudo cp /etc/motd /etc/motd.bak) 2>/dev/null + sudo cp etc/motd /etc/ + echo -e "${RED}[+]${NOCOLOR} Copied /etc/motd -- backup done" + (sudo cp /etc/network/interfaces /etc/network/interfaces.bak) 2>/dev/null + sudo cp etc/network/interfaces.mini /etc/network/interfaces + echo -e "${RED}[+]${NOCOLOR} Copied /etc/network/interfaces -- backup done" + sudo cp etc/systemd/system/rc-local.service /etc/systemd/system/rc-local.service + (sudo cp /etc/rc.local /etc/rc.local.bak) 2>/dev/null + sudo cp etc/rc.local.mini /etc/rc.local + sudo chmod a+x /etc/rc.local + echo -e "${RED}[+]${NOCOLOR} Copied /etc/rc.local -- backup done" + if grep -q "#net.ipv4.ip_forward=1" /etc/sysctl.conf ; then + sudo cp /etc/sysctl.conf /etc/sysctl.conf.bak + sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf + echo -e "${RED}[+]${NOCOLOR} Changed /etc/sysctl.conf -- backup done" + fi + (sudo cp /etc/tor/torrc /etc/tor/torrc.bak) 2>/dev/null + sudo cp etc/tor/torrc /etc/tor/ + echo -e "${RED}[+]${NOCOLOR} Copied /etc/tor/torrc -- backup done" + echo -e "${RED}[+]${NOCOLOR} Activating IP forwarding" + sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" + (sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak) 2>/dev/null + (sudo cp etc/nginx/nginx.conf /etc/nginx/) 2>/dev/null + echo -e "${RED}[+]${NOCOLOR} Copied /etc/nginx/nginx.conf -- backup done" + echo "" -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 + #Back to the home directory + cd + # NEW v.0.5.3: what if .profile doesn't exist? + if [ -f ".profile" ]; then + if ! grep "Added by TorBox (002)" .profile ; then + sudo printf "\n# Added by TorBox (002)\ncd torbox\n./menu\n" | tee -a .profile + fi + else + printf "\n# Added by TorBox (002)\ncd torbox\n./menu\n" | tee -a .profile + fi + + echo -e "${RED}[+] Make tor ready for Onion Services${NOCOLOR}" + (sudo mkdir /var/lib/tor/services) 2>/dev/null + sudo chown -R debian-tor:debian-tor /var/lib/tor/services + sudo chmod -R go-rwx /var/lib/tor/services + (sudo mkdir /var/lib/tor/onion_auth) 2>/dev/null + sudo chown -R debian-tor:debian-tor /var/lib/tor/onion_auth + sudo chmod -R go-rwx /var/lib/tor/onion_auth + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi # 11. Disabling Bluetooth @@ -1031,170 +1063,177 @@ fi #fi #sudo rfkill block bluetooth -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 -fi +#if [ "$STEP_BY_STEP" = "--step_by_step" ]; then +# echo "" +# read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' +# clear +#else +# sleep 10 +#fi -# 12. Configure the system services -clear -echo -e "${RED}[+] Step 12: Configure the system services...${NOCOLOR}" -sudo systemctl daemon-reload -# Temporary to test TorBox TorBox mini -sudo systemctl stop hostapd -sudo systemctl disable hostapd -sudo systemctl mask hostapd -#sudo systemctl unmask hostapd -#sudo systemctl enable hostapd -#sudo systemctl start hostapd -sudo systemctl unmask isc-dhcp-server -sudo systemctl enable isc-dhcp-server -sudo systemctl start isc-dhcp-server -sudo systemctl stop tor -sudo systemctl mask tor -# Both tor services have to be masked to block outgoing tor connections -sudo systemctl mask tor@default.service -sudo systemctl unmask ssh -sudo systemctl enable ssh -sudo systemctl start ssh -# Temporary to test TorBox TorBox mini -#echo "" -#echo -e "${RED}[+] Stop logging, now...${NOCOLOR}" -#sudo systemctl stop rsyslog -#sudo systemctl disable rsyslog -#sudo systemctl mask rsyslog -#sudo systemctl stop systemd-journald-dev-log.socket -#sudo systemctl stop systemd-journald-audit.socket -#sudo systemctl stop systemd-journald.socket -#sudo systemctl stop systemd-journald.service -#sudo systemctl mask systemd-journald.service -echo"" - -# Make Nginx ready for Webssh and Onion Services -echo -e "${RED}[+] Make Nginx ready for Webssh and Onion Services${NOCOLOR}" -sudo systemctl stop nginx -(sudo rm /etc/nginx/sites-enabled/default) 2>/dev/null -(sudo rm /etc/nginx/sites-available/default) 2>/dev/null -(sudo rm -r /var/www/html) 2>/dev/null -# This is necessary for Nginx / TFS -(sudo chown torbox:torbox /var/www) 2>/dev/null -# Configuring webssh -sudo cp torbox/etc/nginx/sites-available/sample-webssh.conf /etc/nginx/sites-available/webssh.conf -sudo ln -sf /etc/nginx/sites-available/webssh.conf /etc/nginx/sites-enabled/ -# HAS TO BE TESTED: https://unix.stackexchange.com/questions/164866/nginx-leaves-old-socket -(sudo sed "s|STOP_SCHEDULE=\"${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}\"|STOP_SCHEDULE=\"${STOP_SCHEDULE:-TERM/5/KILL/5}\"|g" /etc/init.d/nginx) 2>/dev/null -#sudo systemctl start nginx -sudo systemctl daemon-reload - -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 +if [ "$STEP_NUMBER" -le "12" ]; then + # 12. Configure the system services + clear + echo -e "${RED}[+] Step 12: Configure the system services...${NOCOLOR}" + sudo systemctl daemon-reload + # Temporary to test TorBox TorBox mini + sudo systemctl stop hostapd + sudo systemctl disable hostapd + sudo systemctl mask hostapd + #sudo systemctl unmask hostapd + #sudo systemctl enable hostapd + #sudo systemctl start hostapd + sudo systemctl unmask isc-dhcp-server + sudo systemctl enable isc-dhcp-server + sudo systemctl start isc-dhcp-server + sudo systemctl stop tor + sudo systemctl mask tor + # Both tor services have to be masked to block outgoing tor connections + sudo systemctl mask tor@default.service + sudo systemctl unmask ssh + sudo systemctl enable ssh + sudo systemctl start ssh + # Temporary to test TorBox TorBox mini + #echo "" + #echo -e "${RED}[+] Stop logging, now...${NOCOLOR}" + #sudo systemctl stop rsyslog + #sudo systemctl disable rsyslog + #sudo systemctl mask rsyslog + #sudo systemctl stop systemd-journald-dev-log.socket + #sudo systemctl stop systemd-journald-audit.socket + #sudo systemctl stop systemd-journald.socket + #sudo systemctl stop systemd-journald.service + #sudo systemctl mask systemd-journald.service + echo"" + + # Make Nginx ready for Webssh and Onion Services + echo -e "${RED}[+] Make Nginx ready for Webssh and Onion Services${NOCOLOR}" + sudo systemctl stop nginx + (sudo rm /etc/nginx/sites-enabled/default) 2>/dev/null + (sudo rm /etc/nginx/sites-available/default) 2>/dev/null + (sudo rm -r /var/www/html) 2>/dev/null + # This is necessary for Nginx / TFS + (sudo chown torbox:torbox /var/www) 2>/dev/null + # Configuring webssh + sudo cp torbox/etc/nginx/sites-available/sample-webssh.conf /etc/nginx/sites-available/webssh.conf + sudo ln -sf /etc/nginx/sites-available/webssh.conf /etc/nginx/sites-enabled/ + # HAS TO BE TESTED: https://unix.stackexchange.com/questions/164866/nginx-leaves-old-socket + (sudo sed "s|STOP_SCHEDULE=\"${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}\"|STOP_SCHEDULE=\"${STOP_SCHEDULE:-TERM/5/KILL/5}\"|g" /etc/init.d/nginx) 2>/dev/null + #sudo systemctl start nginx + sudo systemctl daemon-reload + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -# 13. Updating run/torbox.run -clear -echo -e "${RED}[+] Step 13: Configuring TorBox and update run/torbox.run...${NOCOLOR}" -echo -e "${RED}[+] Update run/torbox.run${NOCOLOR}" -sudo sed -i "s/^NAMESERVERS=.*/NAMESERVERS=${NAMESERVERS_ORIG}/g" ${RUNFILE} -sudo sed -i "s|^GO_DL_PATH=.*|GO_DL_PATH=${GO_DL_PATH}|g" ${RUNFILE} -sudo sed -i "s|^OBFS4PROXY_USED=.*|OBFS4PROXY_USED=${OBFS4PROXY_USED}|g" ${RUNFILE} -sudo sed -i "s|^SNOWFLAKE_USED=.*|SNOWFLAKE_USED=${SNOWFLAKE_USED}|g" ${RUNFILE} -sudo sed -i "s|^WIRINGPI_USED=.*|WIRINGPI_USED=${WIRINGPI_USED}|g" ${RUNFILE} -sudo sed -i "s/^FRESH_INSTALLED=.*/FRESH_INSTALLED=3/" ${RUNFILE} -sudo sed -i "s/^ON_A_CLOUD=.*/ON_A_CLOUD=0/" ${RUNFILE} - -# NEW for TorBox mini: Set a flag (only in this installation script!) -sed -i "s/^TORBOX_MINI=.*/TORBOX_MINI=1/" ${RUNFILE} - -echo -e "${RED}[+] Update sudo setup${NOCOLOR}" -sudo mkdir /home/torbox/openvpn -sudo chown -R torbox:torbox /home/torbox/ -if ! sudo grep "# Added by TorBox" /etc/sudoers ; then - sudo printf "\n# Added by TorBox\ntorbox ALL=(ALL) NOPASSWD: ALL\n" | sudo tee -a /etc/sudoers - (sudo visudo -c) 2>/dev/null +if [ "$STEP_NUMBER" -le "13" ]; then + # 13. Updating run/torbox.run + clear + echo -e "${RED}[+] Step 13: Configuring TorBox and update run/torbox.run...${NOCOLOR}" + echo -e "${RED}[+] Update run/torbox.run${NOCOLOR}" + sudo sed -i "s/^NAMESERVERS=.*/NAMESERVERS=${NAMESERVERS_ORIG}/g" ${RUNFILE} + sudo sed -i "s|^GO_DL_PATH=.*|GO_DL_PATH=${GO_DL_PATH}|g" ${RUNFILE} + sudo sed -i "s|^OBFS4PROXY_USED=.*|OBFS4PROXY_USED=${OBFS4PROXY_USED}|g" ${RUNFILE} + sudo sed -i "s|^SNOWFLAKE_USED=.*|SNOWFLAKE_USED=${SNOWFLAKE_USED}|g" ${RUNFILE} + sudo sed -i "s|^WIRINGPI_USED=.*|WIRINGPI_USED=${WIRINGPI_USED}|g" ${RUNFILE} + sudo sed -i "s/^FRESH_INSTALLED=.*/FRESH_INSTALLED=3/" ${RUNFILE} + sudo sed -i "s/^ON_A_CLOUD=.*/ON_A_CLOUD=0/" ${RUNFILE} + + # NEW for TorBox mini: Set a flag (only in this installation script!) + sed -i "s/^TORBOX_MINI=.*/TORBOX_MINI=1/" ${RUNFILE} + + echo -e "${RED}[+] Update sudo setup${NOCOLOR}" + sudo mkdir /home/torbox/openvpn + sudo chown -R torbox:torbox /home/torbox/ + if ! sudo grep "# Added by TorBox" /etc/sudoers ; then + sudo printf "\n# Added by TorBox\ntorbox ALL=(ALL) NOPASSWD: ALL\n" | sudo tee -a /etc/sudoers + (sudo visudo -c) 2>/dev/null + fi + cd /home/torbox/ + + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' + clear + else + sleep 10 + fi fi -cd /home/torbox/ -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to continue... \e[0m' - clear -else - sleep 10 -fi +if [ "$STEP_NUMBER" -le "14" ]; then + # 14. Finishing, cleaning and booting + echo "" + echo "" + echo -e "${RED}[+] Step 14: We are finishing and cleaning up now!${NOCOLOR}" + echo -e "${RED}[+] This will erase all log files and cleaning up the system.${NOCOLOR}" + echo "" + echo -e "${YELLOW}[!] IMPORTANT${NOCOLOR}" + echo -e "${YELLOW} After this last step, TorBox has to be rebooted.${NOCOLOR}" + echo -e "${YELLOW} Afterwards, log in with \"torbox\" and your choosen password !! ${NOCOLOR}" + echo -e "${YELLOW} If connecting via TorBox's WiFi (TorBox053) use \"CHANGE-IT\" as password.${NOCOLOR}" + echo "" + read -n 1 -s -r -p $'\e[1;31mTo complete the installation, please press any key... \e[0m' + clear + echo -e "${RED}[+] Erasing big not usefull packages...${NOCOLOR}" + # Find the bigest space waster packages: dpigs -H + sudo apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light + sudo apt-get -y remove libgl1-mesa-dri texlive* lmodern + sudo apt-get -y clean + sudo apt-get -y autoclean + sudo apt-get -y autoremove + echo -e "${RED}[+] Setting the timezone to UTC${NOCOLOR}" + sudo timedatectl set-timezone UTC + echo -e "${RED}[+] Erasing ALL LOG-files...${NOCOLOR}" + echo " " + # shellcheck disable=SC2044 + for logs in $(sudo find /var/log -type f); do + echo -e "${RED}[+]${NOCOLOR} Erasing $logs" + sudo rm $logs + sleep 1 + done + echo -e "${RED}[+]${NOCOLOR} Erasing History..." + #.bash_history is already deleted + history -c + # To start TACA, notices.log has to be present + (sudo -u debian-tor touch /var/log/tor/notices.log) 2>/dev/null + (sudo chmod -R go-rwx /var/log/tor/notices.log) 2>/dev/null + #echo "" + #echo -e "${RED}[+]${NOCOLOR} Disable auto-login..." + #sudo raspi-config nonint do_boot_behaviour B1 + #echo "" + #echo -e "${RED}[+] Setting up the hostname...${NOCOLOR}" + # NEW v.0.5.3 + # This has to be at the end to avoid unnecessary error messages + #(sudo hostnamectl set-hostname "$HOSTNAME") 2>/dev/null + #(sudo systemctl restart systemd-hostnamed) 2>/dev/null + #if grep 127.0.1.1.* /etc/hosts ; then + # (sudo sed -i "s/127.0.1.1.*/127.0.1.1\t$HOSTNAME/g" /etc/hosts) 2>/dev/null + #else + # (sudo sed -i "s/^::1/127.0.1.1\t$HOSTNAME\n::1/g" /etc/hosts) 2>/dev/null + #fi + # + # OLD + echo "" + echo -e "${YELLOW}[!] IMPORTANT${NOCOLOR}" + echo -e "${YELLOW} TorBox has to be rebooted.${NOCOLOR}" + echo -e "${YELLOW} Afterwards, log in with \"torbox\" and your choosen password !! ${NOCOLOR}" + echo -e "${YELLOW} If connecting via TorBox's WiFi (TorBox053) use \"CHANGE-IT\" as password.${NOCOLOR}" + echo "" -# 14. Finishing, cleaning and booting -echo "" -echo "" -echo -e "${RED}[+] Step 14: We are finishing and cleaning up now!${NOCOLOR}" -echo -e "${RED}[+] This will erase all log files and cleaning up the system.${NOCOLOR}" -echo "" -echo -e "${YELLOW}[!] IMPORTANT${NOCOLOR}" -echo -e "${YELLOW} After this last step, TorBox has to be rebooted.${NOCOLOR}" -echo -e "${YELLOW} Afterwards, log in with \"torbox\" and your choosen password !! ${NOCOLOR}" -echo -e "${YELLOW} If connecting via TorBox's WiFi (TorBox053) use \"CHANGE-IT\" as password.${NOCOLOR}" -echo "" -read -n 1 -s -r -p $'\e[1;31mTo complete the installation, please press any key... \e[0m' -clear -echo -e "${RED}[+] Erasing big not usefull packages...${NOCOLOR}" -# Find the bigest space waster packages: dpigs -H -sudo apt-get -y --purge remove exim4 exim4-base exim4-config exim4-daemon-light -sudo apt-get -y remove libgl1-mesa-dri texlive* lmodern -sudo apt-get -y clean -sudo apt-get -y autoclean -sudo apt-get -y autoremove -echo -e "${RED}[+] Setting the timezone to UTC${NOCOLOR}" -sudo timedatectl set-timezone UTC -echo -e "${RED}[+] Erasing ALL LOG-files...${NOCOLOR}" -echo " " -# shellcheck disable=SC2044 -for logs in $(sudo find /var/log -type f); do - echo -e "${RED}[+]${NOCOLOR} Erasing $logs" - sudo rm $logs - sleep 1 -done -echo -e "${RED}[+]${NOCOLOR} Erasing History..." -#.bash_history is already deleted -history -c -# To start TACA, notices.log has to be present -(sudo -u debian-tor touch /var/log/tor/notices.log) 2>/dev/null -(sudo chmod -R go-rwx /var/log/tor/notices.log) 2>/dev/null -#echo "" -#echo -e "${RED}[+]${NOCOLOR} Disable auto-login..." -#sudo raspi-config nonint do_boot_behaviour B1 -#echo "" -#echo -e "${RED}[+] Setting up the hostname...${NOCOLOR}" -# NEW v.0.5.3 -# This has to be at the end to avoid unnecessary error messages -#(sudo hostnamectl set-hostname "$HOSTNAME") 2>/dev/null -#(sudo systemctl restart systemd-hostnamed) 2>/dev/null -#if grep 127.0.1.1.* /etc/hosts ; then -# (sudo sed -i "s/127.0.1.1.*/127.0.1.1\t$HOSTNAME/g" /etc/hosts) 2>/dev/null -#else -# (sudo sed -i "s/^::1/127.0.1.1\t$HOSTNAME\n::1/g" /etc/hosts) 2>/dev/null -#fi -# -# OLD -echo "" -echo -e "${YELLOW}[!] IMPORTANT${NOCOLOR}" -echo -e "${YELLOW} TorBox has to be rebooted.${NOCOLOR}" -echo -e "${YELLOW} Afterwards, log in with \"torbox\" and your choosen password !! ${NOCOLOR}" -echo -e "${YELLOW} If connecting via TorBox's WiFi (TorBox053) use \"CHANGE-IT\" as password.${NOCOLOR}" -echo "" - -if [ "$STEP_BY_STEP" = "--step_by_step" ]; then - echo "" - read -n 1 -s -r -p $'\e[1;31mPlease press any key to REBOOT... \e[0m' - clear -else - sleep 10 + if [ "$STEP_BY_STEP" = "--step_by_step" ]; then + echo "" + read -n 1 -s -r -p $'\e[1;31mPlease press any key to REBOOT... \e[0m' + clear + else + sleep 10 + fi fi + echo -e "${RED}[+] Rebooting...${NOCOLOR}" sync sleep 3 diff --git a/install/run_install_on_debian.sh b/install/run_install_on_debian.sh index db3bcdf0..56d63bdf 100755 --- a/install/run_install_on_debian.sh +++ b/install/run_install_on_debian.sh @@ -245,7 +245,7 @@ re-connect() echo -e "${RED}[+] Yes, we have Internet! :-)${NOCOLOR}" else echo -e "${YELLOW}[!] Hmmm, no we don't have Internet... :-(${NOCOLOR}" - echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" + echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" sleep 30 echo "" echo -e "${RED}[+] Trying again...${NOCOLOR}" @@ -706,7 +706,7 @@ while [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; do readarray -t REQUIREMENTS < requirements.txt for REQUIREMENT in "${REQUIREMENTS[@]}"; do if grep "==" <<< $REQUIREMENT ; then REQUIREMENT=$(sed s"/==.*//" <<< $REQUIREMENT); fi - VERSION=$(pip3 freeze | grep $REQUIREMENT | sed "s/${REQUIREMENT}==//" 2>&1) + VERSION=$(pip3 freeze | grep -i $REQUIREMENT | sed "s/${REQUIREMENT}==//i" 2>&1) echo -e "${RED}${REQUIREMENT} version: ${YELLOW}$VERSION${NOCOLOR}" if [ -z "$VERSION" ]; then # shellcheck disable=SC2059 diff --git a/install/run_install_on_ubuntu.sh b/install/run_install_on_ubuntu.sh index e8432478..07129f8b 100755 --- a/install/run_install_on_ubuntu.sh +++ b/install/run_install_on_ubuntu.sh @@ -251,7 +251,7 @@ re-connect() echo -e "${RED}[+] Yes, we have Internet! :-)${NOCOLOR}" else echo -e "${YELLOW}[!] Hmmm, no we don't have Internet... :-(${NOCOLOR}" - echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" + echo -e "${RED}[+] We will check again in about 30 seconds...${NOCOLOR}" sleep 30 echo "" echo -e "${RED}[+] Trying again...${NOCOLOR}" @@ -752,7 +752,7 @@ while [ "$REPLY" == "Y" ] || [ "$REPLY" == "y" ]; do readarray -t REQUIREMENTS < requirements.txt for REQUIREMENT in "${REQUIREMENTS[@]}"; do if grep "==" <<< $REQUIREMENT ; then REQUIREMENT=$(sed s"/==.*//" <<< $REQUIREMENT); fi - VERSION=$(pip3 freeze | grep $REQUIREMENT | sed "s/${REQUIREMENT}==//" 2>&1) + VERSION=$(pip3 freeze | grep -i $REQUIREMENT | sed "s/${REQUIREMENT}==//i" 2>&1) echo -e "${RED}${REQUIREMENT} version: ${YELLOW}$VERSION${NOCOLOR}" if [ -z "$VERSION" ]; then # shellcheck disable=SC2059 diff --git a/menu-update b/menu-update index fec16f98..34dd6f3c 100755 --- a/menu-update +++ b/menu-update @@ -101,6 +101,8 @@ TORBOXMENU_FORKNAME="radio24" TORBOXMENU_BRANCHNAME="master" TORBOXURL="https://github.com/$TORBOXMENU_FORKNAME/TorBox/archive/refs/heads/$TORBOXMENU_BRANCHNAME.zip" SPEED=$(grep "^EX_SLOW=" ${RUNFILE} | sed "s/EX_SLOW=//g") 2>/dev/null +ON_A_CLOUD=$(grep "^ON_A_CLOUD=.*" ${RUNFILE} | sed "s/.*=//g") +TORBOX_MINI=$(grep "^TORBOX_MINI=.*" ${RUNFILE} | sed "s/.*=//g") #Other variables TORRC="/etc/tor/torrc" @@ -434,8 +436,8 @@ update_torcfg() (sudo cp /etc/network/interfaces /etc/network/interfaces.bak) 2>/dev/null sudo cp etc/network/interfaces /etc/network/ echo -e "${RED}[+]${NOCOLOR} Copied /etc/network/interfaces -- backup done" + sudo cp etc/systemd/system/rc-local.service /etc/systemd/system/rc-local.service (sudo cp /etc/rc.local /etc/rc.local.bak) 2>/dev/null - # NEW v.0.5.3: No special rc.local for Debian/Ubuntu anymore sudo cp etc/rc.local /etc/rc.local sudo chmod a+x /etc/rc.local echo -e "${RED}[+]${NOCOLOR} Copied /etc/rc.local -- backup done" @@ -521,7 +523,6 @@ update_torcfg() echo "" echo -e "${RED}[+] Configure Nginx${NOCOLOR}" (sudo sed "s|STOP_SCHEDULE=\"${STOP_SCHEDULE:-QUIT/5/TERM/5/KILL/5}\"|STOP_SCHEDULE=\"${STOP_SCHEDULE:-TERM/5/KILL/5}\"/g" /etc/init.d/nginx) - # NEW v.0.5.3 # This has to be at the end to avoid unnecessary error messages (sudo hostnamectl set-hostname "$HOSTNAME") 2>/dev/null sudo systemctl restart systemd-hostnamed @@ -853,9 +854,15 @@ case "$CHOICE" in sleep 5 echo "" echo -e "${RED}[+] Configure the system services...${NOCOLOR}" - sudo systemctl unmask hostapd - sudo systemctl enable hostapd - sudo systemctl enable isc-dhcp-server + if [ "$TORBOX_MINI" -eq "1" ] || [ "$TORBOX_ON_A_CLOUD" -eq "1" ] ; then + sudo systemctl stop hostapd + sudo systemctl disable hostapd + sudo systemctl mask hostapd + else + sudo systemctl unmask hostapd + sudo systemctl enable hostapd + sudo systemctl enable isc-dhcp-server + fi # Copy not moving! (sudo cp /usr/share/tor/geoip* /usr/bin) 2>/dev/null sudo chmod a+x /usr/bin/geoip* @@ -880,7 +887,6 @@ case "$CHOICE" in INPUT=$(cat text/install_network_drivers-text) if (whiptail --defaultno --yesno "$INPUT" $MENU_HEIGHT $MENU_WIDTH); then clear - ON_A_CLOUD=$(grep "^ON_A_CLOUD=.*" ${RUNFILE} | sed "s/.*=//g") if [ "$ON_A_CLOUD" -eq "1" ]; then INPUT=$(cat text/on_a_cloud_warning-text) if (whiptail --title "TorBox - INFO" --yesno --defaultno --no-button "BACK!" --yes-button "DO IT!" "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH_REDUX); then @@ -888,7 +894,18 @@ case "$CHOICE" in # exitstatus = 255 means that the ESC key was pressed / exitstatus = 1 is cancelled if [ "$exitstatus" = "1" ] || [ "$exitstatus" = "255" ] ; then exit 0 ; fi else - trap "bash menu-config; exit 0" EXIT + trap "bash menu-update; exit 0" EXIT + exit 0 + fi + fi + if [ "$TORBOX_MINI" -eq "1" ]; then + INPUT=$(cat text/torbox_mini_warning-text) + if (whiptail --title "TorBox - INFO" --yesno --defaultno --no-button "BACK!" --yes-button "DO IT!" "$INPUT" $MENU_HEIGHT_15 $MENU_WIDTH_REDUX); then + exitstatus=$? + # exitstatus = 255 means that the ESC key was pressed / exitstatus = 1 is cancelled + if [ "$exitstatus" = "1" ] || [ "$exitstatus" = "255" ] ; then exit 0 ; fi + else + trap "bash menu-update; exit 0" EXIT exit 0 fi fi @@ -1347,7 +1364,6 @@ case "$CHOICE" in # Rerun the "First Start-up" script 14) clear - ON_A_CLOUD=$(grep "^ON_A_CLOUD=.*" ${RUNFILE} | sed "s/.*=//g") if [ "$ON_A_CLOUD" -eq "1" ]; then bin/first_use 1 menu-update else diff --git a/requirements.txt b/requirements.txt index a80c4fbe..c1da072e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ Flask-Cors Flask-RESTful Flask-SocketIO PGPy +Pillow PyNaCl PySocks aniso8601 @@ -23,7 +24,6 @@ numpy paramiko peewee peewee-migrate -pillow pip-autoremove pluggy pycparser diff --git a/text/torbox_mini_warning-text b/text/torbox_mini_warning-text new file mode 100644 index 00000000..08d48df6 --- /dev/null +++ b/text/torbox_mini_warning-text @@ -0,0 +1,6 @@ +Isn't that a TorBox mini installation? + +I don't think you should do that... but, hey, what +do I know? + +Do you want to do it anyway?