This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -q -F 'include "/configs/projectname.conf"' foo.bar || echo 'include "/configs/projectname.conf"' >> foo.bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
grep -q -F '192.168.49.10 web1.example.com web1' /etc/hosts || echo '192.168.49.10 web1.example.com web1' >> /etc/hosts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
if [ $(command -v httpd) ]; then echo 'installed'; else echo 'not installed'; fi | |
# or | |
if [ $(which httpd) ]; then echo 'installed'; else echo 'not installed'; fi | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sed -i '/ServerName web2.example.com:443/a CustomLog /var/log/httpd/example.com/logs/web2.example.com-access.log combined' ssl.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global_entry=" | |
global | |
log 127.0.0.1 local0 | |
log 127.0.0.1 local1 debug | |
maxconn 45000 # Total Max Connections. | |
daemon | |
nbproc 1 # Number of processing cores." | |
echo "$global_entry" | |
file=tester | |
grep -qF "$global_entry" "$file" || echo "$global_entry" | sudo tee --append "$file" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SITESFILE=sites.txt #list the sites you want to monitor in this file | |
#EMAILS="[email protected],[email protected]" #list of email addresses to receive alerts (comma separated) | |
while read site; do | |
if [ ! -z "${site}" ]; then | |
CURL=$(curl -s --head $site) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Create a secure server on your lan e.g. raspi | |
#invoke the following command from the server you will use as socks5 proxy specify port. | |
ssh -o ServerAliveInterval=60 -D0.0.0.0:8888 -f -N "host_with_www_connection" | |
#we have forked a background ssh process creating a socks5 proxy dynamically on ALL interfaces using 8888 on localhost, check with... | |
netstat -ntlp | |
#turn on the firewalld service | |
systemctl status firewalld.service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ $(grep -o '\.' file|wc -l) -gt 3 ] && sed -i file -e 's/\./+/g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raw=/path/to/dir | |
files=("$raw"/*) | |
for each in "${files[@]}"; do | |
echo "$each" | |
sleep 3 | |
done | |
count=${#files[@]} | |
files_ordered=() | |
for (( i = 0; i < count; i++ )); do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
shopt -s nullglob | |
exec > /path/to/logfile | |
# Variables | |
sql_path="/path/to/backup" | |
data_path="/path/to/backup" | |
days=7 | |
testvalue=1 | |
# Arrays | |
mapfile -t sql < <(find "$sql_path" -type f -mtime -"$days") |