Shell script to generate Confluence debian package.
This commit is contained in:
parent
a6419b6328
commit
5b30e592c2
|
@ -0,0 +1,2 @@
|
|||
*.gz
|
||||
debian
|
|
@ -0,0 +1,82 @@
|
|||
#!/bin/bash -ex
|
||||
# creates a Confluence debian package
|
||||
# based on http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/
|
||||
|
||||
# Confluence version to package
|
||||
ver=4.2.4
|
||||
|
||||
# debian revision
|
||||
rev=0
|
||||
|
||||
wget -N http://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-${ver}.tar.gz
|
||||
|
||||
base=$PWD
|
||||
|
||||
rm -rf debian || true
|
||||
mkdir debian
|
||||
cd debian
|
||||
root=$PWD
|
||||
|
||||
# control files and metadata
|
||||
mkdir DEBIAN
|
||||
cat > DEBIAN/control << EOF
|
||||
Package: atlassian-confluence
|
||||
Version: $ver-$rev
|
||||
Section: base
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: coreutils, openjdk-6-jre
|
||||
Maintainer: Kohsuke Kawaguchi <kk@kohsuke.org>
|
||||
Description: Atlassian Confluence
|
||||
EOF
|
||||
cp $base/postinst DEBIAN/postinst
|
||||
|
||||
|
||||
# main binary
|
||||
mkdir -p srv/wiki
|
||||
pushd srv/wiki
|
||||
tar xzf $base/atlassian-confluence-$ver.tar.gz
|
||||
# symlink to the current version
|
||||
ln -s atlassian-confluence-$ver current
|
||||
popd
|
||||
|
||||
# init script
|
||||
mkdir -p etc/init.d
|
||||
pushd etc/init.d
|
||||
cp $base/confluence.init confluence
|
||||
popd
|
||||
|
||||
# default settings
|
||||
mkdir -p etc/default
|
||||
pushd etc/default
|
||||
cp $base/confluence.default confluence
|
||||
popd
|
||||
echo /etc/default/confluence > DEBIAN/conffiles
|
||||
|
||||
# move $HOME/conf to /etc
|
||||
mkdir -p etc/confluence
|
||||
pushd srv/wiki/current
|
||||
mv conf $root/etc/confluence/conf
|
||||
ln -s ../../../etc/confluence/conf .
|
||||
popd
|
||||
|
||||
# tell dpkg that everything in /etc/confluence is configuration files
|
||||
(find etc/confluence -type f) | sed -e 's#^#/#' >> DEBIAN/confflies
|
||||
|
||||
# ditto for files in $HOME/confluence/WEB-INF/classes
|
||||
# TODO: I originally tried to move them into /etc/confluence and symlinks, but JVM didn't like that
|
||||
pushd srv/wiki/current/confluence/WEB-INF/classes
|
||||
files="$(ls *.properties *.xml)"
|
||||
for f in $files; do
|
||||
echo /srv/wiki/atlassian-confluence-$ver/confluence/WEB-INF/classes/$f >> $root/DEBIAN/conffiles
|
||||
done
|
||||
popd
|
||||
|
||||
pushd etc/confluence
|
||||
ln -s ../../srv/wiki/current/confluence/WEB-INF/classes/ WEB-INF-classes
|
||||
popd
|
||||
|
||||
# build a package
|
||||
cd ..
|
||||
fakeroot dpkg-deb --build debian apt-repo/atlassian-confluence_${ver}-${rev}_all.deb
|
||||
cp apt-repo/*.deb ../modules/confluence/files
|
|
@ -0,0 +1,3 @@
|
|||
CONFLUENCE_USER=wiki
|
||||
CONFLUENCE_GROUP=wiki
|
||||
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
# /etc/init.d/confluence
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: confluence
|
||||
# Required-Start: $remote_fs $syslog $network
|
||||
# Required-Stop: $remote_fs $syslog $network
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start Confluence at boot time
|
||||
# Description: Controls Confluence
|
||||
### END INIT INFO
|
||||
|
||||
# Define some variables
|
||||
# Name of app ( JIRA, Confluence, etc )
|
||||
APP=confluence
|
||||
|
||||
[ -r /etc/default/confluence ] && . /etc/default/confluence
|
||||
|
||||
# Location of application's bin directory
|
||||
BASE=/srv/wiki/current
|
||||
|
||||
case "$1" in
|
||||
# Start command
|
||||
start)
|
||||
echo "Starting $APP"
|
||||
/bin/su -m $CONFLUENCE_USER -c "cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null"
|
||||
;;
|
||||
# Stop command
|
||||
stop)
|
||||
echo "Stopping $APP"
|
||||
/bin/su -m $CONFLUENCE_USER -c "$BASE/bin/shutdown.sh &> /dev/null"
|
||||
echo "$APP stopped successfully"
|
||||
;;
|
||||
# Restart command
|
||||
restart)
|
||||
$0 stop
|
||||
sleep 5
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/$APP {start|restart|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash -e
|
||||
# postinst script for confluence
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <postinst> `configure' <most-recently-configured-version>
|
||||
# * <old-postinst> `abort-upgrade' <new version>
|
||||
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
||||
# <new-version>
|
||||
# * <postinst> `abort-remove'
|
||||
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
||||
# <failed-install-package> <version> `removing'
|
||||
# <conflicting-package> <version>
|
||||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
|
||||
[ -r /etc/default/confluence ] && . /etc/default/confluence
|
||||
: ${CONFLUENCE_USER:=wiki}
|
||||
: ${CONFLUENCE_GROUP:=wiki}
|
||||
|
||||
grep \^${CONFLUENCE_GROUP}: /etc/group > /dev/null || groupadd $CONFLUENCE_GROUP
|
||||
|
||||
# Create confluence user if it doesn't exist.
|
||||
if ! id $CONFLUENCE_USER > /dev/null 2>&1 ; then
|
||||
adduser --system --home /srv/wiki --no-create-home \
|
||||
--ingroup $CONFLUENCE_GROUP --disabled-password --shell /bin/bash \
|
||||
$CONFLUENCE_USER
|
||||
fi
|
||||
|
||||
# directories needed for jenkins
|
||||
# we don't do -R because it can take a long time on big installation
|
||||
chown -R $CONFLUENCE_USER:$CONFLUENCE_GROUP /srv/wiki
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -x "/etc/init.d/confluence" ]; then
|
||||
update-rc.d confluence defaults >/dev/null
|
||||
invoke-rc.d confluence start || exit $?
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
|
Loading…
Reference in New Issue