Skip to content

Instantly share code, notes, and snippets.

View benoitjpnet's full-sized avatar
🇯🇵
Working from home

Benoit benoitjpnet

🇯🇵
Working from home
View GitHub Profile
@benoitjpnet
benoitjpnet / POSTSuspect.sh
Created October 20, 2014 13:46
Search for suspects POST in apache.log (often attacks)
grep -Eo '"POST .*.php' access.log | grep -ve cron -e login -e admin -e xmlrpc -e trackback -e comment -e 404 | sort -u
@benoitjpnet
benoitjpnet / repairmysql.sh
Created July 9, 2014 09:38
Check for crashed MySQL table in syslog and launch a repair.
#!/bin/bash
tables=$(grep crashed /var/log/syslog | grep -Eo \'\./.*\' --color=auto | sed s#\'./## | sed s#\'## | uniq | tr -s '\n' ' ')
for tableC in $tables; do
db=${tableC%/*}
table=${tableC#*/}
mysqlcheck --auto-repair --check $db $table
done
@benoitjpnet
benoitjpnet / gr.sh
Created December 16, 2013 15:59
Get the groups of an user and add another user into these groups.
for group in $(grep user1 /etc/group | cut -d':' -f1 | sed '/user1/d'); do adduser user2 $group; done
@benoitjpnet
benoitjpnet / squidurls.sh
Created July 10, 2013 13:26
Get the last acceded URLs in Squid Access list.
tail -n100 /var/log/squid3/access.log | grep -oE 'http.*' | cut -d ' ' -f1 | sort | uniq
@benoitjpnet
benoitjpnet / mysqlusers.sh
Created July 9, 2013 12:54
Migrate MySQL users.
# SRC Server
mysql mysql -e "select * from user WHERE USER='user1' OR USER='user2' INTO OUTFILE '/tmp/mysql_user';"
mysql mysql -e "select * from db WHERE USER='user1' OR USER='user2' INTO OUTFILE '/tmp/mysql_db';"
# DST Server
scp server:/tmp/mysql_{db,user} /tmp
chmod 664 /tmp/mysql_{db,user}
mysql mysql -e "LOAD DATA INFILE '/tmp/mysql_user' INTO TABLE user;"
mysql mysql -e "LOAD DATA INFILE '/tmp/mysql_db' INTO TABLE db;"
@spikegrobstein
spikegrobstein / nginx.conf
Last active August 9, 2024 13:42
nginx config for proxying requests for plex over a hostname-based virtualhost.
upstream plex-upstream {
# change plex-server.example.com:32400 to the hostname:port of your plex server.
# this can be "localhost:32400", for instance, if Plex is running on the same server as nginx.
server plex-server.example.com:32400;
}
server {
listen 80;
# server names for this server.
@benoitjpnet
benoitjpnet / migrateaacount.sh
Last active October 12, 2015 01:38
Get useradd command for migrating account
for i in user1 user2 user3...; do echo -n 'useradd -m -s /bin/bash -u '$(grep -E "^$i" /etc/passwd | cut -d':' -f3) && echo -en ' -p' \'$(grep -E "^$i" /etc/shadow | cut -d ':' -f2)\' $i '\n'; done
Output :
useradd -m -s /bin/bash -u USERID -p 'USERPWD' username