summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-10-26 17:11:38 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-10-26 17:11:38 +0100
commitec54b9528b2eb32d5775bc1ff3566f1e2e2db955 (patch)
treefaafce0250705f97785b0bf30b092f9e27362fe3
parent1c304f96c427d3538934fffa075ab50d7ab7d64a (diff)
downloadbin-ec54b9528b2eb32d5775bc1ff3566f1e2e2db955.tar.gz
bin-ec54b9528b2eb32d5775bc1ff3566f1e2e2db955.tar.xz
Add new scripts
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xbind-cal.sh23
-rwxr-xr-xcert2curlpub4
-rwxr-xr-xclipboard-singlify3
-rwxr-xr-xdomain2curlpub3
-rwxr-xr-xrename_db67
-rwxr-xr-xsvg2pdf5
6 files changed, 105 insertions, 0 deletions
diff --git a/bind-cal.sh b/bind-cal.sh
new file mode 100755
index 0000000..555560f
--- /dev/null
+++ b/bind-cal.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+BASE="$1"
+USER="$2"
+RESOURCE="$3"
+NAME="${4:-${3##*/}}"
+
+URL="$BASE/caldav.php/$USER/"
+
+RESSOURCE=$(echo "$RESSOURCE" | php -e '<?php echo file_get_contents("php://stdin")')
+
+
+REQUEST=`cat <<EOF
+<?xml version="1.0" encoding="utf-8"?>
+<bind xmlns="DAV:">
+ <segment>$NAME</segment>
+ <href>$RESOURCE</href>
+</bind>
+EOF`
+
+echo $REQUEST
+
+echo $REQUEST | curl -k -d @- -X BIND -u $USER -H "content-type: text/xml;charset=\"UTF-8\"" -H "user-agent: bind-script" $URL
diff --git a/cert2curlpub b/cert2curlpub
new file mode 100755
index 0000000..81bd07d
--- /dev/null
+++ b/cert2curlpub
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+hash=$(sed -n '/-----BEGIN/,/-----END/p' | openssl x509 -noout -pubkey | openssl rsa -noout -pubin -outform DER | openssl dgst -sha256 -binary | openssl enc -base64)
+echo "sha256//$hash"
diff --git a/clipboard-singlify b/clipboard-singlify
new file mode 100755
index 0000000..75d09e0
--- /dev/null
+++ b/clipboard-singlify
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+xclip -o | perl -pe 'BEGIN{undef $/;} s#[\t ]*\n[\t ]*# #mg; s#^\s*##; s#\s*$##' | xclip
diff --git a/domain2curlpub b/domain2curlpub
new file mode 100755
index 0000000..bc4ff6f
--- /dev/null
+++ b/domain2curlpub
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+openssl s_client -connect $1:443 2>&1 < /dev/null | cert2curlpub
diff --git a/rename_db b/rename_db
new file mode 100755
index 0000000..eacff17
--- /dev/null
+++ b/rename_db
@@ -0,0 +1,67 @@
+#!/bin/bash
+# Copyright 2013 Percona LLC and/or its affiliates
+set -e
+if [ -z "$3" ]; then
+ echo "rename_db <server> <database> <new_database>"
+ exit 1
+fi
+db_exists=`mysql -h $1 -e "show databases like '$3'" -sss`
+if [ -n "$db_exists" ]; then
+ echo "ERROR: New database already exists $3"
+ exit 1
+fi
+TIMESTAMP=`date +%s`
+character_set=`mysql -h $1 -e "show create database $2\G" -sss | grep ^Create | awk -F'CHARACTER SET ' '{print $2}' | awk '{print $1}'`
+TABLES=`mysql -h $1 -e "select TABLE_NAME from information_schema.tables where table_schema='$2' and TABLE_TYPE='BASE TABLE'" -sss`
+STATUS=$?
+if [ "$STATUS" != 0 ] || [ -z "$TABLES" ]; then
+ echo "Error retrieving tables from $2"
+ exit 1
+fi
+echo "create database $3 DEFAULT CHARACTER SET $character_set"
+mysql -h $1 -e "create database $3 DEFAULT CHARACTER SET $character_set"
+TRIGGERS=`mysql -h $1 $2 -e "show triggers\G" | grep Trigger: | awk '{print $2}'`
+VIEWS=`mysql -h $1 -e "select TABLE_NAME from information_schema.tables where table_schema='$2' and TABLE_TYPE='VIEW'" -sss`
+if [ -n "$VIEWS" ]; then
+ mysqldump -h $1 $2 $VIEWS > /tmp/${2}_views${TIMESTAMP}.dump
+fi
+mysqldump -h $1 $2 -d -t -R -E > /tmp/${2}_triggers${TIMESTAMP}.dump
+for TRIGGER in $TRIGGERS; do
+ echo "drop trigger $TRIGGER"
+ mysql -h $1 $2 -e "drop trigger $TRIGGER"
+done
+for TABLE in $TABLES; do
+ echo "rename table $2.$TABLE to $3.$TABLE"
+ mysql -h $1 $2 -e "SET FOREIGN_KEY_CHECKS=0; rename table $2.$TABLE to $3.$TABLE"
+done
+if [ -n "$VIEWS" ]; then
+ echo "loading views"
+ mysql -h $1 $3 < /tmp/${2}_views${TIMESTAMP}.dump
+fi
+echo "loading triggers, routines and events"
+mysql -h $1 $3 < /tmp/${2}_triggers${TIMESTAMP}.dump
+TABLES=`mysql -h $1 -e "select TABLE_NAME from information_schema.tables where table_schema='$2' and TABLE_TYPE='BASE TABLE'" -sss`
+if [ -z "$TABLES" ]; then
+ echo "Dropping database $2"
+ mysql -h $1 $2 -e "drop database $2"
+fi
+if [ `mysql -h $1 -e "select count(*) from mysql.columns_priv where db='$2'" -sss` -gt 0 ]; then
+ COLUMNS_PRIV=" UPDATE mysql.columns_priv set db='$3' WHERE db='$2';"
+fi
+if [ `mysql -h $1 -e "select count(*) from mysql.procs_priv where db='$2'" -sss` -gt 0 ]; then
+ PROCS_PRIV=" UPDATE mysql.procs_priv set db='$3' WHERE db='$2';"
+fi
+if [ `mysql -h $1 -e "select count(*) from mysql.tables_priv where db='$2'" -sss` -gt 0 ]; then
+ TABLES_PRIV=" UPDATE mysql.tables_priv set db='$3' WHERE db='$2';"
+fi
+if [ `mysql -h $1 -e "select count(*) from mysql.db where db='$2'" -sss` -gt 0 ]; then
+ DB_PRIV=" UPDATE mysql.db set db='$3' WHERE db='$2';"
+fi
+if [ -n "$COLUMNS_PRIV" ] || [ -n "$PROCS_PRIV" ] || [ -n "$TABLES_PRIV" ] || [ -n "$DB_PRIV" ]; then
+ echo "IF YOU WANT TO RENAME the GRANTS YOU NEED TO RUN ALL OUTPUT BELOW:"
+ if [ -n "$COLUMNS_PRIV" ]; then echo "$COLUMNS_PRIV"; fi
+ if [ -n "$PROCS_PRIV" ]; then echo "$PROCS_PRIV"; fi
+ if [ -n "$TABLES_PRIV" ]; then echo "$TABLES_PRIV"; fi
+ if [ -n "$DB_PRIV" ]; then echo "$DB_PRIV"; fi
+ echo " flush privileges;"
+fi
diff --git a/svg2pdf b/svg2pdf
new file mode 100755
index 0000000..798e6a3
--- /dev/null
+++ b/svg2pdf
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+b=${1%.svg}
+
+inkscape "$b.svg" -A "$b.pdf" --export-area-drawing --export-dpi=600