From e2cb402704cb46e834f373fd2c0d0bbc3e659dff Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sat, 29 Dec 2012 10:12:05 -0600 Subject: [PATCH] * VRFS-188 in progress --- build | 6 ++++++ script/package/post-install.sh | 11 ++++++++++ script/package/post-uninstall.sh | 11 ++++++++++ script/package/pre-install.sh | 36 ++++++++++++++++++++++++++++++++ script/package/pre-uninstall.sh | 0 5 files changed, 64 insertions(+) create mode 100755 script/package/post-install.sh create mode 100755 script/package/post-uninstall.sh create mode 100755 script/package/pre-install.sh create mode 100755 script/package/pre-uninstall.sh diff --git a/build b/build index afe1877f1..44d4406b0 100755 --- a/build +++ b/build @@ -44,7 +44,13 @@ else exit 1 fi +if [ -n "$PACKAGE" ]; then + # cache all gems local, and tell bundle to use local gems only + DIR=. + bundle install --path vendor/bundle --local + bundle exec fpm -s dir -t deb -n "jam-web" -v "0.1.$BUILD_NUMBER" . --post-install $DIR/script/package/post-install.sh --pre-install $DIR/script/package/pre-install.sh --pre-uninstall $DIR/script/package/pre-uninstall.sh --post-uninstall $DIR/script/package/post-install.sh +fi echo "build complete" diff --git a/script/package/post-install.sh b/script/package/post-install.sh new file mode 100755 index 000000000..75cb8376d --- /dev/null +++ b/script/package/post-install.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -eu + +NAME="jam-web" + +USER="$NAME" +GROUP="$NAME" + +chown $USER:$GROUP /var/lib/$NAME +chown $USER:$GROUP /var/log/$NAME diff --git a/script/package/post-uninstall.sh b/script/package/post-uninstall.sh new file mode 100755 index 000000000..30ad27c89 --- /dev/null +++ b/script/package/post-uninstall.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +NAME="jam-web" + +if [ "$1" = "purge" ] +then + rm -rf /var/lib/$NAME + userdel $NAME +fi diff --git a/script/package/pre-install.sh b/script/package/pre-install.sh new file mode 100755 index 000000000..a776110ea --- /dev/null +++ b/script/package/pre-install.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -eu + +NAME="jam-web" + +HOME="/var/lib/$NAME" +USER="$NAME" +GROUP="$NAME" + +# if NIS is used, then errors can occur but be non-fatal +if which ypwhich >/dev/null 2>&1 && ypwhich >/dev/null 2>&1 +then + set +e +fi + +if ! getent group $GROUP >/dev/null +then + addgroup --system $GROUP >/dev/null +fi + +# creating user if it isn't already there +if ! getent passwd $USER >/dev/null +then + adduser \ + --system \ + --home $HOME \ + --shell /bin/false \ + --disabled-login \ + --ingroup $GROUP \ + --gecos "$USER server" \ + $USER >/dev/null +fi + +# NISno longer a possible problem; stop ignoring errors +set -e diff --git a/script/package/pre-uninstall.sh b/script/package/pre-uninstall.sh new file mode 100755 index 000000000..e69de29bb