mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-28 16:58:03 +01:00
add nginx, tor config, status and menu
This commit is contained in:
parent
6497ce90e4
commit
73c6b065c3
1 changed files with 82 additions and 4 deletions
|
@ -14,6 +14,58 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
source /mnt/hdd/raspiblitz.conf
|
||||||
|
|
||||||
|
isInstalled=$(compgen -u | grep -c strfry)
|
||||||
|
isActive=$(sudo ls /etc/systemd/system/strfry.service 2>/dev/null | grep -c 'strfry.service')
|
||||||
|
localip=$(hostname -I | awk '{print $1}')
|
||||||
|
toraddress=$(sudo cat /mnt/hdd/tor/strfry/hostname 2>/dev/null)
|
||||||
|
|
||||||
|
if [ "$1" = "status" ]; then
|
||||||
|
echo "version='${VERSION}'"
|
||||||
|
echo "installed='${isInstalled}'"
|
||||||
|
echo "active='${isActive}'"
|
||||||
|
echo "localIP='${localip}'"
|
||||||
|
echo "httpPort='${portTCP}'"
|
||||||
|
echo "httpsPort='${portSSL}'"
|
||||||
|
echo "toraddress='${toraddress}'"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# show info menu
|
||||||
|
if [ "$1" = "menu" ]; then
|
||||||
|
|
||||||
|
if [ ${isActive} -eq 1 ]; then
|
||||||
|
# get network info
|
||||||
|
fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2)
|
||||||
|
|
||||||
|
if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then
|
||||||
|
# Info with Tor
|
||||||
|
sudo /home/admin/config.scripts/blitz.display.sh qr "${toraddress}"
|
||||||
|
whiptail --title " strfry " --msgbox "Connect to:
|
||||||
|
wss://${localip}:${portSSL}\n
|
||||||
|
with Fingerprint:
|
||||||
|
${fingerprint}\n
|
||||||
|
Hidden Service address is (see LCD for QR):
|
||||||
|
${toraddress}
|
||||||
|
" 16 67
|
||||||
|
sudo /home/admin/config.scripts/blitz.display.sh hide
|
||||||
|
else
|
||||||
|
# Info without Tor
|
||||||
|
whiptail --title " strfry " --msgbox "Connect to:
|
||||||
|
wss://${localip}:${portSSL}\n
|
||||||
|
with Fingerprint:
|
||||||
|
${fingerprint}\n
|
||||||
|
Activate Tor to serve an .onion address.
|
||||||
|
" 15 57
|
||||||
|
fi
|
||||||
|
echo "# please wait ..."
|
||||||
|
else
|
||||||
|
echo "# *** strfry is not installed ***"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$1" = "on" ]; then
|
if [ "$1" = "on" ]; then
|
||||||
|
|
||||||
LIMITS=("strfry soft nofile 1000000" "strfry hard nofile 1000000")
|
LIMITS=("strfry soft nofile 1000000" "strfry hard nofile 1000000")
|
||||||
|
@ -81,16 +133,43 @@ if [ "$1" = "on" ]; then
|
||||||
sudo systemctl start strfry
|
sudo systemctl start strfry
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo ufw allow ${portTCP} comment 'strfry TCP'
|
|
||||||
sudo ufw allow ${portSSL} comment 'strfry SSL'
|
sudo ufw allow ${portSSL} comment 'strfry SSL'
|
||||||
|
|
||||||
# nginx
|
# nginx
|
||||||
|
cat <<EOF | sudo tee /etc/nginx/sites-available/strfry
|
||||||
|
server {
|
||||||
|
listen ${portSSL} ssl http2;
|
||||||
|
listen [::]:${portSSL} ssl http2;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
include /etc/nginx/snippets/ssl-params.conf;
|
||||||
|
include /etc/nginx/snippets/ssl-certificate-app-data.conf;
|
||||||
|
|
||||||
|
include /etc/nginx/snippets/gzip-params.conf;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access_strfry.log;
|
||||||
|
error_log /var/log/nginx/error_strfry.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:${portTCP};
|
||||||
|
|
||||||
|
# needed for websocket connections
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade \$http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
include /etc/nginx/snippets/ssl-proxy-params.conf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo ln -sf /etc/nginx/sites-available/strfry /etc/nginx/sites-enabled/strfry
|
||||||
|
|
||||||
# test and reload nginx
|
# test and reload nginx
|
||||||
sudo nginx -t && sudo systemctl reload nginx
|
sudo nginx -t && sudo systemctl reload nginx
|
||||||
|
|
||||||
# Tor
|
# Tor
|
||||||
/home/admin/config.scripts/tor.onion-service.sh strfry ${portTCP} ${portTCP} ${portSSL} ${portSSL}
|
/home/admin/config.scripts/tor.onion-service.sh strfry 80 ${portTCP}
|
||||||
|
|
||||||
# setting value in raspiblitz config
|
# setting value in raspiblitz config
|
||||||
/home/admin/config.scripts/blitz.conf.sh set strfry "on"
|
/home/admin/config.scripts/blitz.conf.sh set strfry "on"
|
||||||
|
@ -103,11 +182,10 @@ if [ "$1" = "off" ]; then
|
||||||
sudo rm -f /etc/strfry.conf
|
sudo rm -f /etc/strfry.conf
|
||||||
sudo rm -f /etc/systemd/system/strfry.service
|
sudo rm -f /etc/systemd/system/strfry.service
|
||||||
|
|
||||||
sudo ufw delete allow ${portTCP}
|
|
||||||
sudo ufw delete allow ${portSSL}
|
sudo ufw delete allow ${portSSL}
|
||||||
|
|
||||||
# Tor
|
# Tor
|
||||||
/home/admin/config.scripts/tor.onion-service.sh strfry off
|
/home/admin/config.scripts/tor.onion-service.sh off strfry
|
||||||
|
|
||||||
sudo userdel -rf strfry
|
sudo userdel -rf strfry
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue