Merge pull request #2007 from ether/packaging

Debian deb file Packager
This commit is contained in:
John McLear 2013-11-25 09:40:04 -08:00
commit fb69e6b0a3
7 changed files with 119 additions and 0 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ npm-debug.log
.ep_initialized
*.crt
*.key
bin/etherpad-1.deb

44
bin/buildDebian.sh Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
# IMPORTANT
# Protect agaisnt mispelling a var and rm -rf /
set -u
set -e
SRC=/tmp/etherpad-deb-src
DIST=/tmp/etherpad-deb-dist
SYSROOT=${SRC}/sysroot
DEBIAN=${SRC}/DEBIAN
rm -rf ${DIST}
mkdir -p ${DIST}/
rm -rf ${SRC}
rsync -a bin/deb-src/ ${SRC}/
mkdir -p ${SYSROOT}/opt/
rsync --exclude '.git' -a . ${SYSROOT}/opt/etherpad/ --delete
mkdir -p ${SYSROOT}/usr/share/doc
cp README.md ${SYSROOT}/usr/share/doc/etherpad
find ${SRC}/ -type d -exec chmod 0755 {} \;
find ${SRC}/ -type f -exec chmod go-w {} \;
chown -R root:root ${SRC}/
let SIZE=`du -s ${SYSROOT} | sed s'/\s\+.*//'`+8
pushd ${SYSROOT}/
tar czf ${DIST}/data.tar.gz [a-z]*
popd
sed s"/SIZE/${SIZE}/" -i ${DEBIAN}/control
pushd ${DEBIAN}
tar czf ${DIST}/control.tar.gz *
popd
pushd ${DIST}/
echo 2.0 > ./debian-binary
find ${DIST}/ -type d -exec chmod 0755 {} \;
find ${DIST}/ -type f -exec chmod go-w {} \;
chown -R root:root ${DIST}/
ar r ${DIST}/etherpad-1.deb debian-binary control.tar.gz data.tar.gz
popd
rsync -a ${DIST}/etherpad-1.deb ./

View File

@ -0,0 +1,9 @@
Package: etherpad
Version: 1.3
Section: base
Priority: optional
Architecture: i386
Installed-Size: SIZE
Depends:
Maintainer: John McLear <john@mclear.co.uk>
Description: Etherpad is a collaborative editor.

7
bin/deb-src/DEBIAN/postinst Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# Start the services!
service etherpad start
echo "Give Etherpad about 3 minutes to install dependencies then visit http://localhost:9001 in your web browser"
echo "To stop etherpad type 'service etherpad stop', To restart type 'service etherpad restart'".
rm -f /tmp/etherpad.log /tmp/etherpad.err

26
bin/deb-src/DEBIAN/preinst Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# Installs node if it isn't already installed
#
# Don't steamroll over a previously installed node version
# TODO provide a local version of node?
VER="0.10.4"
ARCH="x86"
if [ `arch | grep 64` ]
then
ARCH="x64"
fi
# TODO test version
if [ ! -f /usr/local/bin/node ]
then
pushd /tmp
wget -c "http://nodejs.org/dist/v${VER}/node-v${VER}-linux-${ARCH}.tar.gz"
rm -rf /tmp/node-v${VER}-linux-${ARCH}
tar xf node-v${VER}-linux-${ARCH}.tar.gz -C /tmp/
cp -a /tmp/node-v${VER}-linux-${ARCH}/* /usr/local/
fi
# Create Etherpad user
adduser --system etherpad

4
bin/deb-src/DEBIAN/prerm Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# Stop the appserver:
service etherpad stop || true

View File

@ -0,0 +1,28 @@
description "etherpad"
start on started networking
stop on runlevel [!2345]
env EPHOME=/opt/etherpad
env EPLOGS=/var/log/etherpad
env EPUSER=etherpad
respawn
pre-start script
cd $EPHOME
mkdir $EPLOGS ||true
chown $EPUSER $EPLOGS ||true
chmod 0755 $EPLOGS ||true
chown -R $EPUSER $EPHOME/var ||true
$EPHOME/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; }
end script
script
cd $EPHOME/
exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- node node_modules/ep_etherpad-lite/node/server.js \
>> $EPLOGS/access.log \
2>> $EPLOGS/error.log
echo "Etherpad is running on http://localhost:9001 - To change settings edit /opt/etherpad/settings.json"
end script