Skip to content

Commit

Permalink
Even if we not save the content of shared folders, we have to restore…
Browse files Browse the repository at this point in the history
… the folders to make Onion Services to work.
  • Loading branch information
radio24 committed Oct 12, 2024
1 parent c44d13e commit c54a3cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 6 additions & 1 deletion bin/backup
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
if [ "$OBFS4RELAY" == "1" ]; then BACKUPSTRING="$BACKUPSTRING ${DATA_DIR}/fingerprint ${DATA_DIR}/hashed-fingerprint ${DATA_DIR}/keys ${DATA_DIR}/pt_state"; fi
if [ "$ONIONSERVICES" == "1" ]; then BACKUPSTRING="$BACKUPSTRING ${DATA_DIR_OS}" ; fi
if [ "$ONIONAUTH" == "1" ]; then BACKUPSTRING="$BACKUPSTRING ${CLIENT_ONION_AUTH_DIR}"; fi
if [ "$SHAREDFOLDERS" == "1" ]; then BACKUPSTRING="$BACKUPSTRING ${WEBSITE_DIR}"; fi
if [ "$SHAREDFOLDERS" == "1" ]; then
BACKUPSTRING="$BACKUPSTRING ${WEBSITE_DIR}";
else
sudo find "$WEBSITE_DIR" -type d >${RUNDIR}/directories_list.txt
fi
clear
echo -e "${RED}[+] Start backup...${NOCOLOR}"
echo -e "${RED}[+] Calculating size...${NOCOLOR}"
Expand All @@ -171,6 +175,7 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
mkdir $BACKUP_DIR
fi
(sudo tar -cpzf "$OS_BK_TAR" --absolute-names ${BACKUPSTRING}) 2>/dev/null
sudo rm "${RUNDIR}/directories_list.txt"
LINK_EXIST=$(ls -L "$BACKUP_DIR/shared_folders" 2>/dev/null)
if [ -z "$LINK_EXIST" ]; then
echo -e "${RED}[+] Creating a link to the shared folders.${NOCOLOR}"
Expand Down
19 changes: 16 additions & 3 deletions bin/restore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ NOCOLOR='\033[0m'
TOR_DIR="/etc/tor/"
TORRC="${TOR_DIR}torrc"
TORRC_RESTORE="restore${TORRC}"
TOR_USER="debian-tor"
DATA_DIR_ROOT="/var/lib"
DATA_DIR="${DATA_DIR_ROOT}/tor"
DATA_DIR_OS="${DATA_DIR}/services"
Expand Down Expand Up @@ -405,7 +404,7 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
sudo sed -i 's/\\n/\n/g' "${TORRC}"
# Restoring TFS and TCS configuration
TFS_STRING=$(grep "^TFS-" restore${RUNFILE}) 2>/dev/null
TFS_STRING="$(<<< "$TFS_STRING" sed -e 's`[][\\/.*^$]`\\&`g')"
  TFS_STRING="$(<<< "$TFS_STRING" sed -e 's`[][\\/.*^$]`\\&`g')"
(sudo sed -i "s/^TFS-.*/$TFS_STRING/" ${RUNFILE}) 2>/dev/null
TCS_STRING=$(grep "^TCS-" restore${RUNFILE}) 2>/dev/null
TCS_STRING="$(<<< "$TCS_STRING" sed -e 's`[][\\/.*^$]`\\&`g')"
Expand Down Expand Up @@ -444,7 +443,19 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
fi
echo ""
sleep 1
fi
else
if [ -f restore/${RUNDIR}/directories_list.txt ]; then
if (whiptail --title "TorBox - RESTORE" --yesno "There were no shared folders backed up. However, we have a list of directories that may be created to ensure that Onion Services is working. This is, for example, needed if a restored shared folder and TFS configuration should work correctly.\n\nDo you want to create these folders (if unsure, choose YES)?" $MENU_HEIGHT_15 $MENU_WIDTH); then
clear
while IFS= read -r FOLDER; do
if [ ! -d "$FOLDER" ]; then
mkdir -p "$FOLDER"
echo -e "${RED}[+] Restoring folder: $FOLDER${NOCOLOR}"
fi
done < "restore/${RUNDIR}/directories_list.txt"
fi
fi
fi

# Catch and remove the TFS configuration from the runfile, if no Onion Service and/or shared folders are restored
TFS_STRING=$(grep -m 1 "^TFS-" "${RUNFILE}")
Expand All @@ -454,6 +465,7 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
if [ ! -z "$TFS_STRING" ]; then
echo -e "${RED}[+] Starting TFS...${NOCOLOR}"
sudo bash $TORBOX_PATH/bin/start_tfs
clear
sleep 1
fi
fi
Expand All @@ -466,6 +478,7 @@ if (whiptail --title "TorBox - INFO (scroll down!)" --scrolltext --yesno "$INPUT
if [ ! -z "$TCS_STRING" ]; then
echo -e "${RED}[+] Starting TCS...${NOCOLOR}"
sudo bash $TORBOX_PATH/bin/start_tcs
clear
sleep 1
fi
fi
Expand Down

0 comments on commit c54a3cc

Please sign in to comment.