Skip to content

Instantly share code, notes, and snippets.

View stefb69's full-sized avatar

Stéphane Benoit stefb69

View GitHub Profile
@stefb69
stefb69 / sync-es-cluster.py
Created October 16, 2023 23:07
Script to replicate/migrate indexes from an elasticsearch cluster to an opensearch cluster
#!/usr/bin/python3
import socket
from elasticsearch import Elasticsearch, exceptions as es_exceptions, Transport as es_transport, ConnectionPool as es_connection_pool
from opensearchpy import OpenSearch, exceptions as os_exceptions, Transport as os_transport, ConnectionPool as os_connection_pool
import logging
from urllib3.connection import HTTPConnection
# Configuration de la journalisation
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@stefb69
stefb69 / ypvtast.pl
Last active May 3, 2017 09:13
Mojolicious::Lite App to lookup contacts or leads phone number from Vtiger for Asterisk with FreePBX CIDLookup feature
use Mojolicious::Lite;
use WebService::Vtiger;
app->config(hypnotoad => {listen => ['http://*:3002'],
pid_file => '/tmp/ypvtast.pid' });
app->attr(vt => sub {
my $c = shift;
@stefb69
stefb69 / notify_by_ifttt.pl
Last active January 19, 2019 16:42
Nagios / Shinken notification script to trigger ifttt receipes via Maker Channel
#!/usr/bin/perl -w
# IFTTT Notification for nagios,
# Largely inspired from the Notify My Andoid perl code
use strict;
use LWP::UserAgent;
use Getopt::Long;
use Pod::Usage;
# Grab our options.
@stefb69
stefb69 / mail2fax_free.pl
Created November 1, 2015 20:36
Mail to fax gateway script for france free.fr free fax service
#!/usr/bin/perl
# mail2fax_free.pl stefb69
#
use strict;
use warnings;
use WWW::Mechanize;
use MIME::Parser;
my $baseurl = "https://subscribe.free.fr";
my $username = "fbxXXXusername";
SOURCE="/"
DESTLABEL="backup-disk"
SMOUNTDIR=/mnt/source
DMOUNTDIR=/mnt/destination
EXCLUDE=/etc/save.exclude
[email protected]
DBPW="password"
RC=0
@stefb69
stefb69 / mail2fax.sh
Created August 28, 2015 07:20
Mail to Fax gateway script for hylafax
#!/bin/sh
# mail2fax reloaded
# modified version working 100% by stefb (for europe)
# This script allows you to send faxes through your HylaFAX box.
# It uses mpack to strip out email attachments and sendfax to do
# the fax delivery.
### Temporary dir stuff
RANDOMFAX=/tmp/faxtmp.$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -f1 -d" ")
@stefb69
stefb69 / Asset.php
Last active August 29, 2015 14:23 — forked from SubZane/Asset.php
function get_attachment_id_from_src ($src) {
global $wpdb;
$reg = "/(-e\d{13})?(-[0-9]+x[0-9]+)?\.(jpg|jpeg|png|gif)$/i";
$src1 = preg_replace($reg,'',$src);
if($src1 != $src){
$ext = pathinfo($src, PATHINFO_EXTENSION);
$src = $src1 . '.' .$ext;
}
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$src'";
$id = $wpdb->get_var($query);
@stefb69
stefb69 / postfwd.cf
Last active August 19, 2016 13:34
GeoIP postfwd2 plugin
#Example usage
id=SASL_003
HIT_dnsbls >= 2
sasl_username =~ /^(.+)$/
client_country_code !~ /^(FR|IL|US|UK|CA|BE|CH|IT)$/
action = rcpt(sasl_username/3/86400/REJECT your is ip listed as trojaned, only 3 recipient per DAY for $$sasl_username)
@stefb69
stefb69 / LDAPAuth.pm
Last active February 28, 2017 15:57
Simple and per location customizable LDAP Authentication for nginx, using embedded perl and ngx_http_auth_request_module
#!/usr/bin/perl
package LDAPAuth;
use nginx;
use Authen::Simple::LDAP;
use MIME::Base64;
sub handler {
my $r = shift;