Install Squid Ubuntu 18.04 Menggunakan Script Bash

 


 

Bash (akronim dari Bourne-Again shell) adalah syel Unix dan bahasa skrip yang menjadi standar syel di sebagian besar sistem Linux dan macOS (hingga versi Catalina). Bash dikembangkan oleh proyek GNU sebagai pengganti berlisensi bebas dari Bourne shell dengan peningkatan dan penambahan fitur, sesuai dengan namanya: Bourne shell yang "terlahir kembali".

Seperti syel pada umumnya, Bash mendukung pencocokan wildcard, dokumen here, substitusi perintah, variabel, percabangan, dan iterasi. Bash juga menawarkan fitur-fitur baru seperti pengendalian tugas, pengeditan baris perintah, histori perintah, dan fungsi shell. Bash dapat mematuhi standar POSIX.
Microsoft Windows mendukung shell Bash dengan melalui Subsistem Windows untuk Linux.

Bash ini dapat di gunakan untuk mempermudah pembuatan konfigurasi tanpa perlu mengetik satu persatu, dengan menjalankan bash script yang sudah di buat aplikasi akan langsung berjalan


Di sini Kami akan memberikan contoh cara membuat Script bash Install Squid Proxy :


#!/bin/bash

echo ' Update OS'
apt -y update

echo 'Upgrade Linux'
apt -y upgrade

echo 'install Squid'
apt install -y squid

echo 'Config squid'
mv /etc/squid/squid.conf /etc/squid/squid.bak
cat <<EOF>> /etc/squid/squid.conf
# _____Squid config for eset_____

# ACLs all, manager, localhost, and to_localhost are predefined.
# Recommended minimum configuration:
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12    # RFC1918 possible internal network
#acl localnet src 192.168.0.0/16    # RFC1918 possible internal network
#acl localnet src fc00::/7       # RFC 4193 local private network range
#acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80        # http
acl Safe_ports port 21        # ftp
acl Safe_ports port 443        # https
acl Safe_ports port 70        # gopher
acl Safe_ports port 210        # wais
acl Safe_ports port 1025-65535    # unregistered ports
acl Safe_ports port 280        # http-mgmt
acl Safe_ports port 488        # gss-http
acl Safe_ports port 591        # filemaker
acl Safe_ports port 777        # multiling http
acl CONNECT method CONNECT
#cache_peer 10.1.12.41 parent 3128 0 no-query
#prefer_direct off
#never_direct allow all

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# And finally deny all other access to this proxy
http_access allow localnet
http_access deny all
http_port 3128
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 5000 16 256 max-size=200000000

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
# example lin deb packages
#refresh_pattern (\.deb|\.udeb)$ 129600 100% 129600
refresh_pattern . 0 20% 4320

# ——————- End Konfigurasi Squid ———————–
EOF

echo 'restart service squid'
systemctl enable squid && systemctl stop squid && squid3 -z && systemctl start squid

echo 'Finish'


Silahkan Copy Script di atas dari #!/bin/bash sampai echo 'Finish' dan  Save Menjadi Installsquid.sh


Lalu ubah permision

chmod +x Installsquid.sh 


Jalankan Script bash dengan perintah :

bash Installsquid.sh 



0 Komentar