Skip to content

Instantly share code, notes, and snippets.

View icheko's full-sized avatar

Jose Pacheco icheko

View GitHub Profile
@icheko
icheko / checkNFSMount.sh
Last active December 31, 2015 19:49
Check if NFS mount is present, else attempt to remount. Usage: ./checkNFSMount.sh /mount/point
#!/bin/sh
#
# USAGE: ./checkNFSMount.sh /san
#
for i in `cat /proc/mounts | cut -d' ' -f2`; do
if [ "x$1" = "x$i" ]; then
exit
@icheko
icheko / aliases
Created December 19, 2013 08:56
some common aliases i use on RHEL systems
#!/bin/bash
# TAR #
alias tar-view="tar -tvf"
# FILES #
alias ll='ls -lah'
alias ls='ls --color=auto'
# NAVIGATION #
@icheko
icheko / random_chuck.py
Created December 19, 2013 19:12
Quick and dirty Chuck Norris python script. Used in our SVN post commit hook. In case you don't have the requests library: yum install python-requests.noarch
import json, requests
url = 'http://api.icndb.com/jokes/random'
params = dict(
category='nerdy'
)
resp = requests.get(url=url, params=params)
data = json.loads(resp.content)
@icheko
icheko / dynamic_htaccess_update.php
Last active August 29, 2015 13:57
Usage in cron: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/php /root/scripts/dynamic_htaccess_update.php dynamic.ip.com
<?php
// Rewrites the entire htaccess file. When a line starts with '# Allow from brett.getmyip.com' the
// very next line will be replaced with the actual ip associated with brett.getmyip.com
//
// Usage in cron: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/php /root/scripts/dynamic_htaccess_update.php /var/www/html/.htaccess dynamic.ip.com
//
// Hat tip: http://brett.batie.com/software-development/update-htaccess-with-dynamic-dns-ip-address-to-prevent-password-protection/
$htaccessFile = $argv[1];
$target_dns_name = $argv[2];
#!/bin/bash
LOCK=/root/scripts/replicationLock
LOGFILE=/tmp/replication_script_log
if [ -f $LOCK ]
then
echo "$$ | $(date +'%D %T') | Replication currently locked. Exiting." >> $LOGFILE
exit 1
fi
@icheko
icheko / DAS_free_space.vbs
Created July 9, 2014 16:09
VBScript write free disk space to file
Const ForAppending = 8
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='s:'")
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile("c:\DAS_free_space.txt", ForAppending, True)
objFile.WriteLine(FormatNumber((CDbl(objLogicalDisk.FreeSpace)/1024/1024/1024)) & ",")
objFile.Close
@icheko
icheko / stash_backup.sh
Created July 30, 2014 15:22
Backup Atlassian Stash
#!/bin/bash
#
# TO UNTAR: tar -xvzf stash_2014-07-24.tar.gz --strip-components=2
#
LOG_FILE=/tmp/stash_backup_log
TIMESTAMP="$$ | $(date +'%D %T') |"
TODAY=`date +'%Y-%m-%d'`
STASH_DB="stash"
TMP_DIR=/root/scripts
@icheko
icheko / check-s3fs-mount.sh
Last active April 5, 2017 18:33
Check if S3FS mount is not connected and attempt to reconnect Usage: ./checkNFSMount.sh /mount/point
#!/bin/sh
MNT_PATH=$1
if [ -z "$MNT_PATH" ]
then
echo "MNT_PATH is not set"
exit
fi
@icheko
icheko / bump_version.sh
Last active August 29, 2015 14:09 — forked from pete-otaqui/bumpversion.sh
Bump version for PHP projects
#!/bin/bash
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <axelseaa@amadmax.com>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9