Skip to content

Instantly share code, notes, and snippets.

View skarllot's full-sized avatar
💭
I may be slow to respond.

Fabrício Godoy skarllot

💭
I may be slow to respond.
View GitHub Profile
@skarllot
skarllot / lvm.conf
Created November 28, 2012 12:48
LVM filter to ignore LVM-over-LVM (especially for Openfiler and Xen)
# /etc/lvm/lvm.conf
. . .
filter = [ "r|/dev/dm-*|", "r|/dev/vg*|", "r|/dev/mapper/*|", "a/.*/" ]
. . .
@skarllot
skarllot / sysvol-sync.sh
Last active December 17, 2015 15:09
Script to sync sysvol (and netlogon) folder to Samba 4.
#!/bin/bash
#
# Copyright (C) Matthieu Patou <mat at matws.net> 2011-2012
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
#!/bin/bash
INSTALAR="N";
AUTOR="[email protected]";
TMP_DIR="/tmp/upgZabbix";
DATA_BACKUP=`date +%Y%m%d`;
idioma() {
# Selecao de Idioma -------------------------------------------------------------------------
if [ -d $TMP_DIR ]; then
@skarllot
skarllot / cron-weekly.sh
Last active June 3, 2019 06:39
Bash wrapper for cron to run any script daily, weekly and monthly.
#!/bin/bash
# Called by cron: 0 0 * * * /root/scripts/cron-weekly.sh "/myscript.sh"
# "/myscript.sh" should handle "monthly", "weekly" and "daily" parameters.
wkdate=`date +%w`
DD=`date +%d`
# Mon - Fri, & Sun run daily
# Saturday run weekly except:
@skarllot
skarllot / remove-first-line-example.sh
Created June 27, 2013 06:32
Remove first line from file using Bash
. . .
perl -ni -e 'print unless $. == 1' filename.txt
. . .
@skarllot
skarllot / regex.py
Created September 14, 2013 17:23
Python regex with named groups
import re
str = '{12948}>{$CPU_LOAD_MAX}'
m = re.search('(?:{)(?P<num>\d+)(?:})', str)
print(m.group('num')
@skarllot
skarllot / zabbix_fping_selinux.sh
Created September 15, 2013 02:25
Allow fping to zabbix
grep fping /var/log/audit/audit.log | audit2allow -M zabbix_fping
semodule -i zabbix_fping.pp
@skarllot
skarllot / gist:6685822
Last active December 23, 2015 19:49
Get user list from nested groups (LDAP search)
# http://technet.microsoft.com/en-us/library/ee198834.aspx
(&(objectCategory=person)(memberOf:1.2.840.113556.1.4.1941:=(CN=TargetGroup,CN=Users,DC=DOMAIN,DC=COM)))
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# Based on:
# https://gist.github.com/martin-ueding/4007035#file-colorcodes-py
# https://gist.github.com/jyros/5169803#file-colorcodes-py
# https://gist.github.com/housemaister/5255959#file-colorcodes-py
#
# Copyright (c) 2012 Martin Ueding <[email protected]>
# Copyright (c) 2013 Jairo Sanchez <[email protected]>
@skarllot
skarllot / lockfile.py
Last active December 24, 2015 19:28
Create a lockfile and writes PID
import os
import sys
fname = "./lockfile"
if os.path.isfile(fname):
os.remove(fname)
try:
a = os.open(fname, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0644)
os.write(a, str(os.getpid()) + '\n')