Difference between revisions of "Scripts"
Jump to navigation
Jump to search
Michael.mast (talk | contribs) (→Files) |
Michael.mast (talk | contribs) (→Files) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Backup== | ==Backup== | ||
==Files== | ==Files== | ||
+ | *[[Convert Massive VCard file into individual files]] | ||
*[[Process new or changed files]] | *[[Process new or changed files]] | ||
==Reporting== | ==Reporting== | ||
+ | *Apache logs. This was from a production environment, I had a list of users to IP addresses in another location and this would replace IPs with user names. It also removes some backend stuff used with word press and Apache. | ||
+ | <pre> | ||
+ | #!/bin/bash | ||
+ | grep GET /var/log/httpd/access_log | grep https://yoursite.tld/ | sed 's|/var/log/httpd/access_log-[0-9]\+:||; s|-\ -\ \[||; s|-[0-9]\{4\}||; s|\ \]||; s|GET||; /ccm/d; /tools/d; /dashboard/d; /index.php\ HTTP/d' | sed '/\/index.php\/login/d; s|HTTP/1.1||; /cID=/d' | awk -F\" '{ print $1 $2 }' | grep index.php > /tmp/logtest | ||
+ | |||
+ | while read line; | ||
+ | do | ||
+ | ip=$(awk '{ print $1 }' <<<$line) | ||
+ | # echo $ip | ||
+ | username=$(files=$(grep -R $ip /mnt/fs01/ | awk '{ print $3 }'); while read line; do ls -al --time-style=+s $line; done <<<$files | awk '{ print $5 $7}' | sort -r | head -1 | sed 's/^[0-9]\+//' | awk -F\/ '{ print $4 }' | sed 's/^[0-9a-zA-Z-]\+\.//; s/\.txt//') | ||
+ | if [ -v $username ]; then | ||
+ | username="$ip" | ||
+ | fi | ||
+ | sed "s/$ip/$username/" <<<$line | ||
+ | done < /tmp/logtest | ||
+ | rm -f /tmp/logtest | ||
+ | </pre> | ||
==Interfacing With Windows Domain== | ==Interfacing With Windows Domain== | ||
*[[Monitor AD Group for Changes]] | *[[Monitor AD Group for Changes]] | ||
+ | ==Misc== | ||
+ | *[[7zip Extract Encrypted files]] | ||
+ | *[[File Consolidation Script (Basic)]] | ||
+ | *[[General Connectivity Check for Internet and Specified Subnets]] | ||
+ | *[[Backup Website Data w/ MySQL]] | ||
+ | *[[OpenVPN Keep Alive Script]] | ||
+ | *[[RoboCopy Access Denied Report - Linux]] | ||
+ | *[[SMART Status Report - BASH]] | ||
+ | *[[Run SMART test on all SATA drives]] |
Latest revision as of 12:22, 21 February 2018
Backup
Files
Reporting
- Apache logs. This was from a production environment, I had a list of users to IP addresses in another location and this would replace IPs with user names. It also removes some backend stuff used with word press and Apache.
#!/bin/bash grep GET /var/log/httpd/access_log | grep https://yoursite.tld/ | sed 's|/var/log/httpd/access_log-[0-9]\+:||; s|-\ -\ \[||; s|-[0-9]\{4\}||; s|\ \]||; s|GET||; /ccm/d; /tools/d; /dashboard/d; /index.php\ HTTP/d' | sed '/\/index.php\/login/d; s|HTTP/1.1||; /cID=/d' | awk -F\" '{ print $1 $2 }' | grep index.php > /tmp/logtest while read line; do ip=$(awk '{ print $1 }' <<<$line) # echo $ip username=$(files=$(grep -R $ip /mnt/fs01/ | awk '{ print $3 }'); while read line; do ls -al --time-style=+s $line; done <<<$files | awk '{ print $5 $7}' | sort -r | head -1 | sed 's/^[0-9]\+//' | awk -F\/ '{ print $4 }' | sed 's/^[0-9a-zA-Z-]\+\.//; s/\.txt//') if [ -v $username ]; then username="$ip" fi sed "s/$ip/$username/" <<<$line done < /tmp/logtest rm -f /tmp/logtest