#!/bin/bash ############################################################################ # Squid Proxy Installer (SPI) # # Version: 2.0 Build 2017 # # Branch: Stable # #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# # Author: Hidden Refuge (© 2014 - 2017) # # Modified for me: Icharis, Thanks to hidden-refuge for leading the # # way. and thanks to ADHD-- copied from his repo # # License: MIT License # #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# # GitHub Repo: https://github.com/hidden-refuge/spi/ # # SPI Wiki: https://github.com/hidden-refuge/spi/wiki # ############################################################################ # Declaring a few misc variables vspiversion=2.0 # SPI version vspibuild=2017 # SPI build number vbranch=Stable # SPI build branch vsysarch=$(getconf LONG_BIT) # System architecture # Function for iptables rules (CentOS 5 & 6) firew1 () { # Opening default Squid port 3128 for clients to connect iptables -I INPUT -p tcp --dport 3128 -j ACCEPT # Saving firewall rules service iptables save } # Function for iptables rules (CentOS 7, Debian, Ubuntu, Fedora) firew2 () { # Opening default Squid port 3128 for clients to connect iptables -I INPUT -p tcp --dport 3128 -j ACCEPT # Saving firewall rules iptables-save } # Function for RHEL 5 Linux distributions rhel5 () { # Downloading and installing necessary repo for newer Squid 3 versions for CentOS 5 rpm -Uvh http://flexbox.sourceforge.net/centos/5/i386/flexbox-release-1-4.3.noarch.rpm # Installing necessary packages (Squid, httpd for htpasswd and dependencies) yum install perl-DBI libecap squid httpd -y # Asking user to set a username via read and writing it into $usrn read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password htpasswd -c /etc/squid/passwd $usrn # Downloading necessary Squid.conf for the corresponding OS & system architecture case $vsysarch in 32) # 32 bit Squid configuration wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-rhel5632.conf --no-check-certificate;; 64) # 64 bit Squid configuration wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-rhel5664.conf --no-check-certificate;; esac # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid/blacklist.acl # Restarting Squid and enabling its service service squid restart && chkconfig squid on # Turning off httpd and removing it from services (post installation of yum enabled it but we don't need it) service httpd stop && chkconfig httpd off # Running function firew1 firew1 } # Function for RHEL 6 Linux distributions rhel6 () { # Installing necessary packages (Squid, httpd-tools for htpasswd and dependencies) yum install squid httpd-tools -y # Asking user to set a username via read and writing it into $usrn read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password htpasswd -c /etc/squid/passwd $usrn # Downloading necessary Squid.conf for the corresponding OS & system architecture case $vsysarch in 32) # 32 bit Squid configuration wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-rhel5632.conf --no-check-certificate;; 64) # 64 bit Squid configuration wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-rhel5664.conf --no-check-certificate;; esac # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid/blacklist.acl # Restarting Squid and enabling its service service squid restart && chkconfig squid on # Running function firew1 firew1 } # Function for RHEL 7 Linux distributions rhel7 () { # Installing necessary packages (Squid, httpd-tools for htpasswd and dependencies) yum install nano dos2unix squid httpd-tools -y # Asking user to set a username via read and writing it into $usrn read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password htpasswd -c /etc/squid/passwd $usrn # Downloading Squid configuration wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-rhel7.conf --no-check-certificate # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid/blacklist.acl # Restarting Squid and enabling its service systemctl restart squid.service && systemctl enable squid.service # Running function firew2 firew2 } # Function for Debian "Squeeze" 6 and Debian "Wheezy" 7 deb () { # Updating package database apt-get update # Installing necessary packages (Squid, apache2-utils for htpassword and dependencies) apt-get install apache2-utils squid3 -y # Asking user to set a username via read and writing it into $usrn read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password htpasswd -c /etc/squid3/passwd $usrn # Downloading Squid configuration wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-debian.conf --no-check-certificate # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid3/blacklist.acl # Restarting Squid and enabling its service service squid3 restart && update-rc.d squid3 defaults # Running function firew2 firew2 } # Function for Debian "Jessie" 8 deb8 () { # Updating package database apt-get update # Installing necessary packages (Squid, apache2-utils for htpassword and dependencies) apt-get install apache2-utils squid3 -y # Asking user to set a username via read and writing it into $usrn read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password htpasswd -c /etc/squid3/passwd $usrn # Downloading Squid configuration wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-jessie.conf --no-check-certificate # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid3/blacklist.acl # Restarting Squid and enabling its service service squid3 restart && update-rc.d squid3 defaults # Running function firew2 firew2 } # Function for Ubuntu User Auth ubt () { # Updating package database apt-get update # Installing necessary packages (Squid, apache2-utils for htpassword and dependencies) apt-get install nano dos2unix apache2-utils squid3 -y # Asking user to set a username via read and writing it into $usrn read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password htpasswd -c /etc/squid3/passwd $usrn # Downloading Squid configuration wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-ubuntu.conf --no-check-certificate # Copying squid3.conf from init to init.d for startup script cp /etc/init/squid3.conf /etc/init.d/squid3 # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid3/blacklist.acl # Restarting Squid and enabling its service service squid3 restart && update-rc.d squid3 defaults # Running function firew2 firew2 } # Function for Ubuntu Ip Auth ubt_ip () { # Updating package database apt-get update # Installing necessary packages (Squid, apache2-utils for htpassword and dependencies) apt-get install nano dos2unix apache2-utils squid3 -y # Asking user to set a username via read and writing it into $usrn # read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password # htpasswd -c /etc/squid3/passwd $usrn # Downloading Squid configuration wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-ubuntu_ip_auth.conf --no-check-certificate # Copying squid3.conf from init to init.d for startup script cp /etc/init/squid3.conf /etc/init.d/squid3 # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid3/blacklist.acl # Restarting Squid and enabling its service service squid3 restart && update-rc.d squid3 defaults # Running function firew2 firew2 } # Function for Ubuntu No Auth ubt_null () { # Updating package database apt-get update # Installing necessary packages (Squid, apache2-utils for htpassword and dependencies) apt-get install nano dos2unix apache2-utils squid3 -y # Asking user to set a username via read and writing it into $usrn # read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password # htpasswd -c /etc/squid3/passwd $usrn # Downloading Squid configuration wget -O /etc/squid3/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-ubuntu_no_auth.conf --no-check-certificate # Copying squid3.conf from init to init.d for startup script cp /etc/init/squid3.conf /etc/init.d/squid3 # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid3/blacklist.acl # Restarting Squid and enabling its service service squid3 restart && update-rc.d squid3 defaults # Running function firew2 firew2 } # Function for Fedora fed () { # Installing necessary packages (Squid, httpd-tools for htpasswd and dependencies) yum install squid httpd-tools -y # Asking user to set a username via read and writing it into $usrn read -e -p "Your desired username: " usrn # Creating user with username from $usrn and asking user to set a password htpasswd -c /etc/squid/passwd $usrn # Downloading necessary Squid.conf for the corresponding OS & system architecture case $vsysarch in 32) # 32 bit Squid configuration wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-fedora32.conf --no-check-certificate;; 64) # 64 bit Squid configuration wget -O /etc/squid/squid.conf https://raw.githubusercontent.com/icharisofcc/proxy/master/spi-rhel7.conf --no-check-certificate;; esac # Creating empty blacklist.acl file for further blacklisting entries touch /etc/squid/blacklist.acl # Restarting Squid and enabling its service systemctl restart squid && systemctl enable squid # Running function firew2 firew2 } # Default function with information dinfo () { echo "Squid Proxy Installer $vspiversion Build $vspibuild" echo "You are using builds from the $vbranch branch" echo "" echo "Usage: bash spi