diff --git a/ripe-dbase/rc.ripe-dbase b/ripe-dbase/rc.ripe-dbase new file mode 100644 index 0000000000..4576b85f58 --- /dev/null +++ b/ripe-dbase/rc.ripe-dbase @@ -0,0 +1,54 @@ +#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc +## +## rc.ripe-dbase -- Run-Commands +## + +%config + ripe_dbase_enable="$openpkg_rc_def" + +%common + ripe_dbase_pidfile="@l_prefix@/var/ripe-dbase/whois_rip.pid" + ripe_dbase_cfgfile="rip.config.sample" + ripe_dbase_basedir="@l_prefix@" + ripe_dbase_crashes=10 + ripe_dbase_notify="myaddress@mailserver.net" + ripe_dbase_gliblibdir="`@l_prefix@/bin/glib-config --prefix`/lib" + ripe_dbase_mysqllibdir="@l_prefix@/lib/mysql" + ripe_dbase_librarypath="$ripe_dbase_mysqllibdir:$ripe_dbase_gliblibdir" + ripe_dbase_signal () { + [ -f $ripe_dbase_pidfile ] && kill -$1 `cat $ripe_dbase_pidfile` + } + +%status -u @l_susr@ -o + ripe_dbase_usable="unknown" + ripe_dbase_active="no" + rcService ripe_dbase enable yes && \ + ripe_dbase_signal 0 && ripe_dbase_active="yes" + echo "ripe_dbase_enable=\"$ripe_dbase_enable\"" + echo "ripe_dbase_usable=\"$ripe_dbase_usable\"" + echo "ripe_dbase_active=\"$ripe_dbase_active\"" + +%start -u @l_susr@ + rcService ripe_dbase enable yes || exit 0 + rcService ripe_dbase active yes && exit 0 + @l_prefix@/bin/whoisd_start \ + --config=${ripe_dbase_cfgfile} --pid-file=${ripe_dbase_pidfile} \ + --basedir=${ripe_dbase_basedir} --crashes=${ripe_dbase_crashes} \ + --notify=${ripe_dbase_notify} --library_path=${ripe_dbase_librarypath} & + +%stop -u @l_susr@ + rcService ripe_dbase enable yes || exit 0 + rcService ripe_dbase active no && exit 0 + ripe_dbase_signal TERM + sleep 2 + +%restart -u @l_susr@ + rcService ripe_dbase enable yes || exit 0 + rcService ripe_dbase active no && exit 0 + rc ripe-dbase stop start + +%reload -u @l_susr@ + rcService ripe_dbase enable yes || exit 0 + rcService ripe_dbase active no && exit 0 + ripe_dbase_signal HUP + diff --git a/ripe-dbase/ripe-dbase-setup.sh b/ripe-dbase/ripe-dbase-setup.sh new file mode 100644 index 0000000000..665d3690db --- /dev/null +++ b/ripe-dbase/ripe-dbase-setup.sh @@ -0,0 +1,25 @@ +#!/bin/sh +## +## ripedb-setup +## + +# determine MySQL root password +password=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\ + sed -e 's;^password[^=]*= *;;' -e 's; *$;;'` + +# create the MySQL database for RIPE +# FIXME: possible reuse scripts from original distribution +#@l_prefix@/libexec/ripe-dbase/make_db +#@l_prefix@/libexec/ripe-dbase/make_mysql_user +@l_prefix@/bin/mysqladmin --user=root --password=$password create ripe + +# FIXME: probably suck RIPE objects vie FTP or their special protocol here +## create the default RIPE database schema +#@l_prefix@/bin/mysql --user=root --password=$password ripe <@l_prefix@/libexec/ripe-dbase/SQL/create.tables.sql + +# create a MySQL username/password for RIPE +@l_prefix@/bin/mysql --user=root --password=$password mysql </dev/null 2>&1 || true + %{l_shtool} install -c -m 755 %{l_value -s -a} \ + %{SOURCE rc.ripe-dbase} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ + %{l_shtool} install -c -m 755 %{l_value -s -a} \ + %{SOURCE ripe-dbase-setup.sh} \ + $RPM_BUILD_ROOT%{l_prefix}/sbin/ripe-dbase-setup %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} %files -f files @@ -97,3 +113,30 @@ AutoReqProv: no %clean rm -rf $RPM_BUILD_ROOT +%post + if [ $1 -eq 1 ]; then + # display final hints on initial installation + ( echo "1. To complete this installation of the RIPE Whois server," + echo " please start MySQL and initialize the database like this:" + echo " \$ $RPM_INSTALL_PREFIX/etc/rc mysql start" + echo " \$ $RPM_INSTALL_PREFIX/sbin/ripe-dbase-setup" + echo "" + echo "2. After initializing the database, start the server by running" + echo " \$ $RPM_INSTALL_PREFIX/etc/rc ripe-dbase start" + ) | %{l_rpmtool} msg -b -t notice + fi + if [ $1 -eq 2 ]; then + # after upgrade, restart service + eval `%{l_rc} ripe-dbase status 2>/dev/null` + [ ".$ripe-dbase_active" = .yes ] && %{l_rc} ripe-dbase restart + fi + exit 0 + +%preun + if [ $1 -eq 0 ]; then + # before erase, stop service and remove log files + %{l_rc} ripe-dbase stop 2>/dev/null + rm -f $RPM_INSTALL_PREFIX/var/ripe-dbase/log/* >/dev/null 2>&1 || true + fi + exit 0 +