summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-01-15 16:57:00 +0000
committerMark Haines <mark.haines@matrix.org>2015-01-22 11:14:14 +0000
commitf4ce61ed36e7b639550953882b6ea14171108784 (patch)
treefe6e5567f13388d81f02db7a540b44fdda74d99d /scripts
parentAbstract out the room ID from presence tests, so it's stored in self (diff)
downloadsynapse-f4ce61ed36e7b639550953882b6ea14171108784.tar.xz
Move scripts into scripts
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/database-prepare-for-0.0.1.sh21
-rwxr-xr-xscripts/database-prepare-for-0.5.0.sh21
-rwxr-xr-xscripts/database-save.sh16
-rwxr-xr-xscripts/nuke-room-from-db.sh24
-rw-r--r--scripts/sphinx_api_docs.sh1
5 files changed, 83 insertions, 0 deletions
diff --git a/scripts/database-prepare-for-0.0.1.sh b/scripts/database-prepare-for-0.0.1.sh
new file mode 100755
index 0000000000..43d759a5cd
--- /dev/null
+++ b/scripts/database-prepare-for-0.0.1.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# This is will prepare a synapse database for running with v0.0.1 of synapse. 
+# It will store all the user information, but will *delete* all messages and
+# room data.
+
+set -e
+
+cp "$1" "$1.bak"
+
+DUMP=$(sqlite3 "$1" << 'EOF'
+.dump users
+.dump access_tokens
+.dump presence
+.dump profiles
+EOF
+)
+
+rm "$1"
+
+sqlite3 "$1" <<< "$DUMP" 
diff --git a/scripts/database-prepare-for-0.5.0.sh b/scripts/database-prepare-for-0.5.0.sh
new file mode 100755
index 0000000000..e824cb583e
--- /dev/null
+++ b/scripts/database-prepare-for-0.5.0.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# This is will prepare a synapse database for running with v0.5.0 of synapse. 
+# It will store all the user information, but will *delete* all messages and
+# room data.
+
+set -e
+
+cp "$1" "$1.bak"
+
+DUMP=$(sqlite3 "$1" << 'EOF'
+.dump users
+.dump access_tokens
+.dump presence
+.dump profiles
+EOF
+)
+
+rm "$1"
+
+sqlite3 "$1" <<< "$DUMP" 
diff --git a/scripts/database-save.sh b/scripts/database-save.sh
new file mode 100755
index 0000000000..040c8a4943
--- /dev/null
+++ b/scripts/database-save.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# This script will write a dump file of local user state if you want to splat
+# your entire server database and start again but preserve the identity of
+# local users and their access tokens.
+#
+# To restore it, use
+#
+#   $ sqlite3 homeserver.db < table-save.sql
+
+sqlite3 "$1" <<'EOF' >table-save.sql
+.dump users
+.dump access_tokens
+.dump presence
+.dump profiles
+EOF
diff --git a/scripts/nuke-room-from-db.sh b/scripts/nuke-room-from-db.sh
new file mode 100755
index 0000000000..58c036c896
--- /dev/null
+++ b/scripts/nuke-room-from-db.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+## CAUTION:
+## This script will remove (hopefully) all trace of the given room ID from
+## your homeserver.db
+
+## Do not run it lightly.
+
+ROOMID="$1"
+
+sqlite3 homeserver.db <<EOF
+DELETE FROM context_depth WHERE context = '$ROOMID';
+DELETE FROM current_state WHERE context = '$ROOMID';
+DELETE FROM feedback WHERE room_id = '$ROOMID';
+DELETE FROM messages WHERE room_id = '$ROOMID';
+DELETE FROM pdu_backward_extremities WHERE context = '$ROOMID';
+DELETE FROM pdu_edges WHERE context = '$ROOMID';
+DELETE FROM pdu_forward_extremities WHERE context = '$ROOMID';
+DELETE FROM pdus WHERE context = '$ROOMID';
+DELETE FROM room_data WHERE room_id = '$ROOMID';
+DELETE FROM room_memberships WHERE room_id = '$ROOMID';
+DELETE FROM rooms WHERE room_id = '$ROOMID';
+DELETE FROM state_pdus WHERE context = '$ROOMID';
+EOF
diff --git a/scripts/sphinx_api_docs.sh b/scripts/sphinx_api_docs.sh
new file mode 100644
index 0000000000..ee72b29657
--- /dev/null
+++ b/scripts/sphinx_api_docs.sh
@@ -0,0 +1 @@
+sphinx-apidoc -o docs/sphinx/ synapse/ -ef