Skip to content

Instantly share code, notes, and snippets.

View michabbb's full-sized avatar
💯
Need help ? Call me.....

Micha(el) Bladowski michabbb

💯
Need help ? Call me.....
View GitHub Profile
@michabbb
michabbb / test_mailgun.sh
Created May 9, 2017 18:52
Test Mailgun API Http Response Header
KEY=$1
EMAIL=$2
MD5=`echo -n "$KEY $EMAIL" | md5sum| awk '{print $1}'`
curl -o /dev/null -s -sw "%{http_code}" -G --user "api:$KEY" -G https://api.mailgun.net/v3/address/validate --data-urlencode address="$EMAIL" > /tmp/$MD5
RESPONSE_CODE=`cat /tmp/$MD5`
if [ $RESPONSE_CODE -eq 200 ]; then
echo "OK: $RESPONSE_CODE"
exit 0
else
echo "FAILED: $RESPONSE_CODE"
@michabbb
michabbb / imapsync_docker_example.sh
Created June 12, 2017 12:15
Transfer all emails to Gmail with imapsync
# based on your language you have to change the word "Gesendet" (german for Sent)
docker run --rm skempken/imapsync --host1 mail.xxxxx.com --authmech1 PLAIN --ssl1 --port1 993 --user1 xxxxxx --password1 'xxxxxxx' --debug --port2 993 --ssl2 --host2 imap.gmail.com --user2 xxxxxxx --password2 xxxxxxxxxxxx --addheader --exclude "\[Gmail\]$" --regextrans2 's,^Sent Items$,[Gmail]/Gesendet,' --regextrans2 "s/[ ]+/_/g" --regextrans2 "s/['\^\"\\\\]/_/g" --useuid
@michabbb
michabbb / monitor_website_for_string_and_sent_email_if_not_found.sh
Created July 6, 2017 19:23
Monitor Website for string and send email IF NOT found (without local smtp)
if lynx --dump https://xxxxxxxxxxx |grep --quiet 'Something i am looking for' ; then
echo "Still there"
else
swaks --to xxxxxxxxxx@gmail.com --from "xxxxxxxxx@googlemail.com" --server smtp.gmail.com --auth PLAIN --auth-user "xxxxxxxxxx@googlemail.com" --auth-password "xxxxxxxxxxxxx" -tls -p 587 --h-Subject your-special-subject--body "your body"
fi
@michabbb
michabbb / customer-export.php
Created July 7, 2017 11:55 — forked from derak-kilgo/customer-export.php
CLI php script to export customers from magento to CSV using direct access to a magento collection.
<?php
if(php_sapi_name()!=="cli"){
echo "Must be run from the commend line.";
};
/**
* Setup a magento instance so we can run this export from the command line.
*/
require_once('app/Mage.php');
umask(0);
if (!Mage::isInstalled()) {
@michabbb
michabbb / mysql-schema-to-git.sh
Created January 5, 2018 18:52
Backup MySQL Schema to individual files and push changes to git
#!/bin/bash
NOW=`date +%Y%m%d%H%M%S`
GIT_MYSQL=/home/backup/mysql-schema
for T in `mysql -u root -N -B -e 'show tables from xxxxxx'`;
do
echo "Backing up $T"
mysqldump -d --skip-comments -u root xxxxxx $T | sed 's/ AUTO_INCREMENT=[0-9]*//g' > $GIT_MYSQL/$T.sql
done;
git add -A && git commit -m "schema from $NOW" && git push
@michabbb
michabbb / ipmi_forward.sh
Last active January 6, 2018 17:43
Foward IPMI Web and Viewer Ports
#!/bin/bash
REMOTE=x.x.x.x
# https://www.thomas-krenn.com/de/wiki/Supermicro_Remote_Management_Netzwerk_Ports
ssh -p XX root@localhost -L0.0.0.0:443:$REMOTE:443 -L0.0.0.0:5900:$REMOTE:5900 -L0.0.0.0:5901:$REMOTE:5901 -L0.0.0.0:5120:$REMOTE:5120 -L0.0.0.0:5123:$REMOTE:5123 -L0.0.0.0:80:$REMOTE:80 -L0.0.0.0:5988:$REMOTE:5988 -L0.0.0.0:22:$REMOTE:22 -L0.0.0.0:555:$REMOTE:555 -L0.0.0.0623:$REMOTE:623 -L0.0.0.0:5120:$REMOTE:5120 -C
# after this, start http://brokestream.com/udp_redirect.html
#./udp_redirect 0.0.0.0 623 $REMOTE 623
@michabbb
michabbb / check_mysqldbcompare.sh
Created January 11, 2018 13:03
Nagios Script for mysqldbcompare
#!/bin/bash
rm -f /tmp/dbcompareresult
OUTPUT=`docker run --rm --link your_mysql_container:mysql -v /tmp/:/tmp/ macropage/mysql-utilities bash -c 'mysqldbcompare --skip-row-count --skip-data-check --difftype=sql --compact --server1=user:pwd@mysql:3306 --server2=user:pwd@slave:3306 db1:db2 |tee /tmp/dbcompareresult; exit ${PIPESTATUS[0]}'`
if [ ! -f /tmp/dbcompareresult ]; then
echo "CRITICAL COMMAND DID NOT RUN!";
exit 2
fi
if [ $? -ne 0 ]; then
LASTLINE=`tail -1 /tmp/dbcompareresult`
@michabbb
michabbb / create_json_data_from_table.sql
Last active January 15, 2018 15:29
Mysql - Create json date from table
SELECT
CONCAT(',\',"', c.COLUMN_NAME, '":\',', '\'"\', IFNULL(','REPLACE(TRIM(',c.COLUMN_NAME, '),\'"\',\'\\\\"\'), \'null\'),', '\'"\'')
FROM information_schema.COLUMNS c
WHERE c.TABLE_NAME = 'xxxxx';
SELECT
CONCAT('{'
/* PASTE RESULT HERE AND FIX SOME MINOR COMMA STUFF */
@michabbb
michabbb / backup_by_last_day.sh
Last active January 18, 2018 15:44
Compress Files from Last Day and Remove after Compression (file format like YYYYMMDD....)
#!/bin/bash
DATE=`date +%Y%m%d -d "1 day ago"`
echo $DATE
cd /var/log/xxxxx
find . -maxdepth 1 -name "$DATE*.bz2" -type f -print0| tar cjfv /var/log/xxxxx/byday/xxx.$DATE.tar.bz2 --remove-files --null -T -
@michabbb
michabbb / check_http_with_cookie.sh
Created January 26, 2018 17:35
Nagios check_http is unable to follow cookies (and redirects) - so this little helper script does the job