This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOG_DIR="/srv/data-srv1/logs/nginx" | |
NGINX_PID_FILE="/var/run/nginx.pid" | |
DATE_DIR=`date +%Y/%m/%d/%H` | |
cd $LOG_DIR | |
for dir in `ls`; do | |
if [ ! -d $dir ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo update-alternatives --set editor /usr/bin/vim.basic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *> | |
ServerName foo.com | |
ProxyRequests Off | |
ProxyPreserveHost On | |
ProxyPass / http://bar.com/ | |
ProxyPassReverse / http://foobar.com/ | |
<Proxy *> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 1 > /proc/sys/net/ipv4/ip_forward && \ # NAT redirections activation | |
iptables -A FORWARD -i INPUT_INTERFACE -j ACCEPT && \ # Accepts IN forward packets | |
iptables -A FORWARD -o OUTPUT_INTERFACE -j ACCEPT && \ # Accepts OUT forward packets | |
iptables -t nat -A POSTROUTING -o OUTPUT_INTERFACE -j MASQUERADE && \ # Activate masquerade | |
iptables -t nat -A PREROUTING -i INPUT_INTERFACE -p tcp --dport 80 -j LOG --log-level warn --log-prefix NAT: && \ # Forwarded packages are logged | |
iptables -t nat -A PREROUTING -i INPUT_INTERFACE -p tcp --dport 80 -j DNAT --to IP_DEST:80 # Incoming packets on port 80 of INPUT_INTERFACE are sent to IP_DEST |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "===== CRONTAB ====="; \ | |
for user in $(getent passwd | cut -f1 -d:); do \ | |
echo -e "\n\n==> $user:" && echo "`crontab -u $user -l `"; done; \ | |
echo "===== SSH_KEYS ====="; \ | |
for user in $(getent passwd | cut -f1 -d:); do \ | |
user_home=$(getent passwd | grep -E "^$user:" | cut -f6 -d:); \ | |
if [ -e $user_home/.ssh ]; then \ | |
if [ -e $user_home/.ssh/authorized_keys ]; then \ | |
echo "----- $user :"; cat $user_home/.ssh/authorized_keys; \ | |
fi; fi; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The command must be called inside the Git repository to send to the new repository | |
# Usage: push-to-new-repo.sh TARGET_REPO_URL | |
remote=origin; | |
target_repo=$1; | |
nb_branches=`git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}' | wc -l | sed 's/ //g'`; | |
echo "${nb_branches} branch(es) to push"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: rotate.sh filename | |
logfile=$1 | |
if [ ! -f $logfile ]; then | |
echo "log file not found $logfile" | |
exit 1 | |
fi | |
timestamp=`date +%Y%m%d` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync -Haurov {USER}@{IP}:{REMOTE_PATH} {LOCAL_PATH} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm /dev/null && mknod -m 666 /dev/null c 1 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "SELECT table_schema, round(sum(data_length+index_length)/1024/1024,4) AS \"Size (MB)\" FROM information_schema.tables GROUP BY table_schema;" | mysql -u root --password=XXXX |