Skip to content

Instantly share code, notes, and snippets.

@l0neranger
l0neranger / git-del.sh
Created September 4, 2015 23:15
Delete Local and Remote Git tags/branches
#
# Local
#
git tag -d TAG_NAME
git branch -d BRANCH_NAME
#
# Remote
#
git push origin :TAG_NAME
#!/bin/bash
# a simple script to uninstall ossec (tested on debian)
# Author: Han The Thanh <h a n t h e t h a n h @ g m a i l . c o m>
# Public domain.
# this script has been tested on debian; it should also work on other linux
# systems but I have not tested. If you want to be careful and need to see what
# would be done without executing any real action, uncomment the following line:
# dryrun="echo "
@l0neranger
l0neranger / ansibleSetupPostfixSES.yml
Last active May 24, 2022 11:51
Ansible Playbook - Postfix for SES Delivery
#
# According to AWS Docs - http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
#
# Rewrites all sender addresses to a single canonical ses verified address.
#
# Expects a vars files at ../vars/PostfixSES-vars.yml with the following variables:
# - ses_host: email-smtp.us-west-x.amazonaws.com
# - ses_port: 587
# - ses_username: ses-smtp-username
# - ses_password: ses-smtp-password
@l0neranger
l0neranger / apache_mod_rewrite
Created January 7, 2015 01:26
Mod_Rewrite Example
RewriteEngine on
#
# If the request comes in on the domain cname, redirect to domain root
#
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://domain1.com/$1 [L,R=301,NE,NC]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://domain2.com/$1 [L,R=301,NE,NC]
#
# Delete Ansible retry files
#
5 * * * * /usr/bin/find /Users/user/. -maxdepth 1 -type f -name \*.retry -exec rm {} \; > /dev/null 2>&1
@l0neranger
l0neranger / git-pack-tar
Created October 16, 2014 22:55
Create tar bundle of all files in a Git SHA - A Bash Function
function gpack() {
if [ -d ".git" ]; then
echo -n "List of files:" ; git show --pretty="format:" --name-only $1
if [ $? == 0 ]; then
git show --pretty="format:" --name-only $1 | xargs tar czf ../`printf '%q\n' "${PWD##*/}"`-partial-`cdate`.tar.gz
echo ; echo -n "Tar bundle: ../" ; ls -1t .. | head -n 1
else
echo "git SHA Not Found"
fi
else
---
- hosts: all
gather_facts: true
name: CVE-2014-6271 - Bash Fix with Debian 6 Support
tasks:
- name: Add LTS to sources.list
lineinfile: >
dest=/etc/apt/sources.list
insertafter=EOF
@l0neranger
l0neranger / req_by_ip.sh
Created September 18, 2014 16:42
# of requests in Apache access log by ip
#!/bin/bash
awk '{ print $1 } ' access.log | uniq -c | sort
@l0neranger
l0neranger / rm-dpkg-rc.sh
Created September 9, 2014 05:30
Purge dpkg packages marked as rc
dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs apt-get autoremove --purge -y
@l0neranger
l0neranger / baculaRestore.yml
Last active August 29, 2015 14:06
Bacula restore tests using Ansible
- hosts: bacula
user: user
sudo: True
tasks:
- name: Restore files from bacula for weekly restore tests
shell: /bin/echo "restore before=2013-10-14\ 08:00:00 client={{ item }}-fd restoreclient={{ item }}-fd file=</tmp/{{ item }}-file-list where=/tmp/bacula-restores yes" | /usr/bin/bconsole
with_items:
- hostname1
- hostname2