summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2017-11-14 21:15:59 -0600
committerEndi S. Dewata <edewata@redhat.com>2017-11-14 21:15:59 -0600
commit75c76bdaf20b783e0764845e1e0b65a15f42fe4a (patch)
treec6da00613fbc252c4d85af483f5e2ee06deec803
parentfff08a4f08ddd6633e536d13f8ce89caeb069d2d (diff)
downloadpki-dev-75c76bdaf20b783e0764845e1e0b65a15f42fe4a.zip
pki-dev-75c76bdaf20b783e0764845e1e0b65a15f42fe4a.tar.gz
pki-dev-75c76bdaf20b783e0764845e1e0b65a15f42fe4a.tar.xz
Added wiki scripts.
-rwxr-xr-xwiki/docker/mysql-create.sh12
-rwxr-xr-xwiki/docker/mysql-import.sh6
-rwxr-xr-xwiki/docker/mysql-remove.sh3
-rwxr-xr-xwiki/docker/wiki-build.sh6
-rwxr-xr-xwiki/docker/wiki-run.sh10
-rwxr-xr-xwiki/openshift/data-create.sh16
-rwxr-xr-xwiki/openshift/data-import.sh12
-rwxr-xr-xwiki/openshift/data-mount.sh3
-rwxr-xr-xwiki/openshift/mysql-deploy.sh18
-rwxr-xr-xwiki/openshift/mysql-import.sh15
-rwxr-xr-xwiki/openshift/mysql-remove.sh6
-rwxr-xr-xwiki/openshift/mysql-undeploy.sh6
-rwxr-xr-xwiki/openshift/storage-undeploy.sh4
-rwxr-xr-xwiki/openshift/wiki-deploy.sh21
-rwxr-xr-xwiki/openshift/wiki-undeploy.sh7
15 files changed, 145 insertions, 0 deletions
diff --git a/wiki/docker/mysql-create.sh b/wiki/docker/mysql-create.sh
new file mode 100755
index 0000000..17a9230
--- /dev/null
+++ b/wiki/docker/mysql-create.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+docker run \
+ --name mysql-server \
+ --privileged \
+ -v $HOME/data:/mnt/data \
+ -e MYSQL_ROOT_PASSWORD=Secret.123 \
+ -d \
+ mysql:5.5
+
+docker exec -ti mysql-server \
+ mysql -h 127.0.0.1 --password=Secret.123 -e "create database wiki"
diff --git a/wiki/docker/mysql-import.sh b/wiki/docker/mysql-import.sh
new file mode 100755
index 0000000..8014b18
--- /dev/null
+++ b/wiki/docker/mysql-import.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+FILENAME=$1
+
+docker exec -ti mysql-server \
+ mysql wiki -h 127.0.0.1 --password=Secret.123 -e "source /mnt/data/$FILENAME"
diff --git a/wiki/docker/mysql-remove.sh b/wiki/docker/mysql-remove.sh
new file mode 100755
index 0000000..458c018
--- /dev/null
+++ b/wiki/docker/mysql-remove.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+docker rm -f mysql-server
diff --git a/wiki/docker/wiki-build.sh b/wiki/docker/wiki-build.sh
new file mode 100755
index 0000000..61d6100
--- /dev/null
+++ b/wiki/docker/wiki-build.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+s2i build \
+ https://github.com/dogtagpki/pki-wiki.git \
+ -r mediawiki-1.23 \
+ rhscl/php-56-rhel7 pki-wiki
diff --git a/wiki/docker/wiki-run.sh b/wiki/docker/wiki-run.sh
new file mode 100755
index 0000000..7934451
--- /dev/null
+++ b/wiki/docker/wiki-run.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+docker run \
+ --name pki-wiki \
+ --link mysql-server:mysql \
+ --privileged \
+ -v $HOME/data:/opt/app-root/data \
+ -p 8080:8080 \
+ --rm \
+ pki-wiki
diff --git a/wiki/openshift/data-create.sh b/wiki/openshift/data-create.sh
new file mode 100755
index 0000000..9a6610c
--- /dev/null
+++ b/wiki/openshift/data-create.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+cat > tmp/data.yaml << EOF
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+ name: data
+spec:
+ accessModes:
+ - ReadWriteOnce
+ resources:
+ requests:
+ storage: 1Gi
+EOF
+
+oc create -f tmp/data.yaml
diff --git a/wiki/openshift/data-import.sh b/wiki/openshift/data-import.sh
new file mode 100755
index 0000000..efdfffb
--- /dev/null
+++ b/wiki/openshift/data-import.sh
@@ -0,0 +1,12 @@
+#/bin/sh +x
+
+if [ $# != 1 ]; then
+ echo "usage: data-import.sh <folder>"
+ exit 1
+fi
+
+FOLDER=$1
+
+POD=`oc get pods -l deploymentconfig=pki-wiki | grep -v NAME | awk '{ print $1; }'`
+
+oc rsync $FOLDER $POD:/opt/app-root/data --no-perms
diff --git a/wiki/openshift/data-mount.sh b/wiki/openshift/data-mount.sh
new file mode 100755
index 0000000..8872155
--- /dev/null
+++ b/wiki/openshift/data-mount.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+oc volume dc/pki-wiki --add --name=data --type=persistentVolumeClaim --claim-name=data --mount-path=/opt/app-root/data
diff --git a/wiki/openshift/mysql-deploy.sh b/wiki/openshift/mysql-deploy.sh
new file mode 100755
index 0000000..c032002
--- /dev/null
+++ b/wiki/openshift/mysql-deploy.sh
@@ -0,0 +1,18 @@
+#/bin/sh +x
+
+FILENAME=$1
+
+mkdir -p tmp
+mkdir -p tmp/secrets
+
+echo "user`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 3`" > tmp/secrets/MYSQL_USER
+echo "`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`" > tmp/secrets/MYSQL_PASSWORD
+
+cat > tmp/mysql.env << EOF
+DATABASE_SERVICE_NAME=mysql
+MYSQL_DATABASE=wiki
+MYSQL_USER=`cat tmp/secrets/MYSQL_USER`
+MYSQL_PASSWORD=`cat tmp/secrets/MYSQL_PASSWORD`
+EOF
+
+oc new-app openshift/mysql-persistent --param-file tmp/mysql.env
diff --git a/wiki/openshift/mysql-import.sh b/wiki/openshift/mysql-import.sh
new file mode 100755
index 0000000..619baf8
--- /dev/null
+++ b/wiki/openshift/mysql-import.sh
@@ -0,0 +1,15 @@
+#/bin/sh +x
+
+if [ $# != 1 ]; then
+ echo "usage: mysql-import.sh <file>"
+ exit 1
+fi
+
+FILE=`basename $1`
+DIR=`dirname $1`
+
+POD=`oc get pods -l deploymentconfig=mysql | grep -v NAME | awk '{ print $1; }'`
+
+oc rsync $DIR $POD:/tmp --exclude=* --include=$FILE --no-perms
+oc rsh $POD /opt/rh/rh-mysql57/root/usr/bin/mysql -u root wiki -e "source /tmp/$FILE"
+oc rsh $POD rm -rf /tmp/$FILE
diff --git a/wiki/openshift/mysql-remove.sh b/wiki/openshift/mysql-remove.sh
new file mode 100755
index 0000000..ac1e2ab
--- /dev/null
+++ b/wiki/openshift/mysql-remove.sh
@@ -0,0 +1,6 @@
+#/bin/sh +x
+
+NAME=mysql
+
+oc delete secrets/$NAME
+oc delete pvc/$NAME
diff --git a/wiki/openshift/mysql-undeploy.sh b/wiki/openshift/mysql-undeploy.sh
new file mode 100755
index 0000000..9c04e6c
--- /dev/null
+++ b/wiki/openshift/mysql-undeploy.sh
@@ -0,0 +1,6 @@
+#/bin/sh +x
+
+NAME=mysql
+
+oc delete svc/$NAME
+oc delete dc/$NAME
diff --git a/wiki/openshift/storage-undeploy.sh b/wiki/openshift/storage-undeploy.sh
new file mode 100755
index 0000000..aefcb05
--- /dev/null
+++ b/wiki/openshift/storage-undeploy.sh
@@ -0,0 +1,4 @@
+#/bin/sh +x
+
+oc delete secrets/data
+oc delete pvc/data
diff --git a/wiki/openshift/wiki-deploy.sh b/wiki/openshift/wiki-deploy.sh
new file mode 100755
index 0000000..06a7d6e
--- /dev/null
+++ b/wiki/openshift/wiki-deploy.sh
@@ -0,0 +1,21 @@
+#/bin/sh +x
+
+mkdir -p tmp
+
+cat > tmp/pki-wiki.env << EOF
+OPENSHIFT_MYSQL_DB_HOST=mysql.dogtagpki.svc
+OPENSHIFT_MYSQL_DB_PORT=3306
+OPENSHIFT_MYSQL_DB_USERNAME=`cat tmp/secrets/MYSQL_USER`
+OPENSHIFT_MYSQL_DB_PASSWORD=`cat tmp/secrets/MYSQL_PASSWORD`
+OPENSHIFT_APP_NAME=wiki
+MEDIAWIKI_SECRET_KEY=`cat MEDIAWIKI_SECRET_KEY`
+MEDIAWIKI_UPGRADE_KEY=`cat MEDIAWIKI_UPGRADE_KEY`
+PKI_BACKUP_DIR=`cat PKI_BACKUP_DIR`
+GDRIVE_CONFIG_DIR=/opt/app-root/data/.gdrive
+EOF
+
+oc new-app \
+ openshift/php:5.6~https://github.com/dogtagpki/pki-wiki.git#mediawiki-1.23 \
+ --env-file=tmp/pki-wiki.env
+
+oc expose svc/pki-wiki --hostname `cat HOSTNAME`
diff --git a/wiki/openshift/wiki-undeploy.sh b/wiki/openshift/wiki-undeploy.sh
new file mode 100755
index 0000000..883008d
--- /dev/null
+++ b/wiki/openshift/wiki-undeploy.sh
@@ -0,0 +1,7 @@
+#/bin/sh +x
+
+oc delete routes/pki-wiki
+oc delete svc/pki-wiki
+oc delete is/pki-wiki
+oc delete dc/pki-wiki
+oc delete bc/pki-wiki