Operating System - Linux
1748017 Members
3524 Online
108757 Solutions
New Discussion юеВ

Re: Own-build rpm runs the uninstall script after installation

 
Michael Williams_6
Trusted Contributor

Own-build rpm runs the uninstall script after installation

Help!!

I have a simple monitoring tool I've just converted from SCO to Linux and am trying to wrap this in an RPM, after spending many hours trying to work out why the RPM was not adding the cronjob or installing the service, I find it's actually running the uninstall script after installation, which kind of seems pointless, when installing, it still tries to run the uninstall script too, but fails as the cronjobs no longer exist for the user!

The spec file is below, I run an rpm -ba sysinf.spec to create the rpm file.

Summary: Provides automated system monitoring
Name: sysinf
Version: 1.3
Release: 18
Copyright: Alchemetrics Ltd.
Group: Alchemetrics/Infrastructure

%description
Alchemetrics tool to provide automated monitoring on all systems. Works by uploading data to a MySQL database.

%preun
/sbin/insserv -r /etc/init.d/sysinf
/usr/sbin/crontab -u sysinf -r

%post
/sbin/insserv -d /etc/init.d/sysinf
/usr/bin/crontab -u sysinf -r
/usr/bin/crontab -u sysinf - <*/5 * * * * /usr/local/bin/sysinf sysinf
END

%files
/usr/local/bin/sysinf
/etc/init.d/sysinf
3 REPLIES 3
Stuart Browne
Honored Contributor

Re: Own-build rpm runs the uninstall script after installation

In your %post, you have:

%post
/sbin/insserv -d /etc/init.d/sysinf
/usr/bin/crontab -u sysinf -r
/usr/bin/crontab -u sysinf - <*/5 * * * * /usr/local/bin/sysinf sysinf
END

Ok. You're removing the crontab for user 'sysinf', then using a here-document to try to create a new one.

Try twho things.

one: remove that 'crontab -u sysinf -r' from here, add a crontab manually, and reinstall the package.

two: use a simple 'echo */5 * * * * /usr/local/bin/sysinf sysinf' | crontab -e -u sysinf' instead.

See if either of these resolve you issue.
One long-haired git at your service...
Michael Williams_6
Trusted Contributor

Re: Own-build rpm runs the uninstall script after installation

Well, that was even worse:

Vim: Error reading input, exiting... 0,0-1 All
^[[>0;136;0cVim: Finished.
/usr/bin/crontab: "/usr/bin/vi" exited with status 1
execution of sysinf-1.3-19 script failed, exit status 1

Which makes sense, crontab -e won't work as there's no terminal assigned to input!

However, after putting the modification back again, it's now working as I'd expect...

How very strange, I must have made a silly typo or something!
Michael Williams_6
Trusted Contributor

Re: Own-build rpm runs the uninstall script after installation

Strangely by re-writing out the contents of the spec file I got it working, thanks for your help though!

I must have had a dodgy character in there somewhere!