The Original Script - ghostbusker/DarkBerryPi GitHub Wiki

This is the earliest working version of the script. I really wanted those plugins to work... The Overclocking and UI Tweaks have their own project pages now.


#!/bin/bash

## Update system and install new softwares

# Define list to uninstall
#PURGELIST="wolfram-engine scratch scratch2 libreoffice minecraft-pi sonic-pi dillo gpicview oracle-java8-jdk openjdk-7-jre oracle-java7-jdk openjdk-8-jre node nodejs node.js"

#Define list to install
APPLIST="tor tor-arm macchanger netatalk avahi-daemon"

sudo apt-get update
sudo apt-get -y install $APPLIST

sudo apt-get -y dist-upgrade
#sudo apt-get -y install $APPLIST # moved this to the bottom
#sudo apt-get clean
#sudo apt-get autoremove

## Purge apps
#apt-get -y autoremove $PURGELIST # Saves 1+GB. This broke things when it was at the top of the file

## Set hostname to "darkwindow"
#raspi-config nonint do_hostname darkwindow
# this is a bad idea, leaves fingerprint on host PC

# Set wifi country
#echo "setting Wifi country to US"
#raspi-config nonint do_wifi_country US

# Get {ghostwords}'s "chameleon" extension to fix tor fingerprint
echo "Getting {ghostwords}'s 'chameleon' extension to fix tor fingerprint"
wget https://github.com/ghostwords/chameleon/archive/master.zip
mv master.zip /home/pi/
unzip -u -o /home/pi/master.zip
rm /home/pi/master.zip

# Get {gorhill}'s "uBlock" extension to block ads
echo "Getting {gorhill}'s 'uBlock' wide-spectrum blocker extension"
wget https://github.com/gorhill/uBlock/releases/download/1.14.11b1/uBlock0.chromium.zip
mv uBlock0.chromium.zip /home/pi/
unzip -u -o /home/pi/uBlock0.chromium.zip
rm /home/pi/uBlock0.chromium.zip

# Get {EFF}'s "https-everywhere" extension to force encryption
echo "Get {EFF}'s 'https-everywhere' extension to force encryption"
wget https://www.eff.org/files/https-everywhere-chrome-2017.9.12.crx
mkdir /home/pi/https-everywhere/
mv https-everywhere-chrome-2017.9.12.crx /home/pi/https-everywhere/
unzip -u -o /home/pi/https-everywhere/https-everywhere-chrome-2017.9.12.crx
rm /home/pi/https-everywhere/https-everywhere-chrome-2017.9.12.crx 



# Define config files being modified
CMDLINE="/boot/cmdline.txt"
CONFIG="/boot/config.txt"
RCLOCAL="/etc/rc.local"
PANEL="/home/pi/.config/lxpanel/LXDE-pi/panels/panel"

# Disable SSH, enable VNC, Bonjour
raspi-config nonint do_ssh 1
raspi-config nonint do_vnc 0
#update-rc.d avahi-daemon defaults  # may not be neccasary



## Configure Overclock for RPi0W

# If a line containing "arm_freq" exists
if grep -Fq "arm_freq" $CONFIG
then
	# Replace the line
	echo "Modifying arm_freq"
	sed -i "/arm_freq/c\arm_freq=1100" $CONFIG
else
	# Create the definition
	echo "arm_freq not defined. Creating definition"
	echo "arm_freq=1100" >> $CONFIG
fi

# If a line containing "gpu_freq" exists
if grep -Fq "gpu_freq" $CONFIG
then
	# Replace the line
	echo "Modifying gpu_freq"
	sed -i "/gpu_freq/c\gpu_freq=500" $CONFIG
else
	# Create the definition
	echo "gpu_freq not defined. Creating definition"
	echo "gpu_freq=500" >> $CONFIG
fi

# If a line containing "gpu_mem" exists
if grep -Fq "gpu_mem" $CONFIG
then
	# Replace the line
	echo "Modifying gpu_mem"
	sed -i "/gpu_mem/c\gpu_mem=128" $CONFIG
else
	# Create the definition
	echo "gpu_mem not defined. Creating definition"
	echo "gpu_mem=128" >> $CONFIG
fi

# If a line containing "core_freq" exists
if grep -Fq "core_freq" $CONFIG
then
	# Replace the line
	echo "Modifying core_freq"
	sed -i "/core_freq/c\core_freq=500" $CONFIG
else
	# Create the definition
	echo "core_freq not defined. Creating definition"
	echo "core_freq=500" >> $CONFIG
fi

# If a line containing "sdram_freq" exists
if grep -Fq "sdram_freq" $CONFIG
then
	# Replace the line
	echo "Modifying sdram_freq"
	sed -i "/sdram_freq/c\sdram_freq=500" $CONFIG
