From 86be7beca8aebcc932d746b7aeff50455b4b274a Mon Sep 17 00:00:00 2001 From: Toasterbirb Date: Wed, 15 Nov 2023 18:48:24 +0200 Subject: [PATCH] Move Tor related functions to birb_funcs This way the same functions can be used by birbd if needed --- birb | 21 --------------------- birb_funcs | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/birb b/birb index cd37e47..e1fdc5f 100755 --- a/birb +++ b/birb @@ -508,27 +508,6 @@ add_package_to_nest() fi } -# Check if the package has a source URL that points to an .onion address -# Args: [url] -onion_check() -{ - grep -q "http://[A-Za-z2-7]*d.onion" <<< "$1" -} - -# Check if tor is installed and running. Also make sure that torsocks is installed -tor_check() -{ - println "Checking if Tor is installed and running..." - [ ! -f /usr/bin/tor ] && println ERROR "Tor isn't installed! Birb cannot download packages from .onion addresses without it (>﹏<)" && exit 1 - [ ! -f /usr/bin/torsocks ] && println ERROR "torsocks isn't installed! Birb cannot download packages from .onion addresses without it (」><)」" && exit 1 - - if ! pgrep -x tor &>/dev/null - then - println ERROR "Tor isn't running! Birb cannot download packages from .onion addresses without it (ノω・、)" - exit 1 - fi -} - install_package() { root_check diff --git a/birb_funcs b/birb_funcs index a3a9fdd..65c2c24 100644 --- a/birb_funcs +++ b/birb_funcs @@ -37,3 +37,27 @@ major_version() { echo "$1" | cut -d'.' -f1 } + + +# Tor related functions + +# Check if the package has a source URL that points to an .onion address +# Args: [url] +onion_check() +{ + grep -q "http://[A-Za-z2-7]*d.onion" <<< "$1" +} + +# Check if tor is installed and running. Also make sure that torsocks is installed +tor_check() +{ + println "Checking if Tor is installed and running..." + [ ! -f /usr/bin/tor ] && println ERROR "Tor isn't installed! Birb cannot download packages from .onion addresses without it (>﹏<)" && exit 1 + [ ! -f /usr/bin/torsocks ] && println ERROR "torsocks isn't installed! Birb cannot download packages from .onion addresses without it (」><)」" && exit 1 + + if ! pgrep -x tor &>/dev/null + then + println ERROR "Tor isn't running! Birb cannot download packages from .onion addresses without it (ノω・、)" + exit 1 + fi +}