Project

General

Profile

Feature Request #3413 » tor-hardened.sh

/opt/tor-hardened-scripts/tor-hardened.sh - nona, 2024-03-17 09:41 PM

 
1
#!/bin/sh
2

    
3
# /opt/tor-hardened-scripts/tor-hardened.sh
4

    
5
##############################################
6
# Tor-Hardened Cleaner & Startup Script #
7
##############################################
8
# Clean left over files
9
echo "Cleaning any files left over from a previous run..."
10
rm -fr /opt/torchroot/var/lib/tor/*
11
# Detect old version and upgrade
12
Torchroothash=$(sha256sum /opt/torchroot/usr/bin/tor | awk '{print $1}')
13
Toroutsidehash=$(sha256sum /usr/bin/tor | awk '{print $1}')
14
if [ "$Torchroothash" != "$Toroutsidehash" ]
15
then
16
	echo "New version of Tor detected! Updating chroot before running."
17
	rm -rf /opt/torchroot
18
	wait
19
	/usr/bin/sh -c "/opt/tor-hardened-scripts/torchroot.sh"
20
	wait
21
fi
22

    
23
# Start Tor inside of our chroot
24
echo "Running Tor..."
25
chroot --userspec=tor:tor /opt/torchroot /usr/bin/tor -f /etc/tor/torrc  --runasdaemon 1 --pidfile /run/tor/tor.pid --hush
(1-1/3)