#!/bin/bash

# Spoof "EntryNode" in latest Tails 4.18
# so change hole circle
# get new identity?

# YOU only need to type in the last used EntryNode as country code
# for example "united states" = "us" (without quotes)

 mkdir -p /root/torrc
 cp /etc/tor/torrc /etc/tor/torrc.backup
 cp /etc/tor/torrc /etc/tor/torrc.super.backup
 cp /etc/tor/torrc.super.backup /root/torrc/torrc
 sed -n 31p /root/torrc/torrc > /root/torrc/excludes.txt
 sed 's/ StrictNodes 1//g' /root/torrc/excludes.txt > /root/torrc/tmp;mv /root/torrc/tmp /root/torrc/excludes.txt 
 echo ; echo ; echo ; echo "Type in last EntryNode:" ; read state ; echo ,{$state} > /root/torrc/state.txt
 echo `cat /root/torrc/excludes.txt /root/torrc/state.txt` | sed 's/ //2' > /root/torrc/set.txt
 echo `cat /root/torrc/set.txt ; echo ' StrictNodes 1'` > /root/torrc/pastetotorrc.txt
 sed 31d /root/torrc/torrc > /root/torrc/delete37.txt
 cat /root/torrc/delete37.txt | sed 31,34d > /root/torrc/final.txt ; cat /root/torrc/pastetotorrc.txt >> /root/torrc/final.txt ; echo LongLivedPorts 21, 22, 80, 443, 706, 1863, 5050, 5190, 5222, 5223, 6523, 6667, 6697, 8080, 8300, 9001, 9030 StrictNodes 1 >> /root/torrc/final.txt ; echo RejectPlaintextPorts 23,109 >> /root/torrc/final.txt ; mv /root/torrc/final.txt /etc/tor/torrc ; echo ; echo ; echo ; sed -n 31p /etc/tor/torrc ; echo ; echo ; echo
 service network-manager restart