#!/usr/local/bin/perl # Build an RPM package of Webmin if (-d "$ENV{'HOME'}/redhat") { $base_dir = "$ENV{'HOME'}/redhat"; } elsif (-d "$ENV{'HOME'}/rpmbuild") { $base_dir = "$ENV{'HOME'}/rpmbuild"; } else { $base_dir = "/usr/src/redhat"; } $spec_dir = "$base_dir/SPECS"; $source_dir = "$base_dir/SOURCES"; $rpms_dir = "$base_dir/RPMS/noarch"; $srpms_dir = "$base_dir/SRPMS"; $< && die "makerpm.pl must be run as root"; if ($ARGV[0] eq "--nosign" || $ARGV[0] eq "-nosign") { $nosign = 1; shift(@ARGV); } $ver = $ARGV[0] || die "usage: makerpm.pl [release]"; $rel = $ARGV[1] || "1"; $oscheck = <) { chop; if (/^([^\t]+)\t+([^\t]+)\t+([^\t]+)\t+([^\t]+)\t*(.*)$/ && $5) { $if = $count++ == 0 ? "if" : "elsif"; $oscheck .= "$if ($5) {\n". " print \"oscheck='$1'\\n\";\n". " }\n"; } } close(OS); $oscheck =~ s/\\/\\\\/g; $oscheck =~ s/`/\\`/g; $oscheck =~ s/\$/\\\$/g; open(TEMP, "maketemp.pl"); while() { $maketemp .= $_; } close(TEMP); $maketemp =~ s/\\/\\\\/g; $maketemp =~ s/`/\\`/g; $maketemp =~ s/\$/\\\$/g; system("cp tarballs/webmin-$ver.tar.gz $source_dir"); open(SPEC, ">$spec_dir/webmin-$ver.spec"); print SPEC <%{buildroot}/usr/libexec/webmin/install-type %clean #%{rmDESTDIR} [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files %defattr(-,root,root) /usr/libexec/webmin %config /etc/sysconfig/daemons/webmin /etc/init.d/webmin /etc/rc.d/rc2.d/S99webmin /etc/rc.d/rc3.d/S99webmin /etc/rc.d/rc5.d/S99webmin /etc/rc.d/rc0.d/K10webmin /etc/rc.d/rc1.d/K10webmin /etc/rc.d/rc6.d/K10webmin %config /etc/pam.d/webmin %pre perl <$tempdir/\$\$.check </dev/null` 2>/dev/null if [ "\$?" = 0 ]; then startafter=1 fi /etc/init.d/webmin stop >/dev/null 2>&1 \$tempdir/webmin-setup.out 2>&1 chmod 600 \$tempdir/webmin-setup.out rm -f /var/lock/subsys/webmin if [ "\$inetd" != "1" -a "\$startafter" = "1" ]; then /etc/init.d/webmin stop >/dev/null 2>&1 /dev/null 2>&1 /etc/webmin/uninstall.sh </dev/null 2>/dev/null if [ "\$?" = "0" ]; then sslmode=1 fi fi musthost=`grep musthost= /etc/webmin/miniserv.conf | sed -e 's/musthost=//'` if [ "$musthost" != "" ]; then host=$musthost fi if [ "\$1" == 1 ]; then if [ "\$sslmode" = "1" ]; then echo "Webmin install complete. You can now login to https://\$host:\$port/" else echo "Webmin install complete. You can now login to http://\$host:\$port/" fi echo "as root with your root password." fi /bin/true %preun if [ "\$1" = 0 ]; then grep root=/usr/libexec/webmin /etc/webmin/miniserv.conf >/dev/null 2>&1 if [ "\$?" = 0 ]; then # RPM is being removed, and no new version of webmin # has taken it's place. Run uninstalls and stop the server echo "Running uninstall scripts .." (cd /usr/libexec/webmin ; WEBMIN_CONFIG=/etc/webmin WEBMIN_VAR=/var/webmin LANG= /usr/libexec/webmin/run-uninstalls.pl) /etc/init.d/webmin stop >/dev/null 2>&1 /dev/null 2>&1 /dev/null 2>&1 if [ "\$?" = 0 ]; then # RPM is being removed, and no new version of webmin # has taken it's place. Rename away the /etc/webmin directory rm -rf /etc/webmin.rpmsave mv /etc/webmin /etc/webmin.rpmsave rm -rf /var/webmin fi fi /bin/true %triggerpostun -- webmin if [ ! -d /var/webmin -a "\$1" = 2 ]; then echo Re-creating /var/webmin directory mkdir /var/webmin fi if [ ! -r /etc/webmin/miniserv.conf -a -d /etc/.webmin-backup -a "\$1" = 2 ]; then echo Recovering /etc/webmin directory rm -rf /etc/.webmin-broken mv /etc/webmin /etc/.webmin-broken mv /etc/.webmin-backup /etc/webmin /etc/init.d/webmin stop >/dev/null 2>&1 /dev/null 2>&1