Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. RELEASE='buster'
  2. IS_EXIT=false
  3. INSTALL_NYX=true
  4. CHECK_IPV6=true
  5. ENABLE_AUTO_UPDATE=true
  6.  
  7. echo -e "\e[36m" #cyan
  8. cat << "EOF"
  9.  
  10. _____ ___ _
  11. |_ _|__ _ _ ___| _ \___| |__ _ _ _ __ ___
  12. | |/ _ \ '_|___| / -_) / _` | || |_/ _/ _ \
  13. |_|\___/_| |_|_\___|_\__,_|\_, (_)__\___/
  14. |__/
  15.  
  16. EOF
  17.  
  18. echo -e "\e[39m" #default
  19. echo " [Relay Setup]"
  20. echo "This script will ask for your sudo password."
  21. echo "----------------------------------------------------------------------"
  22.  
  23. echo "Updating package list..."
  24. sudo apt-get -y update > /dev/null
  25.  
  26. echo "Installing necessary packages..."
  27. sudo apt-get -y install apt-transport-https psmisc dirmngr ntpdate curl > /dev/null
  28.  
  29. echo "Updating NTP..."
  30. sudo ntpdate pool.ntp.org > /dev/null
  31.  
  32. echo "Adding Torproject apt repository..."
  33. sudo touch /etc/apt/sources.list.d/tor1.list
  34. echo "deb https://deb.torproject.org/torproject.org $RELEASE main" | sudo tee /etc/apt/sources.list.d/tor1.list > /dev/null
  35. echo "deb-src https://deb.torproject.org/torproject.org $RELEASE main" | sudo tee --append /etc/apt/sources.list.d/tor1.list > /dev/null
  36.  
  37. echo "Adding Torproject GPG key..."
  38. curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import > /dev/null
  39. gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add - > /dev/null
  40.  
  41. echo "Updating package list..."
  42. sudo apt-get -y update > /dev/null
  43.  
  44. if $INSTALL_NYX
  45. then
  46. echo "Installing NYX..."
  47. sudo apt-get -y install nyx > /dev/null
  48. fi
  49.  
  50. echo "Installing Tor..."
  51. sudo apt-get -y install tor deb.torproject.org-keyring > /dev/null
  52. sudo chown -R debian-tor1:debian-tor1 /var/log/tor1
  53.  
  54. echo "Setting Tor config..."
  55. cat << 'EOF' | sudo tee /etc/tor1/torrc > /dev/null
  56. SocksPort 0
  57. RunAsDaemon 1
  58. ORPort 9002
  59. ORPort [INSERT_IPV6_ADDRESS]:9002
  60. Nickname PIXEL02
  61. ContactInfo || PIXEL02 powered by createPixel.de || abuse@createpixel.de ||
  62. Log notice file /var/log/tor1/notices.log
  63. DirPort 9032
  64. ExitPolicy reject6 *:*, reject *:*
  65. DisableDebuggerAttachment 0
  66. ControlPort 9052
  67. CookieAuthentication 1
  68.  
  69. EOF
  70.  
  71. if $IS_EXIT
  72. then
  73. echo "Downloading Exit Notice to /etc/tor1/tor-exit-notice.html..."
  74. echo -e "\e[1mPlease edit this file and replace FIXME_YOUR_EMAIL_ADDRESS with your e-mail address!"
  75. echo -e "\e[1mAlso note that this is the US version. If you are not in the US please edit the file and remove the US-Only sections!\e[0m"
  76. sudo wget -q -O /etc/tor1/tor-exit-notice.html "https://raw.githubusercontent.com/flxn/tor-relay-configurator/master/misc/tor-exit-notice.html"
  77. fi
  78.  
  79. if $CHECK_IPV6
  80. then
  81. IPV6_ADDRESS=$(ip -6 addr | grep inet6 | grep "scope global" | awk '{print $2}' | cut -d'/' -f1)
  82. if [ -z "$IPV6_ADDRESS" ]
  83. then
  84. sudo /etc/init.d/tor1 stop
  85. echo -e "\e[31mCould not automatically find your IPv6 address"
  86. sudo sed -i -e '/INSERT_IPV6_ADDRESS/d' /etc/tor1/torrc
  87. sudo sed -i -e 's/IPv6Exit 1/IPv6Exit 0/' /etc/tor1/torrc
  88. echo -e "\e[31mIPv6 support has been disabled\e[39m"
  89. echo "If you want to enable it manually find out your IPv6 address and add this line to your /etc/tor/torrc"
  90. echo "ORPort [YOUR_IPV6_ADDRESS]:YOUR_ORPORT (example: \"ORPort [2001:123:4567:89ab::1]:9001\")"
  91. echo "Then run \"sudo /etc/init.d/tor1 restart\" to rstart Tor"
  92. else
  93. sudo sed -i "s/INSERT_IPV6_ADDRESS/$IPV6_ADDRESS/" /etc/tor1/torrc
  94. echo -e "\e[32mIPv6 Support enabled ($IPV6_ADDRESS)\e[39m"
  95. fi
  96. fi
  97.  
  98. if $ENABLE_AUTO_UPDATE
  99. then
  100. echo "Enabling unattended upgrades..."
  101. sudo apt-get install -y unattended-upgrades apt-listchanges
  102. DISTRO=$(lsb_release -is)
  103. sudo wget -q -O /etc/apt/apt.conf.d/50unattended-upgrades "https://raw.githubusercontent.com/flxn/tor-relay-configurator/master/misc/50unattended-upgrades.$DISTRO"
  104. fi
  105.  
  106. sleep 10
  107.  
  108. echo "Reloading Tor config..."
  109. sudo /etc/init.d/tor1 restart
  110.  
  111. echo -e "\e[32mSetup finished\e[39m"
  112. echo "----------------------------------------------------------------------"
  113. echo "Tor will now check if your ports are reachable. This may take up to 20 minutes."
  114. echo "Check /var/log/tor/notices.log for an entry like:"
  115. echo "\"Self-testing indicates your ORPort is reachable from the outside. Excellent.\""
  116. echo "----------------------------------------------------------------------"
  117. #sleep 5
  118. #tail -f /var/log/tor/log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement