+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#----------------------------------------------------------------------
+
+package esmith;
+
+use strict;
+use CGI ':all';
+use CGI::Carp qw(fatalsToBrowser);
+use FileHandle;
+
+use esmith::cgi;
+use esmith::config;
+use esmith::util;
+use esmith::db;
+
+sub showInitial ($$);
+sub performAndShowResult ($);
+
+BEGIN
+{
+ # Clear PATH and related environment variables so that calls to
+ # external programs do not cause results to be tainted. See
+ # "perlsec" manual page for details.
+
+ #path hack see /sbin/e-smith/yum line 12 & 17
+ $ENV {'PATH'} = '/bin:/usr/bin';
+ $ENV {'SHELL'} = '/bin/bash';
+ delete $ENV {'ENV'};
+}
+
+esmith::util::setRealToEffective ();
+
+my %conf;
+tie %conf, 'esmith::config';
+
+#------------------------------------------------------------
+# examine state parameter and display the appropriate form
+#------------------------------------------------------------
+
+my $q = new CGI;
+
+if (! grep (/^state$/, $q->param))
+{
+ showInitial ($q, '');
+}
+
+elsif ($q->param ('state') eq "perform")
+{
+ performAndShowResult ($q);
+}
+
+else
+{
+ esmith::cgi::genStateError ($q, \%conf);
+}
+
+exit (0);
+
+#------------------------------------------------------------
+# subroutine to display initial form
+#------------------------------------------------------------
+
+sub showInitial ($$)
+{
+ my ($q, $msg) = @_;
+
+ my %yesnoLabels = ('yes' => 'Yes',
+ 'no' => 'No');
+
+ if ($msg eq '')
+ {
+ esmith::cgi::genHeaderNonCacheable
+ ($q, \%conf, 'Update system');
+ }
+ else
+ {
+ esmith::cgi::genHeaderNonCacheable
+ ($q, \%conf, 'Update system');
+
+ print $q->p ($msg);
+ print $q->hr;
+ }
+
+ print $q->start_multipart_form (
+ -method => 'POST',
+ -action => $q->url (-absolute => 1));
+
+ print $q->p ('The Update system panel is used for uploading and installing rpms.
+ The rpm will be installed with YUM and will attempt to meet any dependancies
+ from your configured repositories, if the dependancies fail the install will not proceed.
+
+ WARNING: as this is automatic, you are not given the [y/n] option to cancel.
+
+ Use the Browse button below to find the .rpm file on your workstation.
+ The Update button will upload the file to the server and automatically
+ launch the install process. When completed you will be shown a log file which you
+ may review to see if the update was successful and without errors.
+
+ NOTE: The screen will not refresh until the install is complete');
+
+ print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
+
+ esmith::cgi::genWidgetRow ($q, "Update file ",
+ $q->filefield (-name => 'updateFile',
+ -default => "update.rpm",
+ -size => 32)));
+
+ print $q->p (esmith::cgi::genButtonRow ($q,
+ $q->submit (-name => 'action', -value => 'Update')));
+
+ print $q->hidden (-name => 'state', -override => 1, -default => 'perform');
+
+ print $q->endform;
+ esmith::cgi::genFooter ($q);
+}
+
+sub performAndShowResult ($)
+{
+ my ($q) = @_;
+
+ my $updateFile = $q->param ('updateFile');
+
+ if (-e "/tmp/update.rpm")
+ {
+ unlink ("/tmp/update.rpm");
+ }
+
+ if ("$updateFile" ne "")
+ {
+ unlink ("/tmp/update.rpm");
+ open (WR,">/tmp/update.rpm")||die ("Error while opening temporally file.\n");
+ while (<$updateFile>)
+ {
+ print WR;
+ }
+ close WR;
+ }
+
+ system ("/sbin/e-smith/signal-event", "update-system") == 0
+ or die ("Error occurred while updating the system.\n");
+
+ sleep 3;
+
+ system ("/usr/bin/tail -200 /var/log/messages > /var/log/update-system.log") == 0
+ or die ("Error occurred while creating /var/log/update-system.log.\n");
+
+ esmith::cgi::genHeaderNonCacheable
+ ($q, \%conf, "Update uploaded successfully");
+
+ print $q->p ('Your server has being updated.
+ Please review the log file below for the last
+ Processing event: update-system to make sure no errors occured.');
+
+ print '';
+
+ print $q->hr;
+
+ if ( -f "/var/log/update-system.log" )
+ {
+ print $q->table ({border => 0, cellspacing => 0, cellpadding => 4});
+
+ print "
";
+ open (INF,"/var/log/update-system.log")
+ or die ("can't open /var/log/update-system.log file: $1");
+
+ while ()
+ {
+ print "$_";
+ }
+
+ close INF;
+ print "
\n";
+ }
+ else
+ {
+ print $q->table ({border => 0, cellspacing => 0, cellpadding => 4},
+ (esmith::cgi::genSmallRedCell ($q, "NOTE: You have no /var/log/update-system.log ".
+ "file, you shouldn't see this?")));
+ }
+
+ esmith::cgi::genFooter ($q);
+ return;
+}
diff --git a/smeserver-updates.spec b/smeserver-updates.spec
new file mode 100644
index 0000000..be0513f
--- /dev/null
+++ b/smeserver-updates.spec
@@ -0,0 +1,126 @@
+# $Id: smeserver-updates.spec,v 1.2 2020/10/29 19:22:58 brianr Exp $
+# Authority: dungog
+# Name: Stephen Noble
+
+Summary: Update system panel for SMEserver ç
+%define name smeserver-updates
+Name: %{name}
+%define version 1.4
+%define release 4
+Version: %{version}
+Release: %{release}%{?dist}
+License: GPL
+Group: System/Administration
+Source: %{name}-%{version}.tar.xz
+BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot
+BuildArchitectures: noarch
+Requires: e-smith-release >= 9.0
+BuildRequires: e-smith-devtools
+AutoReqProv: no
+
+%description
+Update system panel for sme server 9
+permitting the uploading and installing of .rpms
+
+%changelog
+* Sat Sep 07 2024 cvs2git.sh aka Brian Read 1.4-4.sme
+- Roll up patches and move to git repo [SME: 12338]
+
+* Sat Sep 07 2024 BogusDateBot
+- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday,
+ by assuming the date is correct and changing the weekday.
+
+* Thu Oct 29 2020 Brian Read 1.4-3.sme
+- Initial import to SME10 tree [SME: 11075]
+
+* Sat Aug 22 2015 stephane de Labrusse 1.4-2.sme
+- Initial release to contribs9
+
+* Mon Jun 23 2014 stephane de Labrusse 1.4-1.sme
+- Initial release to sme9
+
+* Wed Jun 26 2013 JP Pialasse 1.2-5.sme
+- fixing spec file
+
+* Tue Jun 25 2013 JP Pialasse 1.2-4.sme
+- fix yum path [SME: 7478]
+- patch0
+
+* Tue Jan 23 2007 Stephen Noble
+- install with 'yum localinstall'
+- [1.2-3]
+
+* Mon Mar 13 2006 Stephen Noble
+- sme7 version
+- uploading and installing an rpm fixed
+- [1.2-2]
+
+* Tue Dec 13 2005 Stephen Noble
+- sme7 version
+- removed all functions except for uploading and installing a rpm
+- yum is usually a better option
+- [1.2-1]
+
+* Tue Feb 19 2002 Darrell May
+- initial release based on:
+- eneo-update-1.0-01.noarch.rpm
+- Vendor: Eneo Tecnologia SC.
+- Packager: Juan Jesus Prieto
+- [0.0.1-1]
+
+%prep
+%setup
+
+
+%build
+perl createlinks
+
+%install
+/bin/rm -rf $RPM_BUILD_ROOT
+(cd root ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT)
+/bin/rm -f e-smith-%{version}-filelist
+/sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist
+
+%clean
+cd ..
+/bin/rm -rf %{name}-%{version}
+
+%files -f %{name}-%{version}-filelist
+
+%defattr(-,root,root)
+
+%pre
+
+%post
+#new installs
+
+#echo " If panel doesnt appear run /etc/e-smith/events/actions/navigation-conf"
+
+# DBS=`find /home/e-smith/db/navigation -type f -name "navigation.*"`
+# for db in $DBS ; do
+# r=`/sbin/e-smith/db $db get update-system`
+# if [ -z "$r" ] ; then
+# /sbin/e-smith/db $db set update-system panel Description "Update system" DescriptionWeight 4390 Heading "Administration" HeadingWeight 4000
+# fi
+# done
+
+ #if [ -d /etc/e-smith/events/conf-userpanel ] ; then
+ # /sbin/e-smith/signal-event conf-userpanel
+ #fi
+
+%preun
+
+%postun
+#uninstalls
+#if [ $1 = 0 ] ; then
+#
+# DBS=`find /home/e-smith/db/navigation -type f -name "navigation.*"`
+# for db in $DBS ; do
+# /sbin/e-smith/db $db delete update-system
+# done
+#
+# #if [ -d /etc/e-smith/events/conf-userpanel ] ; then
+# # /sbin/e-smith/signal-event conf-userpanel
+# #fi
+#
+#fi