Skip to content

Instantly share code, notes, and snippets.

View fuegas's full-sized avatar
📭
working

Ferdi fuegas

📭
working
View GitHub Profile
@fuegas
fuegas / fix-vagrant-chef-detection.sh
Created September 28, 2021 14:28
Script to fix chef version detection for vagrant
#!/bin/bash
# Common functions
function log_prefix { date +%Y-%m-%d\ %H:%M:%S; }
function info { echo "[$(log_prefix)] Info: ${1}"; }
function error { >&2 echo "[$(log_prefix)] Error: ${1}"; }
function fatal { >&2 echo "[$(log_prefix)] Fatal: ${1}"; exit ${2:1}; }
# Detect if we're on OS-X
if [[ "${OSTYPE}" != darwin* ]]; then
@fuegas
fuegas / fix-knife-pty-default.sh
Last active March 10, 2021 13:06
Script to fix pty default for SSH connections
#!/bin/bash
# Common functions
function log_prefix { date +%Y-%m-%d\ %H:%M:%S; }
function info { echo "[$(log_prefix)] Info: ${1}"; }
function error { >&2 echo "[$(log_prefix)] Error: ${1}"; }
function fatal { >&2 echo "[$(log_prefix)] Fatal: ${1}"; exit ${2:1}; }
# Detect if we're on OS-X
if [[ "${OSTYPE}" != darwin* ]]; then
@fuegas
fuegas / patch-freemius.sh
Last active March 22, 2019 22:37
Auto patch Freemius vulnerability
#!/bin/bash
find /var/www/* -type f -name class-freemius.php | while read -r file; do
after=0
while true; do
((after++))
line=$(grep -A${after} "function _set_db_option" "${file}" | tail -n 1)
if [[ "${line}" =~ fs_request_get ]]; then
sed --in-place -E "s/^(.*)(static function _set_db_option.*)$/\1\2\n\1 check_admin_referer( 'fs_set_db_option' );/" "${file}"
@fuegas
fuegas / autocomplete.sh
Last active March 22, 2019 22:20
Autocomplete ssh addresses
# Host completion
_complete_hosts () {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
host_list=`{
for c in /etc/ssh_config /etc/ssh/ssh_config ~/.ssh/config
do [ -r $c ] && sed -n -e 's/^Host[[:space:]]//p' -e 's/^[[:space:]]*HostName[[:space:]]//p' $c
done
for k in /etc/ssh_known_hosts /etc/ssh/ssh_known_hosts ~/.ssh/known_hosts
do [ -r $k ] && egrep -v '^[#\[]' $k|cut -f 1 -d ' '|sed -e 's/[,:].*//g'