You are not logged in.

#1 2006-12-05 15:46:37

djscholl
Member
From: Michigan, USA
Registered: 2006-05-24
Posts: 56

elog PKGBUILD for review (AUR)

I would appreciate feedback on this PKGBUILD before I submit it to the AUR. It includes boot and install scripts, new user and group ID's, and other things I have not done before. I used other Arch examples as models, but I might not have fully understood what I was trying to emulate.

elog uses the filesystem as a database to log/timestamp and serve back information submitted via http. I think it is a great program, carefully designed, stable, and actively supported. I would recommend it to anyone who needs to log/timestamp information and either: a) wants the information to remain accessible to scripts and not disappear into a large binary blob, or b) doesn't want to install and maintain a normal database.

# Contributor: David Scholl <djscholl>
pkgname=elog
pkgver=2.6.3.1
pkgrel=1
pkgdesc="Electronic logbook w/ attached file support, doesn't use a database."
url="http://midas.psi.ch/elog/"
license="GPL"
arch=(i686)
depends=('glibc')
install=elog.install
backup=etc/elog/elogd.cfg
source=(http://midas.psi.ch/elog/download/tar/elog-2.6.3-1.tar.gz elogd)
md5sums=('935f19692a05c2cb289d45bac14f1088' '746fc2d7ea204473ef95136b99fc7bb0')

build() {
  cd $startdir/src/$pkgname-2.6.3
  # make things more Arch-friendly
  sed -i '/^ELOGDIR/s/$(PREFIX)/elog//etc/elog/' Makefile
  sed -i '/^BINOWNER/s/bin/root/' Makefile
  sed -i '/^BINGROUP/s/bin/root/' Makefile
  # make and install
  make PREFIX=/usr || return 1 
  make PREFIX=/usr ROOT=$startdir/pkg install
  # substitute an Arch-friendly init script in place of the default
  cp ../../elogd $startdir/pkg/etc/rc.d/
  rm -Rf $startdir/pkg/etc/rc.d/init.d
  # move data to standard Arch locations
  mkdir -p $startdir/pkg/usr/share/elog
  mv $startdir/pkg/etc/elog/resources $startdir/pkg/usr/share/elog
  mv $startdir/pkg/etc/elog/scripts $startdir/pkg/usr/share/elog
  mv $startdir/pkg/etc/elog/themes $startdir/pkg/usr/share/elog
  mkdir -p $startdir/pkg/home/elog
  mv $startdir/pkg/etc/elog/logbooks $startdir/pkg/home/elog
  # tell elogd about the new locations
  sed -i '/[global]/s/$/nLogbook dir = /home/elog/logbooks/' 
    $startdir/pkg/etc/elog/elogd.cfg
  sed -i '/[global]/s/$/nResource dir = /usr/share/elog/' 
    $startdir/pkg/etc/elog/elogd.cfg
}

elog.install

# arg 1:  the new package version
post_install() {
  getent group elog  >/dev/null || usr/sbin/groupadd elog
  getent passwd elog >/dev/null || usr/sbin/useradd -c "elog Server" 
    -g elog -d /home/elog -s /bin/false elog
  usr/bin/passwd -l elog &>/dev/null
  chown -R elog:elog /etc/elog
  chown -R elog:elog /home/elog
  echo ">>> Add elogd to the DAEMONS array in /etc/rc.conf if you want"
  echo ">>> the server to start at system boot-up."
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
 post_install $1
}

# arg 1:  the old package version
pre_remove() {
  usr/sbin/userdel elog &>/dev/null
  usr/sbin/groupdel elog &>/dev/null
  echo ">>> Post-install logbook entries remain after package removal."
}

op=$1
shift

$op $*

elogd

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

PID=`pidof -o %PPID /usr/sbin/elogd`
case "$1" in
  start)
    stat_busy "Starting elogd"
    [ -z "$PID" ] && /usr/sbin/elogd -D -c /etc/elog/elogd.cfg 
                         > /dev/null 2>&1
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon elogd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping elogd"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon elogd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
exit 0

Offline

Board footer

Powered by FluxBB