too late for a commit message

This commit is contained in:
Paolo Asperti 2016-07-24 00:27:49 +02:00
parent 91840647e5
commit 3d81fd12e3
10 changed files with 80 additions and 103 deletions

View File

@ -28,39 +28,110 @@ rm -f %{name}-%{version}-%{release}-filelist
mkdir -p %{buildroot}%{_localstatedir}/log/doraemon
mkdir -p %{buildroot}%{_localstatedir}/cache/doraemon
# Copy the webroot dir
# mkdir -p %{buildroot}%{_datarootdir}/%{name}
# cp -av doraemon/* %{buildroot}%{_datadir}/%{name}
%pre
#if [ "$1" = 1 ]; then
# #installation
#fi
if [ "$1" = 2 ]; then
#upgrade
/sbin/stop %{name} >/dev/null 2>&1 || :
DATABASE=/var/lib/doraemon/doraemon.db
INI=/etc/doraemon.ini
if [ -f $INI ]; then
DATABASE=$(awk -F "=" '/Database/ {print $2}' $INI)
PORT=$(awk -F "=" '/Port/ {print $2}' $INI)
BASE=$(awk -F "=" '/Base/ {print $2}' $INI)
ROLE=$(awk -F "=" '/Role/ {print $2}' $INI)
DIGITS=$(awk -F "=" '/Digits/ {print $2}' $INI)
DOMAIN=$(awk -F "=" '/Domain/ {print $2}' $INI)
MGMTKEY=$(awk -F "=" '/MgmtKey/ {print $2}' $INI)
VAULTPASSFILE=$(awk -F "=" '/VaultPassFile/ {print $2}' $INI)
rm $INI
/sbin/e-smith/db configuration set %{name} service \
status enabled \
TCPPort $PORT \
access private \
DefaultRole $ROLE \
DomainFile $DOMAIN \
ManagementKeyFile $MGMTKEY \
NamingBase $BASE \
NamingDigits $DIGITS \
VaultPassFile $VAULTPASSFILE
else
/sbin/e-smith/db configuration set %{name} service \
status enabled \
TCPPort 3000 \
access private \
DefaultRole client \
DomainFile /etc/domain.yml \
ManagementKeyFile /home/amgmt/.ssh/id_rsa.pub \
NamingBase lab \
NamingDigits 2 \
VaultPassFile /home/amgmt/.ansible/vault.txt
fi
if [ -f $DATABASE ]; then
sqlite3 -separator " " $DATABASE \
"select * from client" | while read id hostname mac role; do
/sbin/e-smith/db hosts set $hostname remote \
MacAddress $mac Role $role
done
rm $DATABASE
fi
fi
%post
if [ "$1" = 1 ]; then
#installation
/sbin/e-smith/db configuration set %{name} service status enabled TCPPort 3000 access private DefaultRole client DomainFile /etc/domain.yml ManagementKeyFile /home/amgmt/.ssh/id_rsa.pub NamingBase lab NamingDigits 2 VaultPassFile /home/amgmt/.ansible/vault.txt
/sbin/e-smith/expand-template /etc/sudoers
/sbin/e-smith/expand-template /etc/httpd/doraemon/httpd.conf
/sbin/start %{name} >/dev/null 2>&1 || :
/sbin/e-smith/signal-event runlevel-adjust
/sbin/e-smith/signal-event firewall-adjust
fi
if [ "$1" = 2 ]; then
#upgrade
# TODO: this won't be needed in the next version
/sbin/e-smith/expand-template /etc/sudoers
/sbin/e-smith/expand-template /etc/httpd/doraemon/httpd.conf
/sbin/start %{name} >/dev/null 2>&1 || :
/sbin/e-smith/signal-event runlevel-adjust
/sbin/e-smith/signal-event firewall-adjust
fi
%preun
#if [ "$1" = 1 ]; then
# #upgrade
#fi
if [ "$1" = 0 ]; then
#uninstallation
/sbin/stop %{name} >/dev/null 2>&1 || :
fi
%postun
#if [ "$1" = 1 ]; then
# #upgrade
#fi
if [ "$1" = 0 ]; then
#uninstallation
/sbin/e-smith/db configuration delete %{name}
/sbin/e-smith/expand-template /etc/sudoers
/sbin/e-smith/signal-event runlevel-adjust
/sbin/e-smith/signal-event firewall-adjust
fi
%clean
rm -rf %{buildroot}
%files -f %{name}-%{version}-%{release}-filelist
%files
%defattr(644,root,root,755)
# %doc README.md LICENSE.txt
# %attr(755,-,-) %{_initrddir}/%{name}
# %{_sysconfdir}/logrotate.d/%{name}
# %dir %{_sysconfdir}/httpd/doraemon
%doc README.md LICENSE.txt
%attr(0750,srvmgr,srvmgr) %dir %{_localstatedir}/cache/doraemon
# %attr(0644,root,root) %ghost %{_sysconfdir}/init/doraemon.conf
# %attr(0644,root,root) %ghost %{_sysconfdir}/httpd/doraemon/httpd.conf
%attr(0700,root,root) %dir %{_localstatedir}/log/doraemon
%attr(0644,root,root) %config %ghost %{_localstatedir}/log/doraemon/access_log
%attr(0644,root,root) %config %ghost %{_localstatedir}/log/doraemon/error_log

