Skip to content

Instantly share code, notes, and snippets.

@dcoppari
dcoppari / racklb.sh
Last active March 13, 2017 21:16
Bash Script to change Rackspace loadbalancer timeout
#!/bin/sh
USERNAME={RackspaceUsername}
APIKEY={RackspaceApikey}
ACCOUNT={RackspaceAccount}
LBID={LoadBalancerID}
JSON=$(curl -vs \
-X POST 'https://identity.api.rackspacecloud.com/v2.0/tokens' \
-d '{ "auth": { "RAX-KSKEY:apiKeyCredentials": { "username": "'$USERNAME'", "apiKey": "'$APIKEY'" } } }' \
@dcoppari
dcoppari / checkeximwhitelist.sh
Created April 18, 2017 21:57
This script is intended to filter whitelist IP from exim mainlog for be added to exim.smtpauth
#!/bin/sh
TODATE=`date +'%F'`
cat /var/log/exim_mainlog | \
grep $TODATE | \
grep 'SMTP connection from' | \
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' > /tmp/iplist.tmp
sort /tmp/iplist.tmp | uniq > /tmp/iplist.tmp2
@dcoppari
dcoppari / notify_inode.sh
Created August 15, 2017 11:13
Alert me using notifymyandroid of changes on wordpress folders
#!/bin/sh
APP=`hostname`
APIKEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
VAR=`pidof inotifywait | wc -w`
if [[ $VAR -eq 1 ]] ; then
exit;
fi
@dcoppari
dcoppari / checkimages
Created August 15, 2017 11:19
Use imagemagik to check for not valid media files on Wordpress upload folders
BASEPATH=/var/www/vhosts
LIST=`ls $BASEPATH -1`
for i in $LIST
do
FOLDER=$BASEPATH/$i/public_html/wp-content/uploads
RESULT=`find $FOLDER -type f -exec identify {} 2>&1 \; | grep -v 'JPEG' | grep -v 'PNG' | grep -v 'BMP' | grep -v 'PDF' | grep -v 'GIF'`
@dcoppari
dcoppari / notifyIdle.sh
Created July 12, 2019 13:25
Bash script to monitor when computer is Idle and take information
#!/bin/bash
LOCKFILE=/tmp/notify.pid
HSTFILE=/tmp/history.tmp
if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then
echo "already running"
exit
fi
@dcoppari
dcoppari / bitbucket-usage.php
Created January 28, 2020 01:40
Get BITBUCKET STATISTICS
<?php
# composer install gentle/bitbucket-api
require dirname(__FILE__) . "/vendor/autoload.php";
$bb_user = 'BITBUCKET_USER';
$bb_pass = 'BITBUCKET_PASS';
$account_name = 'BITBUCKET_ACCOUNT';
@dcoppari
dcoppari / howtofix-backup-manager.txt
Created March 6, 2020 19:22
Howto Fix backup-manager upload to S3 error can't locate object method "add_key_filename" via package "0"
This is a workaround to fix the error for backup-manager
can't locate object method "add_key_filename" via package "0"
This error is raised bec no propper Net::Amazon::S3 initialization.
To solve this you must enter the host parameter to where the API will authenticate:
/usr/bin/backup-manager-upload on line 870 you need to change:
This:
@dcoppari
dcoppari / Dockerfile.php-imagick
Created July 24, 2020 02:56
Dockerfile to with imagick
FROM php:7.4-alpine
ARG GLIB_VERSION="2.31-r0"
# Install language pack
RUN apk --no-cache add ca-certificates wget && \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIB_VERSION}/glibc-${GLIB_VERSION}.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIB_VERSION}/glibc-bin-${GLIB_VERSION}.apk && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIB_VERSION}/glibc-i18n-${GLIB_VERSION}.apk && \
@dcoppari
dcoppari / getPipelinesDefinitions.ps1
Created May 17, 2023 17:12
Get list of Pipielines and it Definitions
# Install Azure CLI if not already installed
$azCliInstalled = Get-Command az -ErrorAction SilentlyContinue
if (-not $azCliInstalled) {
Write-Host "Azure CLI is not installed. Please install Azure CLI before running this script."
exit
}
# Set Azure DevOps organization URL and project name
$orgUrl = "https://dev.azure.com/YourOrganizationName"
@dcoppari
dcoppari / email_validator.sh
Created January 29, 2024 15:44
Validate email formart and domain
#!/usr/bin/env bash
function valid_format {
local email=$1
local regex="^(([A-Za-z0-9]+((\.|\-|\_|\+)?[A-Za-z0-9]?)*[A-Za-z0-9]+)|[A-Za-z0-9]+)@(([A-Za-z0-9]+)+((\.|\-|\_)?([A-Za-z0-9]+)+)*)+\.([A-Za-z]{2,})+$"
[[ $email =~ ${regex} ]] || return 1
}