summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-07-22 23:01:45 +0200
committerGravatar Tom Willemse2013-07-22 23:01:45 +0200
commit1e32fe78f689490cfdeb8bb7b0b33edcfc019946 (patch)
tree6544ed5f26aa562852a977cbd8c84bf9cea87871
downloadutilities-1e32fe78f689490cfdeb8bb7b0b33edcfc019946.tar.gz
utilities-1e32fe78f689490cfdeb8bb7b0b33edcfc019946.zip
Initial commit
-rwxr-xr-xcopydb22
-rwxr-xr-xgit-dot11
-rwxr-xr-xgit-etc11
-rwxr-xr-xrebasedb14
4 files changed, 58 insertions, 0 deletions
diff --git a/copydb b/copydb
new file mode 100755
index 0000000..51e5602
--- /dev/null
+++ b/copydb
@@ -0,0 +1,22 @@
+#!/bin/zsh
+
+echo -n 'Database root PW (for DB creation): '
+read -s ROOTPW
+echo
+
+echo -n 'Database user for new DB: '
+read DBUSER
+
+echo -n 'Database user PW for new DB: '
+read -s DBPASSW
+echo
+
+mysql -u root -p"$ROOTPW" -B <<EOF
+CREATE DATABASE $2;
+GRANT ALL ON $2.* to '$DBUSER'@'localhost';
+EOF
+
+unset ROOTPW
+
+mysqldump -u "$DBUSER" -p"$DBPASSW" "$1" \
+ | mysql -u "$DBUSER" -p"$DBPASSW" "$2"
diff --git a/git-dot b/git-dot
new file mode 100755
index 0000000..a145ce1
--- /dev/null
+++ b/git-dot
@@ -0,0 +1,11 @@
+#!/bin/zsh
+
+GITDIR=/home/slash/projects/dotfiles/.git
+
+if [ ! -d "$GITDIR" ]; then
+ echo "Cloning dotfiles to $GITDIR"
+ git clone git@ryuslash.org:dotfiles.git "$GITDIR"
+fi
+
+cd $HOME
+git --git-dir "$GITDIR" --work-tree "$HOME" "$@"
diff --git a/git-etc b/git-etc
new file mode 100755
index 0000000..d7ccdc2
--- /dev/null
+++ b/git-etc
@@ -0,0 +1,11 @@
+#!/usr/bin/zsh
+
+GITDIR=/home/slash/projects/etcfiles
+
+if [ ! -d "$GITDIR" ]; then
+ echo "Cloning etcfiles to $GITDIR"
+ git clone git@ryuslash.org:etcfiles.git "$GITDIR"
+fi
+
+cd /etc
+git --git-dir "$GITDIR" --work-tree /etc/ "$@"
diff --git a/rebasedb b/rebasedb
new file mode 100755
index 0000000..6b41fd4
--- /dev/null
+++ b/rebasedb
@@ -0,0 +1,14 @@
+#!/bin/zsh
+
+echo -n 'Database root PW (for DB manipulation): '
+read -s ROOTPW
+echo
+
+mysql -u root -p"$ROOTPW" -B <<EOF
+DROP DATABASE $2; CREATE DATABASE $2;
+EOF
+echo "Recreated database $2"
+
+mysqldump -u root -p"$ROOTPW" "$1" \
+ | mysql -u root -p"$ROOTPW" -B "$2"
+echo "Copied $1 to $2"