else
	# Create the definition
	echo "sdram_freq not defined. Creating definition"
	echo "sdram_freq=500" >> $CONFIG
fi

# If a line containing "sdram_schmoo" exists
if grep -Fq "sdram_schmoo" $CONFIG
then
	# Replace the line
	echo "Modifying sdram_schmoo"
	sed -i "/sdram_schmoo/c\sdram_schmoo=0x02000020" $CONFIG
else
	# Create the definition
	echo "sdram_schmoo not defined. Creating definition"
	echo "sdram_schmoo=0x02000020" >> $CONFIG
fi

# This modifies BOTH over_voltage and sdram_over_voltage!
# If a line containing "over_voltage" exists
# this needs to be redone with some additional sed flags so you dont do both at once
if grep -Fq "over_voltage" $CONFIG
then
	# Delete both over_voltage entries! Then replace
	echo "Modifying over_voltage amd sdram_over_voltage"
	sed -i "/over_voltage/d" $CONFIG
	echo "over_voltage=3" >> $CONFIG
	echo "sdram_over_voltage=2" >> $CONFIG
else
	# Create the definition
	echo "over_voltage not defined. Creating definition"
	echo "over_voltage=3" >> $CONFIG
	echo "sdram_over_voltage not defined. Creating definition"
	echo "sdram_over_voltage=2" >> $CONFIG
fi

# If a line containing "dtparam=sd_overclock" exists
if grep -Fq "dtparam=sd_overclock" $CONFIG
then
	# Replace the line
	echo "Modifying dtparam=sd_overclock"
	sed -i "/dtparam=sd_overclock/c\dtparam=sd_overclock=100" $CONFIG
else
	# Create the definition
	echo "dtparam=sd_overclock not defined. Creating definition"
	echo "dtparam=sd_overclock=100" >> $CONFIG
fi

# Final overclock setting VOIDS WARRANTY so check with user
# If a line containing "force_turbo=1" exists
if grep -Fq "force_turbo=1" $CONFIG
then
	# Do nothing
	echo "CPU Turbo already enabled"
else
	# Create the definition but check with user first
	echo "Force Turbo on CPU?"
	echo "THIS VOIDS THE WARRANTY on your $10 investment"
	echo "MUST have a heatsink for this one!"
	echo -n "set 'force_turbo=1'? (y/n)? "
	read answer
	if echo "$answer" | grep -iq "^y" ;
	then
		echo "force_turbo=1" >> $CONFIG
	else
		echo "CPU Turbo NOT enabled at this time"
	fi
fi




## Spoof MAC on login

# If a line containing "macchanger" exists
if grep -Fq "macchanger" $RCLOCAL
then
	# Do nothing
	echo "macchanger already set to run at login"
else
	# Insert the command before the last line, "exit 0"
	echo "Modifying /etc/rc.local to randomize wlan0 at login"
	sed -i "/exit 0/c\sudo ifconfig wlan0 down" $RCLOCAL
	echo "sudo macchanger -r wlan0" >> $RCLOCAL
	echo "sudo ifconfig wlan0 up" >> $RCLOCAL
	echo "exit 0" >> $RCLOCAL
fi



## Enable USB Ethernet Gadget

# If a line for ethernet gadget already exists
if grep -Fq "modules-load=dwc2,g_ether" $CMDLINE
then
	# Do nothing
	echo "USB Ethernet already enabled"
else
	# Insert this string precisely
	sed -i "s/rootwait/rootwait modules-load=dwc2,g_ether/" $CMDLINE
fi

# If a line containing "dtoverlay-dwc2" exists
if grep -Fq "dtoverlay=dwc2" $CONFIG
then
	# Do nothing
	echo "dtoverlay already enabled"
else
	# Create the definition
	echo "dtoverlay not defined. Creating definition"
	echo "dtoverlay=dwc2" >> $CONFIG
fi



## Fix desktop resolution for VNC

# If a line containing "framebuffer_width" exists
if grep -Fq "framebuffer_width" $CONFIG
then
	# Replace the line
	echo "Modifying framebuffer_width"
	sed -i "/framebuffer_width/c\framebuffer_width=1366" $CONFIG
else
	# Create the definition
	echo "framebuffer_width not defined. Creating definition"
	echo "framebuffer_width=1366" >> $CONFIG
fi

# If a line containing "framebuffer_height" exists
if grep -Fq "framebuffer_height" $CONFIG
then
	# Replace the line
	echo "Modifying framebuffer_height"
	sed -i "/framebuffer_height/c\framebuffer_height=768" $CONFIG
else
	# Create the definition
	echo "framebuffer_height not defined. Creating definition"
	echo "framebuffer_height=768" >> $CONFIG
fi



