#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2011 Christopher Bratusek		#
#							#
#########################################################

torswitch () {

	if [[ $EUID == 0 ]]; then

		case $1 in
			*on )
				if [[ $(grep forward-socks4a /etc/privoxy/config) == "" ]]; then
					echo "forward-socks4a / 127.0.0.1:9050 ." >> /etc/privoxy/config
				else
					sed -e 's/\# forward-socks4a/forward-socks4a/g' -i /etc/privoxy/config
					/etc/init.d/tor restart
					/etc/init.d/privoxy restart
				fi
			;;

			*off )
				sed -e 's/forward-socks4a/\# forward-socks4a/g' -i /etc/privoxy/config
				/etc/init.d/tor restart
				/etc/init.d/privoxy restart
			;;
		esac

	else	echo -e "${ered} You're not root!"
	fi

}

repoadd () {

	reprepro -Vb "$REPO_HOME" include "$REPO_DIST" *.changes
	cd "$REPO_HOME"/dists/"$REPO_DIST"
	gpg -abs -o Release.gpg Release

}

wipe () {

	if [[ $EUID == 0 ]]; then
		cryptsetup -d /dev/urandom -c aes-xts-plain create delete $1
		shred -vzn 0 /dev/mapper/delete
		sync && sleep 4
		cryptsetup remove delete
	else	echo -e "${ered} You're not root!"
	fi

}

remount () {

	DEVICE=$1
	shift

	mount -oremount,$@ $DEVICE

}

treeps () {

	ps f -u $USER -o command,pid,%cpu,%mem,time,etime,tty | \
		awk 'NR <= 1 {print;next} !/awk/ && $0~var' var=${1:-".*"}

}