[tac_plus] Re: rpm spec for your version of tacacs

Guy Morrell guy.morrell at oucs.ox.ac.uk
Mon Nov 24 10:46:43 UTC 2008


On 21 Nov 2008, at 20:00, tac_plus-request at shrubbery.net wrote:
>
> Today's Topics:
>
>   1.  rpm spec for your version of tacacs (pritam)
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 21 Nov 2008 13:45:30 +0545
> From: pritam <pritam at subisu.net.np>
> Subject: [tac_plus]  rpm spec for your version of tacacs
> To: tac_plus at shrubbery.net
> Message-ID: <49266A9E.9000704 at subisu.net.np>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi,
>
> I am newbie in making rpm spec file.
>
> How can I get the spec file to make the rpm of yours version of  
> tacacs.
>
> Regards,
>
> Pritam
>

Hi Pritam,

Here is the one I used; it's based on another build by Devrim SERAL <devrim at gazi.edu.tr 
 >. I've included the config files below. As I mention in the  
changelog, I'm no packaging expert. This build suits our purposes, I  
hope it helps. If anyone on the list has any improvements to offer I'd  
welcome them.

#This is tac_plus rpm spec file

%define name    tac_plus
%define ver     F4.0.4
%define rel     15
%define prefix  /usr

Summary:        Cisco Tacacs+ Daemon (Shrubbery version)
Name:           %name
Version:        %ver
Release:        %rel
License:        Free Software
Group:          Networking/Daemons
Source0:        ftp://ftp.shrubbery.net/pub/tac_plus/tacacs+-F4.0.4.15.tar.gz
Source1:        tac_plus.cfg
Source2:        tac_plus.init
Source3:        tac_plus.rotate
Url:            http://www.shrubbery.net/tac_plus/
Packager:       Guy Morrell <guy.morrell at oucs.ox.ac.uk>
BuildRoot:      /tmp/%{name}-%{ver}-%{rel}

%description
TACACS+ daemon using with Cisco's NASs (Or other vendors) for AAA  
(Authentication , Authorization and Accounting) propose.

%prep
%setup -n tacacs+-%{ver}.%{rel}

%build
./configure --with-prefix=%{prefix} --without-libwrap

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall

# these aren't created by default
mkdir -p $RPM_BUILD_ROOT/etc/tacacs
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
mkdir -p $RPM_BUILD_ROOT/etc/init.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc0.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc1.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc2.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc3.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc4.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc5.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc6.d

# by default, tac_plus doesn't do any of this so let's make life easy  
for ourselves
# config
install -c -m 0600 %SOURCE1 ${RPM_BUILD_ROOT}/etc/tacacs/
# start / stop
install -c -m 0755 %SOURCE2 ${RPM_BUILD_ROOT}/etc/rc.d/init.d/tac_plus
# log rotation
install -b -c -m 0644 %SOURCE3 ${RPM_BUILD_ROOT}/etc/logrotate.d/ 
tac_plus

# set up the simlinks
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc0.d/ 
K20tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc1.d/ 
K20tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc2.d/ 
S80tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc3.d/ 
S80tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc4.d/ 
K20tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc5.d/ 
S80tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc6.d/ 
K20tac_plus

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-, root, root)
%dir                    /etc/tacacs
%attr(750,root,root)    %{prefix}/bin/tac_pwd
%attr(750,root,root)    %{prefix}/bin/tac_plus
%doc                    %{prefix}/share/man/man3/regexp.3.gz
%doc                    %{prefix}/share/man/man5/tac_plus.conf.5.gz
%doc                    %{prefix}/share/man/man8/tac_plus.8.gz
%doc                    %{prefix}/share/man/man8/tac_pwd.8.gz
%doc                    %{prefix}/share/tacacs+/users_guide
%dir                    %{prefix}/share/tacacs+
                         %{prefix}/share/tacacs+/tac_convert
                         /etc/logrotate.d/tac_plus
                         /etc/tacacs/tac_plus.cfg
                         /etc/rc.d/init.d/tac_plus
                         /etc/rc.d/rc0.d/K20tac_plus
                         /etc/rc.d/rc1.d/K20tac_plus
                         /etc/rc.d/rc2.d/S80tac_plus
                         /etc/rc.d/rc3.d/S80tac_plus
                         /etc/rc.d/rc4.d/K20tac_plus
                         /etc/rc.d/rc5.d/S80tac_plus
                         /etc/rc.d/rc6.d/K20tac_plus

%changelog
* Wed Nov 12 2008 Guy Morrell <guy.morrell at oucs.ox.ac.uk>
- Basic package.
- This is my first attempt at packaging an rpm, there may well be a  
better way to do this but the above works.
"tac_plus.spec" 95L, 3159C written
guym at rhodesia:/usr/src/redhat/SPECS$ cat tac_plus.spec
#This is tac_plus rpm spec file

%define name	tac_plus
%define ver	F4.0.4
%define rel	15
%define prefix	/usr

Summary:	Cisco Tacacs+ Daemon (Shrubbery version)
Name:		%name
Version:	%ver
Release:	%rel
License: 	Free Software
Group:		Networking/Daemons
Source0:	ftp://ftp.shrubbery.net/pub/tac_plus/tacacs+-F4.0.4.15.tar.gz	
Source1:	tac_plus.cfg
Source2:	tac_plus.init
Source3:	tac_plus.rotate
Url:		http://www.shrubbery.net/tac_plus/
Packager:	Guy Morrell <guy.morrell at oucs.ox.ac.uk>
BuildRoot:	/tmp/%{name}-%{ver}-%{rel}