## Create Desktop icon for tor
printf "[Desktop Entry]\nName=TorBrowse\nComment=Tor thru Chrome\nIcon=/usr/share/pixmaps/chromium-browser.png\nExec=sudo chromium-browser --no-sandbox --disable-background-networking --system-developer-mode --disable-reading-from-canvas --aggressive-cache-discard --disable-cache --disable-application-cache --disable-offline-load-stale-cache --disk-cache-size=0 --no-default-browser-check --no-referrers --enable-low-res-tiling --enable-low-end-device-mode --use-fake-device-for-media-stream --use-mock-keychain --window-size="1024,768" --load-extension=/home/pi/chameleon-master/chrome/,/home/pi/uBlock0.chromium/,/home/pi/https-everywhere-chrome-2017.9.12.crx --disable-extensions-except=/home/pi/chameleon-master/chrome/,/home/pi/uBlock0.chromium/,/home/pi/https-everywhere-chrome-2017.9.12.crx --proxy-server=socks5://127.0.0.1:9050 --user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36' https://check.torproject.org https://panopticlick.eff.org/tracker \nType=Application\nEncoding=UTF-8\nTerminal=True\nCategories=None;\n" > /home/pi/Desktop/TorBrowse.desktop

printf "[Desktop Entry]\nName=TorBrowseIncognito\nComment=Tor thru Chrome Incognito\nIcon=/usr/share/pixmaps/chromium-browser.png\nExec=sudo chromium-browser --incognito --no-sandbox --disable-background-networking --system-developer-mode --disable-reading-from-canvas --aggressive-cache-discard --disable-cache --disable-application-cache --disable-offline-load-stale-cache --disk-cache-size=0 --no-default-browser-check --no-referrers --enable-low-res-tiling --enable-low-end-device-mode --use-fake-device-for-media-stream --use-mock-keychain --window-size="1024,768" --proxy-server=socks5://127.0.0.1:9050 --user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36' https://check.torproject.org https://panopticlick.eff.org/tracker \nType=Application\nEncoding=UTF-8\nTerminal=True\nCategories=None;\n" > /home/pi/Desktop/TorBrowseIncognito.desktop

## Create Desktop icon for tor-arm monitor
printf "[Desktop Entry]\nName=TorMonitor\nComment=Tor-arm monitor\nIcon=/usr/share/pixmaps/chromium-browser.png\nExec=lxterminal -e 'sudo arm'\nType=Application\nEncoding=UTF-8\nTerminal=True\nCategories=None;\n" > /home/pi/Desktop/TorMonitor.desktop

## Create Desktop icon for macchanger confirmation
printf "[Desktop Entry]\nName=MacChangerConfirm\nComment=Did macchanger spoof mac?\nIcon=/usr/share/pixmaps/chromium-browser.png\nExec=lxterminal -e 'sudo macchanger wlan0'\nType=Application\nEncoding=UTF-8\nTerminal=True\nCategories=None;\n" > /home/pi/Desktop/MacChangerConfirm.desktop


## Add some panel applets to the taskbar
# checking for pre-existing applets first
if grep -Fq "type=cpu" $PANEL
then
	# Panel already present, try next
	echo "CPU panel already present"
else
	# Add CPU panel
	echo "Adding CPU panel"
	printf "Plugin {\n  type=cpu\n  Config {\n    ShowPercent=1\n    Foreground=#ffff00000000\n    Background=#d3d3d3d3d3d3\n  }\n}" >> $PANEL
fi
	
if grep -Fq "type=thermal" $PANEL
then
	# Panel already present, try next
	echo "Thermal panel already present"
else		
	# Add Thermal panel
	echo "Adding Thermal panel"
	printf "Plugin {\n  type=thermal\n  Config {\n    NormalColor=#00ff00\n    Warning1Color=#FF8C00\n    Warning2Color=#ff0000\n    AutomaticLevels=0\n    Warning1Temp=45\n    Warning2Temp=50\n    AutomaticSensor=1\n  }\n}" >> $PANEL
fi

if grep -Fq "type=monitors" $PANEL
then
	# Panel already present, try next
	echo "Monitor panel already present"
else
	# Add Monitor panel
	echo "Adding Monitor panel"
	printf "Plugin {\n  type=monitors\n  Config {\n    DisplayCPU=0\n    DisplayRAM=1\n    RAMColor=#0000FF\n  }\n}" >> $PANEL
fi

if grep -Fq "type=netstatus" $PANEL
then
	# Panel already present
	echo "NetStatus panel already present"
else
	# Add NetStatus panel
	echo "Adding NetStatus panel"
	printf "Plugin {\n  type=netstatus\n  Config {\n  }\n}" >> $PANEL
fi


# Install Complete
echo "Install complete."
echo -n "Shutdown Now? (y/n)? "
read answer
if echo "$answer" | grep -iq "^y" ;then
    echo "shutting down..."
	sudo shutdown now
fi