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 | |
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
#!/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
#!/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
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 | |
set -x | |
# check hostname | |
hostname -f | |
# update and install Apache | |
yum -y update | |
yum -y install vim httpd | |
systemctl restart httpd | |
# backup of the httpd.conf 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 | |
#Invoke this once, run again after a restart of the system. | |
set -x | |
SSH_ENV=$HOME/.ssh/environment | |
function start_agent { | |
echo "Initialising new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV} | |
echo succeeded | |
chmod 600 ${SSH_ENV} | |
. ${SSH_ENV} > /dev/null |
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
#disable selinux on next reboot | |
sed -i 's/enforcing/disabled/g' /etc/selinux/config /etc/selinux/config | |
sestatus | |
#put in permissive mode | |
setenforce 0 |
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
<?php | |
$lines=array(); | |
$fp = fopen("../log/simplelogger.log", "r"); | |
//tail off last x lines of the log file | |
while(!feof($fp)) | |
{ | |
$line = fgets($fp); | |
array_push($lines, $line); | |
if (count($lines)>10) |
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
<?php | |
//simulating the array from string: | |
$s = ' | |
[2018-02-19 14:08:32] [info] status=GOOD&unit_status=GOOD&hostname=acme | |
[2018-02-19 14:08:32] [alert] Wrong status! (Not "DEGRADED") | |
[2018-02-19 14:08:37] [info] Request with params {"status":"GOOD","unit_status":"GOOD","hostname":"joe"} | |
[2018-02-19 14:08:37] [info] status=GOOD&unit_status=GOOD&hostname=joe | |
[2018-02-19 14:08:37] [alert] Wrong status! (Not "DEGRADED") | |
'; |