small fixes
stupid vault typo e vaultpass permission via sudo added ui only 'remote' hosts sdasfdfsda boh test specfile
This commit is contained in:
parent
cc8a26960a
commit
b1502803ff
@ -1,97 +0,0 @@
|
||||
Summary: apache/mod_php stack for Doraemon
|
||||
Name: doraemon
|
||||
Version: 1.3.0.1
|
||||
Release: 1%{?dist}
|
||||
License: GPL
|
||||
URL: %{url_prefix}/%{name}
|
||||
BuildArch: noarch
|
||||
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
|
||||
|
||||
BuildRequires: nethserver-devtools
|
||||
|
||||
BuildRequires: systemd
|
||||
Requires(post): systemd
|
||||
Requires(preun): systemd
|
||||
Requires(postun): systemd
|
||||
|
||||
Requires: httpd, php, sudo, php-xml, php-mcrypt, nethserver-httpd-admin
|
||||
Requires: nethserver-base, nethserver-php
|
||||
Requires: nethserver-lang-en
|
||||
|
||||
%description
|
||||
Runs an Apache instance on port 3000 that serves
|
||||
the doraemon web application
|
||||
|
||||
%prep
|
||||
%setup
|
||||
|
||||
|
||||
# Nethgui:
|
||||
cd %{_builddir}/nethgui-%{nethgui_commit}
|
||||
|
||||
%build
|
||||
perl createlinks
|
||||
mkdir -p root/%{_nseventsdir}/%{name}-update
|
||||
|
||||
%install
|
||||
(cd root ; find . -depth -print | cpio -dump %{buildroot})
|
||||
rm -f %{name}-%{version}-%{release}-filelist
|
||||
%{genfilelist} %{buildroot} \
|
||||
> %{name}-%{version}-%{release}-filelist
|
||||
mkdir -p %{buildroot}/%{_localstatedir}/log/doraemon
|
||||
mkdir -p %{buildroot}/%{_localstatedir}/cache/doraemon
|
||||
|
||||
# Copy the server-manager dir
|
||||
mkdir -p %{buildroot}%{_nsuidir}
|
||||
cp -av nethserver-manager %{buildroot}%{_nsuidir}/nethserver-manager
|
||||
|
||||
%files -f %{name}-%{version}-%{release}-filelist
|
||||
%defattr(-,root,root)
|
||||
%doc %{extradocs}
|
||||
|
||||
%{_nsuidir}/nethserver-manager
|
||||
|
||||
|
||||
%dir %{_nseventsdir}/%{name}-update
|
||||
%dir %{_sysconfdir}/httpd/doraemon.d
|
||||
|
||||
%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
|
||||
%config(noreplace) /etc/sysconfig/doraemon
|
||||
|
||||
%post
|
||||
%systemd_post doraemon.service
|
||||
|
||||
%preun
|
||||
%systemd_preun doraemon.service
|
||||
|
||||
%postun
|
||||
%systemd_postun
|
||||
|
||||
%changelog
|
||||
* Tue Oct 27 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.1-2.ns6
|
||||
- Packing corrections to rpm to fix upgrading issue
|
||||
|
||||
* Tue Oct 27 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.1-1.ns6
|
||||
- Packing new minor correction on how packages are extracted from db
|
||||
|
||||
* Mon Sep 11 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.0-1.ns6
|
||||
- Packing new version with ansible dynamic inventory support, epoptes server role support.
|
||||
|
||||
* Mon Sep 07 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.1.1-1.ns6
|
||||
- Packing new version with correct roles.
|
||||
|
||||
* Sun Sep 06 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.1.0-1.ns6
|
||||
- Packing new version with new functionalities.
|
||||
|
||||
* Wed Jul 15 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.0.0-2.ns6
|
||||
- Added logrotate file.
|
||||
|
||||
* Mon Jul 13 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.0.0-1.ns6
|
||||
- Unique binary for both ansiblehelper and mac2hostname.
|
@ -1,15 +1,16 @@
|
||||
Summary: Helps client to join domain and maintain itself
|
||||
Name: doraemon
|
||||
Version: 1.2.1
|
||||
Release: 2.ns6
|
||||
Version: 1.3.0
|
||||
Release: 1.ns6
|
||||
URL: https://github.com/bglug-it/doraemon/
|
||||
License: GPLv2+
|
||||
Group: System Environment/Daemons
|
||||
BuildRoot: %{_tmppath}/%{name}-root
|
||||
Requires: python python-bottle python-crypto2.6 nethserver-base
|
||||
Requires(post): chkconfig nethserver-base
|
||||
Requires(preun): chkconfig initscripts nethserver-base
|
||||
Source0: doraemon-1.2.1.tar.gz
|
||||
BuildRequires: nethserver-devtools > 1.0.1
|
||||
Requires: httpd, php, sudo, php-xml, php-mcrypt
|
||||
Requires: nethserver-base, nethserver-php
|
||||
Requires: upstart
|
||||
Source0: doraemon-1.3.0.tar.gz
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
@ -21,33 +22,20 @@ Helps client on a domain network to get information for its maintenance.
|
||||
%build
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
install -d %{buildroot}
|
||||
install -d -m 755 %{buildroot}%{_sysconfdir}
|
||||
install -m 644 doraemon.ini %{buildroot}%{_sysconfdir}/%{name}.ini
|
||||
# Installo il servizio
|
||||
install -d -m 755 %{buildroot}%{_initrddir}
|
||||
install -m 755 initrd %{buildroot}%{_initrddir}/%{name}
|
||||
# Installo lo script vero e proprio
|
||||
install -d -m 755 %{buildroot}%{_bindir}
|
||||
install -m 755 doraemon.py %{buildroot}%{_bindir}/%{name}.py
|
||||
# Cartella del database
|
||||
install -d %{buildroot}%{_sharedstatedir}/%{name}
|
||||
# File per il rotate
|
||||
install -d %{buildroot}%{_sysconfdir}/logrotate.d
|
||||
install -m 644 doraemon.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
|
||||
# File di Nethserver
|
||||
install -d %{buildroot}%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}
|
||||
install -m 644 type %{buildroot}%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/type
|
||||
install -m 644 status %{buildroot}%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/status
|
||||
install -m 644 access %{buildroot}%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/access
|
||||
install -m 644 TCPPort %{buildroot}%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/TCPPort
|
||||
(cd root ; find . -depth -print | cpio -dump %{buildroot})
|
||||
rm -f %{name}-%{version}-%{release}-filelist
|
||||
%{genfilelist} %{buildroot} > %{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}
|
||||
|
||||
%post
|
||||
if [ "$1" = 1 ]; then
|
||||
/sbin/chkconfig --add %{name}
|
||||
/sbin/service %{name} start >/dev/null 2>&1
|
||||
/sbin/e-smith/db configuration set %{name} service status enabled TCPPort 3000 access private
|
||||
/sbin/start %{name} >/dev/null 2>&1 || :
|
||||
/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/signal-event runlevel-adjust
|
||||
/sbin/e-smith/signal-event firewall-adjust
|
||||
fi
|
||||
@ -55,8 +43,7 @@ fi
|
||||
%preun
|
||||
if [ "$1" = 0 ]; then
|
||||
/sbin/e-smith/db configuration delete %{name}
|
||||
/sbin/service %{name} stop >/dev/null 2>&1
|
||||
chkconfig --del %{name}
|
||||
/sbin/stop %{name} >/dev/null 2>&1 || :
|
||||
/sbin/e-smith/signal-event runlevel-adjust
|
||||
/sbin/e-smith/signal-event firewall-adjust
|
||||
fi
|
||||
@ -64,22 +51,26 @@ fi
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%files -f %{name}-%{version}-%{release}-filelist
|
||||
%files
|
||||
%defattr(644,root,root,755)
|
||||
%doc README.md LICENSE
|
||||
%config(noreplace) %{_sysconfdir}/%{name}.ini
|
||||
%attr(755,-,-) %{_initrddir}/%{name}
|
||||
%attr(755,-,-) %{_bindir}/%{name}.py
|
||||
# %doc README.md LICENSE.txt
|
||||
# %attr(755,-,-) %{_initrddir}/%{name}
|
||||
# %{_sysconfdir}/logrotate.d/%{name}
|
||||
# %dir %{_sysconfdir}/httpd/doraemon
|
||||
%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
|
||||
|
||||
%dir %attr(755,-,-) %{_sharedstatedir}/%{name}
|
||||
%{_sysconfdir}/logrotate.d/%{name}
|
||||
%dir %attr(755,-,-) %{_sysconfdir}/e-smith/db/configuration/defaults/%{name}
|
||||
%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/status
|
||||
%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/type
|
||||
%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/access
|
||||
%{_sysconfdir}/e-smith/db/configuration/defaults/%{name}/TCPPort
|
||||
|
||||
%changelog
|
||||
* Mon Jul 18 2016 Paolo Asperti <paolo-AT-asperti.com> - 1.3.0-1.ns6
|
||||
- PHP porting
|
||||
- Added a basic UI
|
||||
|
||||
* Tue Oct 27 2015 Emiliano Vavassori <syntaxerrormmm-AT-gmail.com> - 1.2.1-2.ns6
|
||||
- Packing corrections to rpm to fix upgrading issue
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
#
|
||||
# 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);
|
||||
}
|
||||
|
||||
|
||||
"";
|
||||
}
|
3
root/etc/e-smith/events/actions/doraemon-asyncreload
Executable file
3
root/etc/e-smith/events/actions/doraemon-asyncreload
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec /sbin/start doraemon-reload
|
56
root/etc/e-smith/events/actions/doraemon-migrate
Executable file
56
root/etc/e-smith/events/actions/doraemon-migrate
Executable file
@ -0,0 +1,56 @@
|
||||
#!/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;
|
1
root/etc/e-smith/events/doraemon-update/services2adjust/doraemon
Symbolic link
1
root/etc/e-smith/events/doraemon-update/services2adjust/doraemon
Symbolic link
@ -0,0 +1 @@
|
||||
restart
|
1
root/etc/e-smith/events/migration-import/S99doraemon-migrate
Symbolic link
1
root/etc/e-smith/events/migration-import/S99doraemon-migrate
Symbolic link
@ -0,0 +1 @@
|
||||
../actions/doraemon-migrate
|
@ -0,0 +1,3 @@
|
||||
TEMPLATE_PATH='upstart-job'
|
||||
OUTPUT_FILENAME='/etc/init/doraemon.conf'
|
||||
MORE_DATA={ name => 'doraemon', description => 'Apache instance that runs the doraemon service', author => 'Paolo Asperti <paolo@asperti.com>', daemon_bin => '/usr/sbin/doraemon', daemon_args => '-f /etc/httpd/doraemon/httpd.conf', respawn => 1, 'expect' => 'fork', stop_on => 'stopping network', start_on => 'started network' }
|
6
root/etc/e-smith/templates/etc/sudoers/50doraemon
Normal file
6
root/etc/e-smith/templates/etc/sudoers/50doraemon
Normal file
@ -0,0 +1,6 @@
|
||||
#
|
||||
# 50doraemon
|
||||
#
|
||||
srvmgr ALL=NOPASSWD: /bin/cat /home/amgmt/.ansible/vault.txt
|
||||
|
||||
|
12
root/etc/init/doraemon-reload.conf
Normal file
12
root/etc/init/doraemon-reload.conf
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
# doraemon-reload task
|
||||
#
|
||||
# Signals an Apache graceful restart for doraemon instance
|
||||
#
|
||||
|
||||
# service job, runs asynchronously
|
||||
|
||||
script
|
||||
sleep 5
|
||||
exec /usr/sbin/doraemon -f /etc/httpd/doraemon/httpd.conf -k graceful
|
||||
end script
|
@ -1,8 +0,0 @@
|
||||
#
|
||||
# This file can be used to set additional environment variables for
|
||||
# the httpd-admin process, or pass additional options to the
|
||||
# httpd-admin executable. See httpd-admin.service unit.
|
||||
#
|
||||
|
||||
LANG=C
|
||||
|
@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=Graceful restart of doraemon service
|
||||
Documentation=https://github.com/bglug-it/doraemon
|
||||
Requisite=doraemon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/httpd -f /etc/httpd/doraemon/httpd.conf -k graceful
|
||||
|
@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=Delayed graceful restart of doraemon service
|
||||
Documentation=https://github.com/bglug-it/doraemon
|
||||
Conflicts=doraemon-reload.service
|
||||
|
||||
[Timer]
|
||||
OnActiveSec=5
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=Doraemon httpd instance
|
||||
Documentation=https://github.com/bglug-it/doraemon
|
||||
After=network.target remote-fs.target nss-lookup.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=/etc/sysconfig/doraemon
|
||||
ExecStart=/usr/sbin/httpd -f /etc/httpd/doraemon/httpd.conf -c 'MaxConnectionsPerChild 12' -DFOREGROUND
|
||||
ExecReload=/usr/sbin/httpd -f /etc/httpd/doraemon/httpd.conf -k graceful
|
||||
LimitNOFILE=4096
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -133,7 +133,7 @@ function ROUTE_hosts() {
|
||||
if (isset($get_params['role'])) {
|
||||
$items = $hosts_db->getAllByProp('Role', $get_params['role']);
|
||||
} else {
|
||||
$items = $hosts_db->getAll();
|
||||
$items = $hosts_db->getAll('remote');
|
||||
}
|
||||
$results=array();
|
||||
foreach ($items as $name=>$item) {
|
||||
@ -170,16 +170,18 @@ function ROUTE_ansible_list() {
|
||||
function ROUTE_vaultpass() {
|
||||
global $config_db;
|
||||
$theFile = $config_db->getProp(CONFIG_KEY,'VaultPassFile');
|
||||
$content = trim(file_get_contents($theFile));
|
||||
$oArr = array();
|
||||
exec('/usr/bin/sudo /bin/cat ' . $theFile, $oArr, $exitCode);
|
||||
$content = trim(implode("\n", $oArr));
|
||||
if (false === $content) {
|
||||
echo 'no file'; return;
|
||||
}
|
||||
if (!$client = getClient()) {
|
||||
echo 'no client'; return;
|
||||
}
|
||||
$key = md5($client['name']);
|
||||
$key = md5($client['name'], true);
|
||||
$padlenght = 16 - (strlen($content) % 16);
|
||||
$content_padded = str_repeat('x', $padlenght);
|
||||
$content_padded = $content . str_repeat('x', $padlenght);
|
||||
$ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $content_padded, MCRYPT_MODE_ECB);
|
||||
echo base64_encode($ciphertext);
|
||||
}
|
||||
@ -230,7 +232,7 @@ function newHostname($mac, $base, $role) {
|
||||
return;
|
||||
}
|
||||
|
||||
$domainName = $config_db->getKeyValue('DomainName');
|
||||
$domainName = (string)$config_db->getKeyValue('DomainName');
|
||||
$digits = $config_db->getProp(CONFIG_KEY,'NamingDigits');
|
||||
$formatstring = '%s-%0'.$digits.'d';
|
||||
$nr=0;
|
||||
@ -238,9 +240,10 @@ function newHostname($mac, $base, $role) {
|
||||
do {
|
||||
$nr++;
|
||||
$hostname = sprintf($formatstring, $base, $nr);
|
||||
if ($domainName != '') {
|
||||
$hostname .= '.' . $domainname;
|
||||
}
|
||||
# TODO: we'll use the hostname in future, maybe
|
||||
# if (trim($domainName) != '') {
|
||||
# $hostname .= '.' . $domainName;
|
||||
# }
|
||||
} while ($hosts_db->getKey($hostname));
|
||||
|
||||
$hosts_db->setKey($hostname, 'remote', array(
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/* /usr/share/nethesis/NethServer/Language/en/NethServer_Module_Doraemon.php */
|
||||
|
||||
$L['Doraemon_Title'] = 'Doraemon';
|
||||
$L['Key_label'] = 'Hostname';
|
||||
$L['hostname_label'] = 'Hostname';
|
||||
$L['Role_label'] = 'Role';
|
||||
$L['MacAddress_label'] = 'MAC Address';
|
||||
$L['Hosts_title'] = 'Hosts';
|
||||
$L['Create_Host_Header'] = 'Create a new host';
|
||||
$L['Update_Host_Header'] = 'Update host "${0}"';
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
/* /usr/share/nethesis/NethServer/Language/it/NethServer_Module_Doraemon.php */
|
||||
|
||||
$L['Doraemon_Title'] = 'Doraemon';
|
||||
$L['Key_label'] = 'Hostname';
|
||||
$L['hostname_label'] = 'Hostname';
|
||||
$L['Role_label'] = 'Ruolo';
|
||||
$L['MacAddress_label'] = 'MAC Address';
|
||||
$L['Hosts_title'] = 'Hosts';
|
||||
$L['Create_Host_Header'] = 'Crea un nuovo host';
|
||||
$L['Update_Host_Header'] = 'Modifica il nome host "${0}"';
|
17
root/usr/share/nethesis/NethServer/Module/Doraemon.php
Normal file
17
root/usr/share/nethesis/NethServer/Module/Doraemon.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace NethServer\Module;
|
||||
|
||||
class Doraemon extends \Nethgui\Controller\TabsController
|
||||
{
|
||||
protected function initializeAttributes(\Nethgui\Module\ModuleAttributesInterface $base)
|
||||
{
|
||||
return \Nethgui\Module\SimpleModuleAttributesProvider::extendModuleAttributes($base, 'Configuration', 50);
|
||||
}
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->loadChildrenDirectory();
|
||||
}
|
||||
|
||||
}
|
34
root/usr/share/nethesis/NethServer/Module/Doraemon/Hosts.php
Normal file
34
root/usr/share/nethesis/NethServer/Module/Doraemon/Hosts.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace NethServer\Module\Doraemon;
|
||||
|
||||
|
||||
class Hosts extends \Nethgui\Controller\TableController
|
||||
{
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
$columns = array(
|
||||
'Key',
|
||||
'MacAddress',
|
||||
'Role',
|
||||
'Actions',
|
||||
);
|
||||
|
||||
$this
|
||||
->setTableAdapter($this->getPlatform()->getTableAdapter('hosts', 'remote'))
|
||||
->setColumns($columns)
|
||||
// TODO:
|
||||
// ->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('wake'))
|
||||
// ->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('reboot'))
|
||||
// ->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('shutdown'))
|
||||
->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('update'))
|
||||
->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('delete'))
|
||||
->addTableAction(new \NethServer\Module\Doraemon\Hosts\Modify('create'))
|
||||
->addTableAction(new \Nethgui\Controller\Table\Help('Help'))
|
||||
;
|
||||
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace NethServer\Module\Doraemon\Hosts;
|
||||
|
||||
use Nethgui\System\PlatformInterface as Validate;
|
||||
|
||||
|
||||
class Modify extends \Nethgui\Controller\Table\Modify
|
||||
{
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
$parameterSchema = array(
|
||||
// was: Validate::HOSTNAME_FQDN, but we need hostname
|
||||
array('hostname', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::KEY),
|
||||
array('MacAddress', Validate::MACADDRESS, \Nethgui\Controller\Table\Modify::FIELD),
|
||||
array('Role', Validate::ANYTHING, \Nethgui\Controller\Table\Modify::FIELD),
|
||||
// array('Role', Validate::ROLES_COLLECTION ??? TODO!!!, \Nethgui\Controller\Table\Modify::FIELD),
|
||||
);
|
||||
$this->setSchema($parameterSchema);
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
public function validate(\Nethgui\Controller\ValidationReportInterface $report)
|
||||
{
|
||||
if ($this->getIdentifier() === 'delete') {
|
||||
$v = $this->createValidator()->platform('host-delete');
|
||||
if ( ! $v->evaluate($this->parameters['hostname'])) {
|
||||
$report->addValidationError($this, 'Key', $v);
|
||||
}
|
||||
}
|
||||
parent::validate($report);
|
||||
}
|
||||
|
||||
protected function onParametersSaved($parameters)
|
||||
{
|
||||
$actionName = $this->getIdentifier();
|
||||
if ($actionName === 'update') {
|
||||
$actionName = 'modify';
|
||||
}
|
||||
$this->getPlatform()->signalEvent(sprintf('host-%s &', $actionName));
|
||||
}
|
||||
|
||||
public function prepareView(\Nethgui\View\ViewInterface $view)
|
||||
{
|
||||
parent::prepareView($view);
|
||||
$templates = array(
|
||||
'create' => 'NethServer\Template\Doraemon\Hosts',
|
||||
'update' => 'NethServer\Template\Doraemon\Hosts',
|
||||
'delete' => 'Nethgui\Template\Table\Delete',
|
||||
);
|
||||
$view->setTemplate($templates[$this->getIdentifier()]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/* @var $view \Nethgui\Renderer\Xhtml */
|
||||
|
||||
if ($view->getModule()->getIdentifier() == 'update') {
|
||||
// disable updating of hostname
|
||||
// the hostname is the key of the db item, if you change it, bad things happens
|
||||
$keyFlags = $view::STATE_DISABLED;
|
||||
$template = 'Update_Host_Header';
|
||||
} else {
|
||||
$keyFlags = 0;
|
||||
$template = 'Create_Host_Header';
|
||||
}
|
||||
|
||||
echo $view->header('hostname')->setAttribute('template', $T($template));
|
||||
|
||||
echo $view->panel()
|
||||
->insert($view->textInput('hostname', $keyFlags))
|
||||
->insert($view->textInput('MacAddress'))
|
||||
->insert($view->textInput('Role'))
|
||||
;
|
||||
|
||||
echo $view->buttonList($view::BUTTON_SUBMIT | $view::BUTTON_CANCEL | $view::BUTTON_HELP);
|
Loading…
x
Reference in New Issue
Block a user