%description
TACACS+ daemon using with Cisco's NASs (Or other vendors) for AAA  
(Authentication , Authorization and Accounting) propose.

%prep
%setup -n tacacs+-%{ver}.%{rel}

%build
./configure --with-prefix=%{prefix} --without-libwrap

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall

# these aren't created by default
mkdir -p $RPM_BUILD_ROOT/etc/tacacs
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
mkdir -p $RPM_BUILD_ROOT/etc/init.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc0.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc1.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc2.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc3.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc4.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc5.d
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/rc6.d

# by default, tac_plus doesn't do any of this so let's make life easy  
for ourselves
# config
install -c -m 0600 %SOURCE1 ${RPM_BUILD_ROOT}/etc/tacacs/
# start / stop
install -c -m 0755 %SOURCE2 ${RPM_BUILD_ROOT}/etc/rc.d/init.d/tac_plus
# log rotation
install -b -c -m 0644 %SOURCE3 ${RPM_BUILD_ROOT}/etc/logrotate.d/ 
tac_plus

# set up the simlinks
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc0.d/ 
K20tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc1.d/ 
K20tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc2.d/ 
S80tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc3.d/ 
S80tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc4.d/ 
K20tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc5.d/ 
S80tac_plus
ln -s /etc/rc.d/init.d/tac_plus $RPM_BUILD_ROOT/etc/rc.d/rc6.d/ 
K20tac_plus

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-, root, root)
%dir 			/etc/tacacs
%attr(750,root,root)	%{prefix}/bin/tac_pwd
%attr(750,root,root)	%{prefix}/bin/tac_plus
%doc 			%{prefix}/share/man/man3/regexp.3.gz
%doc			%{prefix}/share/man/man5/tac_plus.conf.5.gz
%doc			%{prefix}/share/man/man8/tac_plus.8.gz
%doc			%{prefix}/share/man/man8/tac_pwd.8.gz
%doc			%{prefix}/share/tacacs+/users_guide
%dir 			%{prefix}/share/tacacs+
			%{prefix}/share/tacacs+/tac_convert
			/etc/logrotate.d/tac_plus
			/etc/tacacs/tac_plus.cfg
			/etc/rc.d/init.d/tac_plus
			/etc/rc.d/rc0.d/K20tac_plus
			/etc/rc.d/rc1.d/K20tac_plus
			/etc/rc.d/rc2.d/S80tac_plus
			/etc/rc.d/rc3.d/S80tac_plus
			/etc/rc.d/rc4.d/K20tac_plus
			/etc/rc.d/rc5.d/S80tac_plus
			/etc/rc.d/rc6.d/K20tac_plus

%changelog
* Wed Nov 12 2008 Guy Morrell <guy.morrell at oucs.ox.ac.uk>
- Basic package.
- This is my first attempt at packaging an rpm, there may well be a  
better way to do this but the above works.

###################
# tac_plus.init
###################

#!/bin/sh
#
# tac_plus        This shell script takes care of starting and stopping
#		         the Shrubbery tac_plus (TACACS+ daemon).
#
# chkconfig: 235 80 20
# description: tac_plus is TACACS+ daemon.
# processname: tac_plus
# config: /etc/tacacs/tac_plus.cfg
# pidfile: /var/run/tac_plus.pid
# debug : 0

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# Some config parameters
#For config file
tacacs_config="/etc/tacacs/tac_plus.cfg"
#For debug option
debug=0

[ -f /usr/bin/tac_plus ] || exit 0

[ -f $tacacs_config ] || exit 0


# See how we were called.
case "$1" in
   start)
         # Start daemon.
	if [ $debug -gt 0 ]
         then
         echo -n "Starting TACACS+ with debug level $debug : "
	daemon tac_plus -C $tacacs_config -d $debug
	else
	echo -n "Starting TACACS+ :"
	daemon tac_plus -C $tacacs_config
	fi
	echo
         touch /var/lock/subsys/tac_plus
         ;;
   stop)
         # Stop daemons.
         echo -n "Shutting down TACACS+: "
         killproc tac_plus
         rm -f /var/lock/subsys/tac_plus
         echo
         ;;
   status)
	status tac_plus	
	exit $?
	;;
   restart)
	$0 stop
	$0 start
	;;

   reload)
	echo "TACACS+ now reloading......"
	kill -SIGUSR1 `cat /var/run/tac_plus.pid`
	exit $?
	;;
   test)
	echo "TACACS+ config being testing..."
	/usr/sbin/tac_plus -P -C $tacacs_config
	;;
   *)
         echo "Usage: tac_plus {start|stop|status|restart|reload|test}"
         exit 1
esac

exit 0

###################
# tac_plus.rotate
###################

# This is tac_plus logrotate config file
# For more info please refer logrotate man page
/var/log/tac_plus.log {
	size 3M
	missingok
	errors root at localhost
	compress
	postrotate
		/usr/bin/killall -HUP tac_plus 2> /dev/null || true
	endscript
}

/var/log/tac_acc.log {
         size 5M
	missingok
         errors root at localhost
	nocompress	
	postrotate
                 /usr/bin/killall -HUP tac_plus 2> /dev/null || true
         endscript
}


Cheers,

Guy

--
Guy Morrell
Network and Telecommunications Group
Oxford University Computing Services



More information about the tac_plus mailing list