View File

@ -1,33 +0,0 @@
{
#
# feature2956_ns6 -- Base: refactor Remote Access page
#
# The ValidFrom prop is migrated to AllowAccess
#
# TODO: gestire la migrazione dal doraemon precedente (sqlite + doraemon.ini -> e-smith)
use esmith::ConfigDB;
use esmith::util;
my $cdb = esmith::ConfigDB->open();
my $validFrom = $cdb->get_prop_and_delete('httpd-admin', 'ValidFrom') || '';
# 1) Ignore ValidFrom if AllowHosts is already set
if($cdb->get_prop('httpd-admin', 'AllowHosts')) {
return "";
}
# 2) Sanitize and import validFrom value if access is private
if($cdb->get_prop('httpd-admin', 'access') eq 'private') {
my $newValue = join(',', map {
my ($ipaddr, $netmask) = (split(/\//, $_));
$_ eq '0.0.0.0/0.0.0.0' ? () : esmith::util::computeLocalNetworkShortSpec($ipaddr, $netmask);
} split(/,/, $validFrom));
$cdb->set_prop('httpd-admin', 'AllowHosts', $newValue);
}
"";
}

View File

@ -1,3 +0,0 @@
#!/bin/bash
exec /sbin/start doraemon-reload

View File

@ -1,56 +0,0 @@
#!/usr/bin/perl
#
# Copyright (C) 2013 Nethesis S.r.l.
# http://www.nethesis.it - support@nethesis.it
#
# This script is part of NethServer.
#
# NethServer 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 3 of the License,
# or any later version.
#
# NethServer 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 NethServer. If not, see <http://www.gnu.org/licenses/>.
#
# TODO: manage migration
use esmith::DB::db;
use esmith::event;
use strict;
my $event = shift;
my $sourceDir = shift;
my $esmithDbDir = '/home/e-smith/db';
my $errors = 0;
if( ! -d $sourceDir) {
die("Could not find dir $sourceDir");
}
my $srcConfigDb = esmith::DB::db->open_ro(join('', $sourceDir, $esmithDbDir, '/configuration')) || die("Could not open source configuration database in $sourceDir \n");
my $dstConfigDb = esmith::DB::db->open('configuration') || die("Could not open destination account db\n");
my $service = 'httpd-admin';
my $old = $srcConfigDb->get($service);
my $new = $dstConfigDb->get($service) || $dstConfigDb->new_record($service);
$new->set_prop('ValidFrom', $old->prop('ValidFrom') || '');
$old = $srcConfigDb->get('modSSL');
$new->set_prop('SSLCipherSuite', $old->prop('CipherSuite') || 'ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM');
#
# Apply configuration
#
if( ! esmith::event::event_signal('nethserver-httpd-admin-update')) {
exit(1);
}
exit 0;

View File

@ -1 +0,0 @@
../actions/doraemon-migrate

View File