Browse Source

add run commands, add database setup script, improve description, other text, and install logic, and add post and pre install logic

master
Michael Schloh von Bennewitz 22 years ago committed by Ralf S. Engelschall
parent
commit
d433ffec20
  1. 54
      ripe-dbase/rc.ripe-dbase
  2. 25
      ripe-dbase/ripe-dbase-setup.sh
  3. 49
      ripe-dbase/ripe-dbase.spec

54
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

25
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 <<EOF
GRANT ALL ON ripe.* TO ripe@localhost IDENTIFIED BY 'ripe';
FLUSH PRIVILEGES;
EOF

49
ripe-dbase/ripe-dbase.spec

@ -23,8 +23,8 @@
## SUCH DAMAGE.
##
# FIXME: rse: run-command script has to be added
# FIXME: rse: mysql database initialization has to be added via ripe-dbase-setup similar to "rt-setup" and "cacti-setup"
# FIXME: rse: run-command script must be debugged
# FIXME: rse: mysql database initialization must be debugged
# FIXME: rse: whois database data initial loading from RIPE NCC ftp service snapshots?
# FIXME: rse: whois database data periodic updating from RIPE NCC
@ -42,6 +42,8 @@ Release: 20031205
# list of sources
Source0: ftp://ftp.ripe.net/ripe/dbase/software/ripe-dbase-%{version}.tar.gz
Source1: ripe-dbase-setup.sh
Source2: rc.ripe-dbase
Patch0: ripe-dbase.patch
# build information
@ -57,7 +59,10 @@ AutoReq: no
AutoReqProv: no
%description
RIPE-dbase is the official RIPE NCC's WHOIS Database Server software.
RIPE-dbase is the official RIPE NCC's Whois Database Server software.
The RIPE Whois Database contains information about IP address space
allocations and assignments, routing policies, and reverse delegations
in the RIPE NCC Service region.
%prep
%setup -q
@ -85,11 +90,22 @@ AutoReqProv: no
%install
rm -rf $RPM_BUILD_ROOT
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/sbin \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
%{l_shtool} subst \
-e "s;^\\([^=]* *= *\\)%{l_prefix};\\1$RPM_BUILD_ROOT%{l_prefix};" \
Makefile
%{l_shtool} subst \
-e 's;^\(err_log=.*/\)bin\(/.*\);\1var/ripe-dbase/log\2;' \
utils/whoisd_start
%{l_make} %{l_mflags} install INSTALL="%{l_shtool} install -c"
strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/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

Loading…
Cancel
Save