2 # Build an RPM package of Webmin
4 if (-r "/usr/src/OpenLinux") {
5 $base_dir = "/usr/src/OpenLinux";
8 $base_dir = "/usr/src/redhat";
10 $spec_dir = "$base_dir/SPECS";
11 $source_dir = "$base_dir/SOURCES";
12 $rpms_dir = "$base_dir/RPMS/noarch";
13 $srpms_dir = "$base_dir/SRPMS";
15 $< && die "makerpm.pl must be run as root";
17 if ($ARGV[0] eq "--nosign" || $ARGV[0] eq "-nosign") {
21 $ver = $ARGV[0] || die "usage: makerpm.pl <version> [release]";
22 $rel = $ARGV[1] || "1";
25 if (-r "/etc/.issue") {
26 \$etc_issue = `cat /etc/.issue`;
28 elsif (-r "/etc/issue") {
29 \$etc_issue = `cat /etc/issue`;
33 open(OS, "os_list.txt");
36 if (/^([^\t]+)\t+([^\t]+)\t+([^\t]+)\t+([^\t]+)\t*(.*)$/ && $5) {
37 $if = $count++ == 0 ? "if" : "elsif";
38 $oscheck .= "$if ($5) {\n".
39 " print \"oscheck='$1'\\n\";\n".
44 $oscheck =~ s/\\/\\\\/g;
45 $oscheck =~ s/`/\\`/g;
46 $oscheck =~ s/\$/\\\$/g;
48 open(TEMP, "maketemp.pl");
53 $maketemp =~ s/\\/\\\\/g;
54 $maketemp =~ s/`/\\`/g;
55 $maketemp =~ s/\$/\\\$/g;
57 system("cp tarballs/webmin-$ver.tar.gz $source_dir");
58 open(SPEC, ">$spec_dir/webmin-$ver.spec");
60 #%define BuildRoot /tmp/%{name}-%{version}
61 %define __spec_install_post %{nil}
63 Summary: A web-based administration interface for Unix systems.
67 Provides: %{name}-%{version}
68 PreReq: /bin/sh /usr/bin/perl /bin/rm
69 Requires: /bin/sh /usr/bin/perl /bin/rm
73 Source: http://www.webmin.com/download/%{name}-%{version}.tar.gz
75 BuildRoot: /tmp/%{name}-%{version}
76 BuildArchitectures: noarch
78 A web-based administration interface for Unix systems. Using Webmin you can
79 configure DNS, Samba, NFS, local/remote filesystems and more using your
82 After installation, enter the URL http://localhost:10000/ into your
83 browser and login as root with your root password.
89 (find . -name '*.cgi' ; find . -name '*.pl') | perl perlpath.pl /usr/bin/perl -
90 rm -f mount/freebsd-mounts*
91 rm -f mount/openbsd-mounts*
92 rm -f mount/macos-mounts*
93 rm -f webmin-gentoo-init
94 rm -rf format bsdexports hpuxexports sgiexports zones rbac
95 rm -rf acl/Authen-SolarisRBAC-0.1*
99 mkdir -p %{buildroot}/usr/libexec/webmin
100 mkdir -p %{buildroot}/etc/sysconfig/daemons
101 mkdir -p %{buildroot}/etc/rc.d/{rc0.d,rc1.d,rc2.d,rc3.d,rc5.d,rc6.d}
102 mkdir -p %{buildroot}/etc/init.d
103 mkdir -p %{buildroot}/etc/pam.d
104 cp -rp * %{buildroot}/usr/libexec/webmin
105 cp webmin-daemon %{buildroot}/etc/sysconfig/daemons/webmin
106 cp webmin-init %{buildroot}/etc/init.d/webmin
107 cp webmin-pam %{buildroot}/etc/pam.d/webmin
108 ln -s /etc/init.d/webmin %{buildroot}/etc/rc.d/rc2.d/S99webmin
109 ln -s /etc/init.d/webmin %{buildroot}/etc/rc.d/rc3.d/S99webmin
110 ln -s /etc/init.d/webmin %{buildroot}/etc/rc.d/rc5.d/S99webmin
111 ln -s /etc/init.d/webmin %{buildroot}/etc/rc.d/rc0.d/K10webmin
112 ln -s /etc/init.d/webmin %{buildroot}/etc/rc.d/rc1.d/K10webmin
113 ln -s /etc/init.d/webmin %{buildroot}/etc/rc.d/rc6.d/K10webmin
114 echo rpm >%{buildroot}/usr/libexec/webmin/install-type
118 [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
121 %defattr(-,root,root)
123 %config /etc/sysconfig/daemons/webmin
125 /etc/rc.d/rc2.d/S99webmin
126 /etc/rc.d/rc3.d/S99webmin
127 /etc/rc.d/rc5.d/S99webmin
128 /etc/rc.d/rc0.d/K10webmin
129 /etc/rc.d/rc1.d/K10webmin
130 /etc/rc.d/rc6.d/K10webmin
131 %config /etc/pam.d/webmin
137 if [ "\$?" != "0" ]; then
138 echo "Failed to create or check temp files directory /tmp/.webmin"
141 if [ "\$tempdir" = "" ]; then
144 perl >$tempdir/\$\$.check <<EOD;
147 . $tempdir/\$\$.check
148 rm -f $tempdir/\$\$.check
149 if [ ! -r /etc/webmin/config ]; then
150 if [ "\$oscheck" = "" ]; then
151 echo Unable to identify operating system
154 echo Operating system is \$oscheck
155 if [ "\$WEBMIN_PORT\" != \"\" ]; then
160 perl -e 'use Socket; socket(FOO, PF_INET, SOCK_STREAM, getprotobyname("tcp")); setsockopt(FOO, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)); bind(FOO, pack_sockaddr_in(\$ARGV[0], INADDR_ANY)) || exit(1); exit(0);' \$port
161 if [ "\$?" != "0" ]; then
162 echo Port \$port is already in use
166 # Save /etc/webmin in case the upgrade trashes it
167 if [ "\$1" != 1 ]; then
168 rm -rf /etc/.webmin-backup
169 cp -r /etc/webmin /etc/.webmin-backup
171 # Put back old /etc/webmin saved when an RPM was removed
172 if [ "\$1" = 1 -a ! -d /etc/webmin -a -d /etc/webmin.rpmsave ]; then
173 mv /etc/webmin.rpmsave /etc/webmin
178 inetd=`grep "^inetd=" /etc/webmin/miniserv.conf 2>/dev/null | sed -e 's/inetd=//g'`
180 if [ "\$1" != 1 ]; then
181 # Upgrading the RPM, so stop the old webmin properly
182 if [ "\$inetd" != "1" ]; then
183 kill -0 `cat /var/webmin/miniserv.pid 2>/dev/null` 2>/dev/null
184 if [ "\$?" = 0 ]; then
187 /etc/init.d/webmin stop >/dev/null 2>&1 </dev/null
192 cd /usr/libexec/webmin
193 config_dir=/etc/webmin
197 if [ "\$WEBMIN_PORT\" != \"\" ]; then
203 if [ -r /etc/shadow ]; then
204 #crypt=`grep "^root:" /etc/shadow | cut -f 2 -d :`
207 crypt=`grep "^root:" /etc/passwd | cut -f 2 -d :`
217 if [ "\$tempdir" = "" ]; then
220 export config_dir var_dir perl autoos port login crypt host ssl nochown autothird noperlpath nouninstall nostart allow atboot
221 ./setup.sh >\$tempdir/webmin-setup.out 2>&1
222 chmod 600 \$tempdir/webmin-setup.out
223 rm -f /var/lock/subsys/webmin
224 if [ "\$inetd" != "1" -a "\$startafter" = "1" ]; then
225 /etc/init.d/webmin start >/dev/null 2>&1 </dev/null
227 cat >/etc/webmin/uninstall.sh <<EOFF
229 printf "Are you sure you want to uninstall Webmin? (y/n) : "
232 if [ "\\\$answer" = "y" ]; then
233 echo "Removing webmin RPM .."
234 rpm -e --nodeps webmin
238 chmod +x /etc/webmin/uninstall.sh
239 port=`grep "^port=" /etc/webmin/miniserv.conf | sed -e 's/port=//g'`
240 perl -e 'use Net::SSLeay' >/dev/null 2>/dev/null
242 if [ "\$?" = "0" ]; then
243 grep ssl=1 /etc/webmin/miniserv.conf >/dev/null 2>/dev/null
244 if [ "\$?" = "0" ]; then
248 musthost=`grep musthost= /etc/webmin/miniserv.conf | sed -e 's/musthost=//'`
249 if [ "$musthost" != "" ]; then
252 if [ "\$sslmode" = "1" ]; then
253 echo "Webmin install complete. You can now login to https://\$host:\$port/"
255 echo "Webmin install complete. You can now login to http://\$host:\$port/"
257 echo "as root with your root password."
261 if [ "\$1" = 0 ]; then
262 grep root=/usr/libexec/webmin /etc/webmin/miniserv.conf >/dev/null 2>&1
263 if [ "\$?" = 0 ]; then
264 # RPM is being removed, and no new version of webmin
265 # has taken it's place. Run uninstalls and stop the server
266 echo "Running uninstall scripts .."
267 (cd /usr/libexec/webmin ; WEBMIN_CONFIG=/etc/webmin WEBMIN_VAR=/var/webmin LANG= /usr/libexec/webmin/run-uninstalls.pl)
268 /etc/init.d/webmin stop >/dev/null 2>&1 </dev/null
269 /etc/webmin/stop >/dev/null 2>&1 </dev/null
275 if [ "\$1" = 0 ]; then
276 grep root=/usr/libexec/webmin /etc/webmin/miniserv.conf >/dev/null 2>&1
277 if [ "\$?" = 0 ]; then
278 # RPM is being removed, and no new version of webmin
279 # has taken it's place. Rename away the /etc/webmin directory
280 rm -rf /etc/webmin.rpmsave
281 mv /etc/webmin /etc/webmin.rpmsave
287 %triggerpostun -- webmin
288 if [ ! -d /var/webmin -a "\$1" = 2 ]; then
289 echo Re-creating /var/webmin directory
292 if [ ! -r /etc/webmin/miniserv.conf -a -d /etc/.webmin-backup -a "\$1" = 2 ]; then
293 echo Recovering /etc/webmin directory
294 rm -rf /etc/.webmin-broken
295 mv /etc/webmin /etc/.webmin-broken
296 mv /etc/.webmin-backup /etc/webmin
297 /etc/init.d/webmin stop >/dev/null 2>&1 </dev/null
298 /etc/init.d/webmin start >/dev/null 2>&1 </dev/null
300 rm -rf /etc/.webmin-backup
307 $cmd = -x "/usr/bin/rpmbuild" ? "rpmbuild" : "rpm";
308 system("$cmd -ba --target=noarch $spec_dir/webmin-$ver.spec") && exit;
310 system("mv $rpms_dir/webmin-$ver-$rel.noarch.rpm rpm/webmin-$ver-$rel.noarch.rpm");
311 print "Moved to rpm/webmin-$ver-$rel.noarch.rpm\n";
312 system("mv $srpms_dir/webmin-$ver-$rel.src.rpm rpm/webmin-$ver-$rel.src.rpm");
313 print "Moved to rpm/webmin-$ver-$rel.src.rpm\n";
314 system("chown jcameron: rpm/webmin-$ver-$rel.noarch.rpm rpm/webmin-$ver-$rel.src.rpm");
316 system("rpm --resign rpm/webmin-$ver-$rel.noarch.rpm rpm/webmin-$ver-$rel.src.rpm");
320 if (!$webmail && -d "/usr/local/webadmin/rpm/yum") {
321 # Add to our repository
322 system("cp rpm/webmin-$ver-$rel.noarch.rpm /usr/local/webadmin/rpm/yum");