aboutsummaryrefslogtreecommitdiffstats
path: root/build/apt
diff options
context:
space:
mode:
Diffstat (limited to 'build/apt')
-rw-r--r--build/apt/.gitignore5
-rw-r--r--build/apt/DEBIAN/control16
-rwxr-xr-xbuild/apt/DEBIAN/postinst143
-rwxr-xr-xbuild/apt/DEBIAN/prerm30
-rw-r--r--build/apt/DEBIAN/templates68
-rw-r--r--build/apt/README25
-rw-r--r--build/apt/TODO7
-rwxr-xr-xbuild/apt/build/build.sh236
-rw-r--r--build/apt/build/makejar.diff17
-rwxr-xr-xbuild/apt/build/run.sh28
-rwxr-xr-xbuild/apt/build/test.sh52
-rwxr-xr-xbuild/apt/do.sh127
-rw-r--r--build/apt/etc/etherpad/etherpad.properties16
-rw-r--r--build/apt/etc/etherpad/properties/admin-password0
-rw-r--r--build/apt/etc/etherpad/properties/database-host0
-rw-r--r--build/apt/etc/etherpad/properties/database-name0
-rw-r--r--build/apt/etc/etherpad/properties/database-password0
-rw-r--r--build/apt/etc/etherpad/properties/database-port0
-rw-r--r--build/apt/etc/etherpad/properties/database-username0
-rw-r--r--build/apt/etc/etherpad/properties/is-production0
-rw-r--r--build/apt/etc/etherpad/properties/port0
-rwxr-xr-xbuild/apt/etc/init.d/etherpad235
22 files changed, 1005 insertions, 0 deletions
diff --git a/build/apt/.gitignore b/build/apt/.gitignore
new file mode 100644
index 0000000..50139f0
--- /dev/null
+++ b/build/apt/.gitignore
@@ -0,0 +1,5 @@
+*~
+.tmp*
+.build*
+.package*
+.revision*
diff --git a/build/apt/DEBIAN/control b/build/apt/DEBIAN/control
new file mode 100644
index 0000000..0129652
--- /dev/null
+++ b/build/apt/DEBIAN/control
@@ -0,0 +1,16 @@
+Package: etherpad-%BRANCH%
+Priority: optional
+Section: web
+Maintainer: penSec.IT UG (haftungsbeschränkt) <etherpad@pensec.it>
+Architecture: all
+Version: 1.0-%REVISION%
+Depends: debconf (>= 0.2.17), sun-java6-jre, scala, mysql-server, mysql-client, libmysql-java, bash
+Description: Etherpad is...
+ EtherPad is the only web-based word processor that allows people to work
+ together in really real-time.
+ .
+ When multiple people edit the same document simultaneously, any changes are
+ instantly reflected on everyone's screen. The result is a new and productive
+ way to collaborate on text documents, useful for meeting notes, drafting
+ sessions, education, team programming, and more.
+
diff --git a/build/apt/DEBIAN/postinst b/build/apt/DEBIAN/postinst
new file mode 100755
index 0000000..f872508
--- /dev/null
+++ b/build/apt/DEBIAN/postinst
@@ -0,0 +1,143 @@
+#!/bin/bash
+
+################################################################################
+#
+# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
+# http://www.pensec.it
+# mail@pensec.it
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+################################################################################
+
+
+
+set -e
+. /usr/share/debconf/confmodule
+
+if [ -n "$ETHERPAD_DEBUG" ]; then
+ echo "now debugging $0 $@"
+ set -x
+fi
+
+db_version 2.0
+
+
+
+
+
+#####
+#
+# Propts the user for a configuration value and writes it into a property file
+#
+# @param $1 Name of the debconfig template to prompt
+# @param $2 File to write the answer to
+# @param $3 deprecated
+#
+function configuration_property() {
+ TEMPLATE="${1}"
+ PROPERTY_FILE="/etc/etherpad/properties/${2}"
+ PLACEHOLDER="${3}"
+
+ PROPERTY=""
+ if [ -f "${PROPERTY_FILE}" ]; then
+ PROPERTY=`cat "${PROPERTY_FILE}"`
+ fi
+ db_input high "etherpad-%BRANCH%/${TEMPLATE}" || true
+ db_go
+
+ db_get "etherpad-%BRANCH%/${TEMPLATE}"
+ if [ "" != "$RET" ]; then
+ PROPERTY="$RET"
+ fi
+
+ echo "${PROPERTY}" > "${PROPERTY_FILE}"
+}
+#
+#####
+
+
+
+case "$1" in
+
+ configure)
+
+ # Create system user
+ if ! getent passwd etherpad > /dev/null ; then
+ echo 'Adding system-user for etherpad' 1>&2
+ adduser --system --group --quiet \
+ --home /usr/share/etherpad --no-create-home \
+ --disabled-login --force-badname etherpad
+ fi
+
+
+ # Give user the rights to write into the log & data directory
+ if [ -d "/var/log/etherpad" ]; then
+ EMPTY_STATEMENT="true"
+ else
+ mkdir -p "/var/log/etherpad"
+ fi
+ chown -R etherpad:etherpad "/var/log/etherpad"
+
+ if [ -d "/usr/share/etherpad/etherpad/data" ]; then
+ EMPTY_STATEMENT="true"
+ else
+ mkdir -p "/usr/share/etherpad/etherpad/data"
+ fi
+ chown -R etherpad:etherpad "/usr/share/etherpad/etherpad/data"
+
+
+ # Give user the rights do write everywhere, did not yet figure
+ # out which rights are necessary, exactly
+ chown -R etherpad:etherpad "/usr/share/etherpad"
+ ;;
+
+esac
+
+
+
+#####
+#
+# Get configuration properties
+#
+configuration_property "is_production" "is-production" "IS_PRODUCTION"
+configuration_property "admin_password" "admin-password" "ADMIN_PASSWORD"
+configuration_property "port" "port" "PORT"
+configuration_property "database_host" "database-host" "DATABASE_HOST"
+configuration_property "database_port" "database-port" "DATABASE_PORT"
+configuration_property "database_name" "database-name" "DATABASE_NAME"
+configuration_property "database_username" "database-username" "DATABASE_USERNAME"
+configuration_property "database_password" "database-password" "DATABASE_PASSWORD"
+#
+#####
+
+
+
+
+
+#####
+#
+# MySQL-Autosetup should be discussed. Simply calling setup-myql-db.sh is
+# insufficient
+#
+# # Auto-setup database
+# db_input medium "etherpad-%BRANCH%/setup_database" || true
+# db_go
+#
+# db_get "etherpad-%BRANCH%/setup_database"
+# if [ "$RET" = "true" ]; then
+# # TODO
+# fi
+#
+#####
+
diff --git a/build/apt/DEBIAN/prerm b/build/apt/DEBIAN/prerm
new file mode 100755
index 0000000..9a9f516
--- /dev/null
+++ b/build/apt/DEBIAN/prerm
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+################################################################################
+#
+# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
+# http://www.pensec.it
+# mail@pensec.it
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+################################################################################
+
+
+
+set -e
+
+# Remove log+data directories, otherwise uninstall will fail
+rm -rf /var/log/etherpad
+rm -rf /usr/share/etherpad/etherpad/data
+
diff --git a/build/apt/DEBIAN/templates b/build/apt/DEBIAN/templates
new file mode 100644
index 0000000..d7c6f36
--- /dev/null
+++ b/build/apt/DEBIAN/templates
@@ -0,0 +1,68 @@
+Template: etherpad-%BRANCH%/is_production
+Type: boolean
+Default: false
+Description: Install as production mode?
+ Do you wish to install etherpad in production mode?
+ .
+ Note: be aware that etherpad is under active development and not yet ready
+ for general deployment!
+
+Template: etherpad-%BRANCH%/admin_password
+Type: password
+Default: password
+Description: etherpad administration password
+ Please insert the administration password, default is password.
+
+Template: etherpad-%BRANCH%/port
+Type: string
+Default: 9000
+Description: etherpad tcp port
+ Please insert the port on which etherpad should listen, default is 9000. You
+ cannot use privileged ports (<= 1024).
+ .
+ If you want to make etherpad available on port 80/443 use etherpad-proxy which
+ will install a webserver (like nginx or apache) to proxy dynamic etherpad
+ contents and serve static contents directly.
+
+Template: etherpad-%BRANCH%/setup_database
+Type: boolean
+Default: false
+Description: Do yo want etherpad to create a database for you?
+ Do you want to use the database wizard to setup a database for etherpad to
+ use?
+ .
+ Note: This wizard only works with local mysql installations. If you want to use
+ a remote mysql database, then answer no and edit
+ /etc/etherpad/etherpad.properties appropriatly.
+
+Template: etherpad-%BRANCH%/database_host
+Type: string
+Default: localhost
+Description: MySQL database hostname
+ Please insert the database hostname, default is localhost.
+
+Template: etherpad-%BRANCH%/database_port
+Type: string
+Default: 3306
+Description: MySQL database port
+ Please insert the database port, default is 3306.
+
+Template: etherpad-%BRANCH%/database_name
+Type: string
+Default: etherpad
+Description: MySQL database name
+ Please insert the database name, default is etherpad.
+
+Template: etherpad-%BRANCH%/database_username
+Type: string
+Default: etherpad
+Description: MySQL database username
+ Please insert the database username, default is etherpad.
+
+Template: etherpad-%BRANCH%/database_password
+Type: password
+Default: password
+Description: MySQL database password
+ Please insert the password for the specified database user, default is
+ password.
+
diff --git a/build/apt/README b/build/apt/README
new file mode 100644
index 0000000..7dba49b
--- /dev/null
+++ b/build/apt/README
@@ -0,0 +1,25 @@
+README
+======
+
+This is a simple script to build debian packages from different etherpad
+repositories. All you have to do is call ./do.sh and select the repository to
+build from.
+
+Depending on the repository you use you have to have installed mercurial or
+git-core in addition to the following packages:
+
+ * debconf (>= 0.2.17)
+ * dpkg
+ * sun-java6-jdk
+ * scala
+ * mysql-client
+ * libmysql-java
+ * bash
+
+
+
+---
+
+If you need commercial support on etherpad don't hesitate to contact
+mail@pensec.it
+
diff --git a/build/apt/TODO b/build/apt/TODO
new file mode 100644
index 0000000..9389c82
--- /dev/null
+++ b/build/apt/TODO
@@ -0,0 +1,7 @@
+TODO
+====
+
+ * Auto-Database setup
+ * etherpad-official replaces etherpad-deprecated and etherpad-devel (and vice-
+ versa)
+
diff --git a/build/apt/build/build.sh b/build/apt/build/build.sh
new file mode 100755
index 0000000..ce308bb
--- /dev/null
+++ b/build/apt/build/build.sh
@@ -0,0 +1,236 @@
+#!/bin/bash
+
+################################################################################
+#
+# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
+# http://www.pensec.it
+# mail@pensec.it
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+################################################################################
+
+
+
+#####
+# Build a Debian/Ubuntu Etherpad package of the source
+#
+# @param $1 (optional) If "${1}" == "rebuild" then the cached repository will be
+# purged and cloned instead of simply updated
+# @param $REPOSITORY_URL the source of the package
+# @param $REPOSITORY_NAME name of the new package, package will be named
+# etherpad-${REPOSITORY_NAME}
+# @param $REPOSITORY_TYPE Element of set {hg, git}, describes which command line
+# toolchain (mercurial or git) will be used
+#
+if [ "" == "${REPOSITORY_URL}" ]; then
+ echo "Missing environment variable REPOSITORY_URL"
+ exit 1
+fi
+if [ "" == "${REPOSITORY_NAME}" ]; then
+ echo "Missing environment variable REPOSITORY_NAME"
+ exit 1
+fi
+if [ "" == "${REPOSITORY_TYPE}" ]; then
+ echo "Missing environment variable REPOSITORY_TYPE"
+ exit 1
+fi
+
+
+
+#####
+# You have to change following lines to your requirements:
+#
+export JAVA_HOME=/usr/lib/jvm/java-6-sun/
+export SCALA_HOME=/usr/share/java
+export MYSQL_CONNECTOR_JAR=/usr/share/java/mysql-connector-java.jar
+export JAVA="$JAVA_HOME/bin/java"
+export SCALA="$SCALA_HOME/bin/scala"
+export PATH="$JAVA_HOME/bin:$SCALA_HOME/bin:$PATH"
+#
+#####
+
+
+#####
+# Don't change this!
+#
+REPOSITORY="${REPOSITORY_URL}"
+BRANCH="${REPOSITORY_NAME}"
+
+TMP_DIR=".tmp.${REPOSITORY_NAME}"
+BUILD_DIR=".build.${REPOSITORY_NAME}"
+PACKAGE_DIR=".package.${REPOSITORY_NAME}"
+REVISION_FILE=".revision.${REPOSITORY_NAME}"
+
+REBUILD="no"
+if [ "rebuild" == "${1}" ]; then
+ REBUILD="yes"
+fi
+#
+#####
+
+
+
+# If the repository isn't checked out by now we can't do a simple {git|hg} pull,
+# we need to do a complete {git|hg} clone instead
+if [ "yes" != "${REBUILD}" ]; then
+ if [ -d "${TMP_DIR}" ]; then
+ bash -c "cd ${TMP_DIR}; ${REPOSITORY_TYPE} pull"
+ else
+ echo "Repository does not exist, will fetch"
+ REBUILD="yes"
+ fi
+fi
+
+# Refresh the complett repository (purge & clone instead of pull)
+if [ "yes" == "${REBUILD}" ]; then
+ if [ -d "${TMP_DIR}" ]; then
+ rm -rf "${TMP_DIR}"
+ fi
+
+ # Fetch the source from remote endpoint
+ $REPOSITORY_TYPE clone "${REPOSITORY}" "${TMP_DIR}"
+fi
+
+
+
+# If there where errors during {git,hg} clone, then ${TMP_DIR} does not exist
+# and we can't continue
+if [ -d "${TMP_DIR}" ]; then
+ echo "Checkout seesm successful, continuing..."
+else
+ echo "Error while checkout, missing directory ${TMP_DIR}"
+ exit 1
+fi
+
+# Ugly fix to work with the google repository which includes a trunk and
+# branches directory instead of using mercurial branches
+if [ -d "${TMP_DIR}/trunk" ]; then
+ touch "${TMP_DIR}/LICENSE"
+ touch "${TMP_DIR}/README.md"
+ bash -c "cd ${TMP_DIR}; cp -r trunk/* ./"
+fi
+
+
+
+# Rebuild jar
+echo ""
+echo "Trying to apply patch. If it detects the patch doesn't match just skip"
+echo ""
+cp "build/makejar.diff" "${TMP_DIR}/makejar.diff"
+bash -c "cd ${TMP_DIR}; patch -p1 < makejar.diff"
+bash -c "cd ${TMP_DIR}/infrastructure; ./bin/makejar.sh"
+bash -c "cd ${TMP_DIR}/infrastructure/ace; bin/make normal etherpad"
+cp "${TMP_DIR}/infrastructure/build/appjet.jar" "${TMP_DIR}/etherpad/appjet-eth-dev.jar"
+
+
+
+# Testing the build
+#bash -c "./build/test-build.sh"
+
+
+
+# Increments the version & create the control file
+REVISION="0"
+if [ -f "${REVISION_FILE}" ]; then
+ REVISION=`cat "${REVISION_FILE}"`
+ REVISION=`expr $REVISION + 1`
+fi
+echo $REVISION > "${REVISION_FILE}"
+
+# Patch the debain control file
+cp "DEBIAN/control" "${TMP_DIR}/control.0"
+sed "s/%BRANCH%/${BRANCH}/" "${TMP_DIR}/control.0" > "${TMP_DIR}/control.1"
+sed "s/%REVISION%/${REVISION}/" "${TMP_DIR}/control.1" > "${TMP_DIR}/control.2"
+cp "${TMP_DIR}/control.2" "${TMP_DIR}/control"
+
+# Patch the install & deinstall script
+cp "DEBIAN/prerm" "${TMP_DIR}/prerm"
+cp "DEBIAN/postinst" "${TMP_DIR}/postinst.0"
+sed "s/%BRANCH%/${BRANCH}/" "${TMP_DIR}/postinst.0" > "${TMP_DIR}/postinst.1"
+cp "${TMP_DIR}/postinst.1" "${TMP_DIR}/postinst"
+
+# Patch debconf templates
+cp "DEBIAN/templates" "${TMP_DIR}/templates.0"
+sed "s/%BRANCH%/${BRANCH}/" "${TMP_DIR}/templates.0" > "${TMP_DIR}/templates.1"
+cp "${TMP_DIR}/templates.1" "${TMP_DIR}/templates"
+
+# Patch init script
+cp "etc/init.d/etherpad" "${TMP_DIR}/init.0"
+sed "s/%BRANCH%/${BRANCH}/" "${TMP_DIR}/init.0" > "${TMP_DIR}/init.1"
+cp "${TMP_DIR}/init.1" "${TMP_DIR}/init"
+
+# Copy the config folder
+cp -r "etc" "${TMP_DIR}/etc"
+
+
+
+# Build the package enviroment (needed to build with dpgk-deb build)
+if [ -d "${BUILD_DIR}" ]; then
+ sudo rm -r "${BUILD_DIR}"
+fi
+mkdir "${BUILD_DIR}"
+mkdir -p "${BUILD_DIR}/DEBIAN"
+mkdir -p "${BUILD_DIR}/usr/share/etherpad"
+mkdir -p "${BUILD_DIR}/usr/share/doc/etherpad"
+mkdir -p "${BUILD_DIR}/var/log/etherpad"
+
+
+
+# Gather the required files
+cp "${TMP_DIR}/control" "${BUILD_DIR}/DEBIAN/control"
+cp "${TMP_DIR}/postinst" "${BUILD_DIR}/DEBIAN/postinst"
+cp "${TMP_DIR}/prerm" "${BUILD_DIR}/DEBIAN/prerm"
+cp "${TMP_DIR}/templates" "${BUILD_DIR}/DEBIAN/templates"
+cp -r "${TMP_DIR}/etc" "${BUILD_DIR}/"
+cp "${TMP_DIR}/init" "${BUILD_DIR}/etc/init.d/etherpad"
+cp -r "${TMP_DIR}/etherpad" "${BUILD_DIR}/usr/share/etherpad"
+cp "build/run.sh" "${BUILD_DIR}/usr/share/etherpad/etherpad/bin"
+mkdir -p "${BUILD_DIR}/usr/share/etherpad/etherpad/data"
+cp -r "${TMP_DIR}/infrastructure" "${BUILD_DIR}/usr/share/etherpad"
+cp "${TMP_DIR}/COPYING" "${BUILD_DIR}/usr/share/doc/etherpad"
+cp "${TMP_DIR}/LICENSE" "${BUILD_DIR}/usr/share/doc/etherpad"
+cp "${TMP_DIR}/README.md" "${BUILD_DIR}/usr/share/doc/etherpad"
+
+
+
+# Fix priviliges and build the package
+sudo chown -R root:root "${BUILD_DIR}"
+sudo chmod +x "${BUILD_DIR}/DEBIAN/postinst"
+sudo chmod +x "${BUILD_DIR}/DEBIAN/prerm"
+sudo chmod +x "${BUILD_DIR}/etc/init.d/etherpad"
+sudo chmod -R 777 "${BUILD_DIR}/usr/share/etherpad/etherpad/data"
+
+if [ -d "${PACKAGE_DIR}" ]; then
+ rm -rf "${PACKAGE_DIR}"
+fi
+mkdir "${PACKAGE_DIR}"
+
+dpkg-deb --build "${BUILD_DIR}" "${PACKAGE_DIR}"
+
+
+
+# Transfer the package to local repository if environment variable
+PACKAGE=`bash -c "cd ${PACKAGE_DIR}; find . -name *.deb"`
+
+if [ "yes" == "${DEPLOY_TO_LOCAL_REPOSITORY}" ]; then
+ if [ -f "${PACKAGE_DIR}/${PACKAGE}" ]; then
+ cp "${PACKAGE_DIR}/${PACKAGE}" "/var/www/packages"
+ bash -c "cd /var/www/packages; reprepro -b . includedeb lenny ${PACKAGE}; rm ${PACKAGE}"
+ else
+ echo "No package in ${PACKAGE_DIR}"
+ fi
+fi
+
+echo "Finished building package ${PACKAGE}"
+
diff --git a/build/apt/build/makejar.diff b/build/apt/build/makejar.diff
new file mode 100644
index 0000000..6e0d44e
--- /dev/null
+++ b/build/apt/build/makejar.diff
@@ -0,0 +1,17 @@
+diff -r 81287c8af1ac infrastructure/bin/makejar.sh
+--- a/infrastructure/bin/makejar.sh Fri Dec 18 18:44:23 2009 +1100
++++ b/infrastructure/bin/makejar.sh Sat Dec 19 09:50:05 2009 -0500
+@@ -32,11 +32,11 @@
+
+ TMPSTORE=/tmp/ajbuild-tmpstore-`date +%s`
+
+-JARFILES=`echo $SCALA_HOME/lib/scala-library.jar lib/*.jar lib/manifest`
++JARFILES=`echo $SCALA_HOME/scala-library.jar lib/*.jar lib/manifest`
+ function genjar {
+ echo "unzipping JARs..."
+ pushd $1 >> /dev/null
+- $JAR xf $SCALA_HOME/lib/scala-library.jar
++ $JAR xf $SCALA_HOME/scala-library.jar
+ rm -rf META-INF
+ for a in ../../lib/*.jar; do
+ $JAR xf $a
diff --git a/build/apt/build/run.sh b/build/apt/build/run.sh
new file mode 100755
index 0000000..1aa3954
--- /dev/null
+++ b/build/apt/build/run.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+################################################################################
+#
+# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
+# http://www.pensec.it
+# mail@pensec.it
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+################################################################################
+
+
+
+
+
+bash -c "`dirname $0`/run-local.sh" > "/var/log/etherpad/log" 2> "/var/log/etherpad/error"
+
diff --git a/build/apt/build/test.sh b/build/apt/build/test.sh
new file mode 100755
index 0000000..0abf7bf
--- /dev/null
+++ b/build/apt/build/test.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+################################################################################
+#
+# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
+# http://www.pensec.it
+# mail@pensec.it
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+################################################################################
+
+
+
+
+
+#####
+# Must be called by build.sh
+#####
+
+
+
+# Truncate database to test start etherpad
+echo "I'm going to lunch MySQL now, you maybe have to enter your root@localhost password"
+sudo /etc/init.d/mysql start
+
+DATABASE_NAME="etherpad"
+DATABASE_USER="etherpad"
+DROP_DATABASE="DROP DATABASE ${DATABASE_NAME}"
+CREATE_DATABASE="CREATE DATABASE ${DATABASE_NAME}"
+DROP_USER="DROP USER '${DATABASE_USER}'@'localhost'"
+CREATE_USER="GRANT ALL PRIVILEGES ON ${DATABASE_NAME}.* TO '${DATABASE_USER}'@'localhost' identified by 'password';"
+echo "${DROP_DATABASE}; ${CREATE_DATABASE}; ${DROP_USER}; ${CREATE_USER}" | mysql -u root -p | grep etherpad
+
+
+
+# Start etherpad and wait for the HTTP-Server to be available
+echo "I'm going to lunch etherpad in a clean environment, try if it works on http://localhost:9000/"
+echo "Kill with ^C to build debian package (waiting 10 seconds)"
+sleep 10
+bash -c "cd ${TMP_DIR}/etherpad; ./bin/run-local.sh"
+
diff --git a/build/apt/do.sh b/build/apt/do.sh
new file mode 100755
index 0000000..c268ce9
--- /dev/null
+++ b/build/apt/do.sh
@@ -0,0 +1,127 @@
+#!/bin/bash
+
+################################################################################
+#
+# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
+# http://www.pensec.it
+# mail@pensec.it
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+################################################################################
+
+
+
+#####
+#
+# To build a Debian/Ubuntu package simply run this script. It will prompt you
+# for the repository to build from.
+#
+# Dependencies: debconf (>= 0.2.17), dpkg, sun-java6-jdk, scala, mysql-client,
+# libmysql-java, bash, mercurial | git-core
+#
+#####
+
+
+
+#####
+#
+# There has to be a better way of doing this ;-)
+#
+REPOSITORY_0_URL="https://etherpad.googlecode.com/hg/trunk"
+REPOSITORY_0_NAME="deprecated"
+REPOSITORY_0_TYPE="hg"
+REPOSITORY_1_URL="git://github.com/ether/pad.git"
+REPOSITORY_1_NAME="official"
+REPOSITORY_1_TYPE="git"
+REPOSITORY_2_URL="git://github.com/redhog/pad.git"
+REPOSITORY_2_NAME="devel"
+REPOSITORY_2_TYPE="git"
+REPOSITORY_3_URL="git://github.com/johnyma22/pad.git"
+REPOSITORY_3_NAME="johny"
+REPOSITORY_3_TYPE="git"
+REPOSITORY_4_URL="git://github.com/Pita/pad.git"
+REPOSITORY_4_NAME="pita"
+REPOSITORY_4_TYPE="git"
+REPOSITORY_5_URL="./../../"
+REPOSITORY_5_NAME="local"
+REPOSITORY_5_TYPE="git"
+
+
+# Tell the user his choises
+echo "Please choose the repository to build a debian package from:"
+echo ""
+
+for i in {0..5}
+do
+ URL="REPOSITORY_${i}_URL"
+ NAME="REPOSITORY_${i}_NAME"
+ TYPE="REPOSITORY_${i}_TYPE"
+
+ echo " ${i}) ${!NAME} ${!URL}"
+done
+echo ""
+read -p "Repository id: " REPOSITORY
+
+
+
+# Test if user's too stupid to input correct number
+URL="REPOSITORY_${REPOSITORY}_URL"
+NAME="REPOSITORY_${REPOSITORY}_NAME"
+TYPE="REPOSITORY_${REPOSITORY}_TYPE"
+
+if [ "" == "${!URL}" ]; then
+ echo "Invalid repository id \"${REPOSITORY}\""
+ exit 1
+fi
+
+
+# Communicate repository details to build script
+export REPOSITORY_URL="${!URL}"
+export REPOSITORY_NAME="${!NAME}"
+export REPOSITORY_TYPE="${!TYPE}"
+#
+#####
+
+
+
+#####
+#
+# Is a complete rebuild necessary or is a simple update sufficient
+#
+echo ""
+read -p "Purge before rebuild (yes/no) [n]: " REBUILD
+
+if [ "y" == "${REBUILD}" ]; then
+ echo "You answered \"${REBUILD}\", will purge before rebuilding"
+ REBUILD="rebuild"
+else
+ echo "You answered \"${REBUILD}\", will try ${!TYPE} pull before rebuilding"
+fi
+#
+#####
+
+
+
+#####
+#
+# Tell user what we're going to to and then do it
+#
+echo ""
+echo "Will build package etherpad-${!NAME} form ${!TYPE}:${!URL}, please be patient..."
+echo ""
+
+bash -c "./build/build.sh ${REBUILD}"
+#
+#####
+
diff --git a/build/apt/etc/etherpad/etherpad.properties b/build/apt/etc/etherpad/etherpad.properties
new file mode 100644
index 0000000..69114c7
--- /dev/null
+++ b/build/apt/etc/etherpad/etherpad.properties
@@ -0,0 +1,16 @@
+ajstdlibHome = ../infrastructure/framework-src/modules
+appjetHome = ./data/appjet
+devMode = true
+etherpad.adminPass = %ADMIN_PASSWORD%
+etherpad.fakeProduction = false
+etherpad.isProduction = %IS_PRODUCTION%
+etherpad.SQL_JDBC_DRIVER = com.mysql.jdbc.Driver
+etherpad.SQL_JDBC_URL = jdbc:mysql://%DATABASE_HOST%:%DATABASE_PORT%/%DATABASE_NAME%
+etherpad.SQL_PASSWORD = %DATABASE_PASSWORD%
+etherpad.SQL_USERNAME = %DATABASE_USERNAME%
+listen = %PORT%
+logDir = /var/log/etherpad
+modulePath = ./src
+transportPrefix = /comet
+transportUseWildcardSubdomains = true
+useVirtualFileRoot = ./src
diff --git a/build/apt/etc/etherpad/properties/admin-password b/build/apt/etc/etherpad/properties/admin-password
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/admin-password
diff --git a/build/apt/etc/etherpad/properties/database-host b/build/apt/etc/etherpad/properties/database-host
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/database-host
diff --git a/build/apt/etc/etherpad/properties/database-name b/build/apt/etc/etherpad/properties/database-name
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/database-name
diff --git a/build/apt/etc/etherpad/properties/database-password b/build/apt/etc/etherpad/properties/database-password
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/database-password
diff --git a/build/apt/etc/etherpad/properties/database-port b/build/apt/etc/etherpad/properties/database-port
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/database-port
diff --git a/build/apt/etc/etherpad/properties/database-username b/build/apt/etc/etherpad/properties/database-username
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/database-username
diff --git a/build/apt/etc/etherpad/properties/is-production b/build/apt/etc/etherpad/properties/is-production
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/is-production
diff --git a/build/apt/etc/etherpad/properties/port b/build/apt/etc/etherpad/properties/port
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/apt/etc/etherpad/properties/port
diff --git a/build/apt/etc/init.d/etherpad b/build/apt/etc/init.d/etherpad
new file mode 100755
index 0000000..95847b8
--- /dev/null
+++ b/build/apt/etc/init.d/etherpad
@@ -0,0 +1,235 @@
+#! /bin/bash
+
+### BEGIN INIT INFO
+# Provides: etherpad-%BRANCH%
+# Required-Start: $local_fs $remote_fs
+# Required-Stop: $local_fs $remote_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: S 0 1 6
+# Short-Description: etherpad initscript
+# Description: EtherPad is the only web-based word processor that allows
+# people to work together in really real-time.
+# .
+# When multiple people edit the same document simultaneously,
+# any changes are instantly reflected on everyone's screen.
+# The result is a new and productive way to collaborate on
+# text documents, useful for meeting notes, drafting
+# sessions, education, team programming, and more.
+### END INIT INFO
+
+# Author: penSec.IT UG (haftungsbeschränkt) <mail@pensec.it>
+
+################################################################################
+#
+# Copyright (c) 2010 penSec.IT UG (haftungsbeschränkt)
+# http://www.pensec.it
+# mail@pensec.it
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+#
+################################################################################
+
+# Do NOT "set -e"
+
+
+
+#####
+#
+# Patches the configuration file by replacing ,,%$2%'' with the contents of file
+# $1 in file $3
+#
+# @param $1 Configuration File which contains the value to set to
+# @param $2 Configuration key to apply (can be done only once)
+# @param $3 Configuration file
+#
+function apply_config() {
+ CONFIG_FILE="${3}"
+ TMP_FILE="/tmp/etherpad.properties"
+
+ CONFIG_KEY="$2"
+ CONFIG_VALUE=`cat $1`
+
+ sed "s/%$CONFIG_KEY%/$CONFIG_VALUE/" $CONFIG_FILE > $TMP_FILE
+ cp $TMP_FILE $CONFIG_FILE
+ rm $TMP_FILE
+}
+#
+#####
+
+
+
+
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+DESC="etherpad daemon"
+NAME="etherpad"
+DAEMON_BASE="/usr/share/etherpad/etherpad"
+DAEMON=$DAEMON_BASE/bin/run.sh
+DAEMON_ARGS=""
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+[ -f /etc/default/rcS ] && . /etc/default/rcS
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ CONFIGURATION_BASE="/etc/etherpad"
+ CONFIGURATION_SRC="${CONFIGURATION_BASE}/etherpad.properties"
+ CONFIGURATION_DEST="${DAEMON_BASE}/etc/etherpad.localdev-default.properties"
+
+
+ # Reset configuration
+ cp "${CONFIGURATION_BASE}/etherpad.properties" "${CONFIGURATION_DEST}"
+
+
+ # Apply configuration properties
+ apply_config "${CONFIGURATION_BASE}/properties/is-production" "IS_PRODUCTION" "${CONFIGURATION_DEST}"
+ apply_config "${CONFIGURATION_BASE}/properties/admin-password" "ADMIN_PASSWORD" "${CONFIGURATION_DEST}"
+ apply_config "${CONFIGURATION_BASE}/properties/port" "PORT" "${CONFIGURATION_DEST}"
+ apply_config "${CONFIGURATION_BASE}/properties/database-host" "DATABASE_HOST" "${CONFIGURATION_DEST}"
+ apply_config "${CONFIGURATION_BASE}/properties/database-port" "DATABASE_PORT" "${CONFIGURATION_DEST}"
+ apply_config "${CONFIGURATION_BASE}/properties/database-name" "DATABASE_NAME" "${CONFIGURATION_DEST}"
+ apply_config "${CONFIGURATION_BASE}/properties/database-username" "DATABASE_USERNAME" "${CONFIGURATION_DEST}"
+ apply_config "${CONFIGURATION_BASE}/properties/database-password" "DATABASE_PASSWORD" "${CONFIGURATION_DEST}"
+
+
+ # Give the etherpad user the configuration file
+ chown etherpad:etherpad "${CONFIGURATION_DEST}"
+
+
+
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --background --chdir $DAEMON_BASE --chuid etherpad:etherpad --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON --test \
+ || return 1
+ start-stop-daemon --background --chdir $DAEMON_BASE --chuid etherpad:etherpad --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
+