Category Archives: Shell Script

Block ip address using iptables

How to block ip address using iptables Some times we need to block ip address of spammer using iptables when Akismet plugin and recaptcha sometimes doesn’t work for manual spamming. Following example shows how to filter IN and OUT traffic … Continue reading

Posted in Hardware and Networking, Protocals, Proxy, Shell Script | Tagged , | Leave a comment

Killing child process in shell script

Killing child process in shell script: Many time we need to kill child process which are hanged or block for some reason. eg. FTP connection issue. There are two approaches, 1) To create separate new parent for each child which … Continue reading

Posted in Shell Script | Tagged | Leave a comment

Shell script multi-processing

Shell script multi processing : Multi processing using shell script can be achieve by spawning multiple child processes. There are two method , 1) Using commands as string : #!/bin/bash declare -a NOS=(1 2 3 5 6 7 8); STR=”{ … Continue reading

Posted in Shell Script | Tagged | Leave a comment

Git deployment shell script

Git deployment shell script Following shell script can be useful for deplying git branch on multiple servers. #!/bin/bash DIR=”$( cd “$( dirname “${BASH_SOURCE[0]}” )” && pwd )” HN=$(hostname) declare -A SERVER; SERVER["app1"]=”ubuntu@″; SERVER["app12"]=”ubuntu@″; SERVER["mongo1"]=”ubuntu@333.333.333.33″; SERVER["mongo12"]=”ubuntu@333.333.333.33″; SERVER["lb1"]=”ubuntu@444.444.444.44″; SERVER["lb12"]=”ubuntu@555.555.555.55″; usage() { local … Continue reading

Posted in Revision control, Shell Script | Tagged , | Leave a comment

Configuration Deployment script

Configuration Deployment script : Following configuration deployment script can be use to deploy git ignored configuration files on multiple server. #!/bin/bash set -e DIR=$(pwd); HST_NAM=$(hostname); CNF_FLR=$DIR”/configs”; KOH_CNF_FIL=”environment.php”; SYM_CNF_FIL=”parameters.yml”; KOH_SER_CNF_PHT=”/var/www/frontend/application/config/”; KOH_STG_SER_CNF_PHT=”/var/www/frontendstaging/application/config/”; SYM_SER_CNF_PHT=”/var/www/backend/Symfony/app/config/”; SYM_STG_SER_CNF_PHT=”/var/www/backendstaging/Symfony/app/config/”; SYM_STG_APP_SER_CNF_PHT=”/var/www/backendappstaging/Symfony/app/config/”; FLAG=”d”; HIP_CHAT_MEG=”"; SEP=”"; usage() { local COMMAND_COLOR=”\033[32m”; … Continue reading

Posted in Shell Script | Tagged | Leave a comment

Gearman shell script

Gearman shell script : This is gearman worker server demo script for getting job done from workers on distributed systems. Scripts generate pdf report using wkhtmltopdf utility and upload them to S3 server. Symphony command : app/console company:command pdf-report /tmp/gearman/wkhtmltopdf/pdfs … Continue reading

Posted in Gearman, Shell Script | Tagged , | Leave a comment