#718: Mejoras en OGAgent para Windows:

* Obtener versión y edición de Windows.
 * Ampliar el tiempo de detección de la red a 5 min.
 * Deshabilitar la hibernación en la instalación del OGAgent.
 * Reinicio opcional en la desinstalación.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5553 a21b9725-9963-47de-94b9-378ad31fedc9
remotes/github/oglive
ramon 2018-01-12 13:15:48 +00:00
parent 622bc35be6
commit 2e072d295d
6 changed files with 31 additions and 10 deletions

View File

@ -4,7 +4,7 @@ Priority: optional
Maintainer: Ramón M. Gómez <ramongomez@us.es>
Build-Depends: debhelper (>= 7), po-debconf
Standards-Version: 3.9.2
Homepage: http://www.opengnsys.es
Homepage: https://opengnsys.es
Package: ogagent
Section: admin

1
src/VERSION 100644
View File

@ -0,0 +1 @@
1.1.0

View File

@ -82,8 +82,8 @@ class OpenGnSysWorker(ServerWorker):
self.cmd = None
# Ensure cfg has required configuration variables or an exception will be thrown
self.REST = REST(self.service.config.get('opengnsys', 'remote'))
# Get network interfaces until they are active or timeout (1 minute)
for t in range(0, 60):
# Get network interfaces until they are active or timeout (5 minutes)
for t in range(0, 300):
try:
self.interface = list(operations.getNetworkInfo())[0] # Get first network interface
except Exception as e:

View File

@ -38,7 +38,7 @@ import sys
if sys.platform == 'win32':
from .windows.operations import * # @UnusedWildImport
osType = 'Windows'
osVersion = '.'.join(map(str,getWindowsVersion()[:3]))+' '+getWindowsVersion()[4]
osVersion = getWindowsVersion()
else:
if sys.platform == 'darwin':
from .macos.operations import * # @UnusedWildImport

View File

@ -99,7 +99,18 @@ def getDomainName():
def getWindowsVersion():
return win32api.GetVersionEx()
'''
Returns Windows version.
'''
import _winreg
reg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion')
try:
data = '{} {}'.format(_winreg.QueryValueEx(reg, 'ProductName')[0], _winreg.QueryValueEx(reg, 'ReleaseId')[0])
except Exception:
data = '{} {}'.format(_winreg.QueryValueEx(reg, 'ProductName')[0], _winreg.QueryValueEx(reg, 'CurrentBuildNumber')[0])
reg.Close()
return data
EWX_LOGOFF = 0x00000000
EWX_SHUTDOWN = 0x00000001
@ -136,6 +147,7 @@ def renameComputer(newName):
computerName = win32api.GetComputerNameEx(win32con.ComputerNamePhysicalDnsHostname)
raise Exception('Error renaming computer from {} to {}: {}'.format(computerName, newName, error))
NETSETUP_JOIN_DOMAIN = 0x00000001
NETSETUP_ACCT_CREATE = 0x00000002
NETSETUP_ACCT_DELETE = 0x00000004

View File

@ -3,13 +3,13 @@
Name "OpenGnsys Agent"
# OpenGnsys Actor version
!define OGA_VERSION 1.1.0
!define /file OGA_VERSION "src\VERSION"
# General Symbol Definitions
!define REGKEY "SOFTWARE\OGAgent"
!define VERSION ${OGA_VERSION}.0
!define COMPANY "OpenGnsys Project"
!define URL http://opengnsys.es
!define URL https://opengnsys.es
# MultiUser Symbol Definitions
!define MULTIUSER_EXECUTIONLEVEL Admin
@ -20,7 +20,6 @@ Name "OpenGnsys Agent"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path"
# MUI Symbol Definitions
#!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
!define MUI_ICON "src\img\oga.ico"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_UNICON "src\img\oga.ico"
@ -110,6 +109,10 @@ Section -post SEC0001
"1" "7" "1" "$INSTDIR\OGAgentService.exe" "" "" \
"" "" "" "" ""
Pop $0 ; return error(1)/success(0)
# Disable fast boot on Windows 10, if registry key exists.
ReadRegDWORD $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled
IfErrors 0 +2
WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled 0
# Install service
nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe --startup auto install" # Add service after installation
# Update recovery options
@ -156,8 +159,9 @@ Section -un.post UNSEC0001
SetShellVarContext all
RmDir /REBOOTOK $INSTDIR
SetRebootFlag true
MessageBox MB_OK|MB_USERICON "Your system needs to reboot to complete uninstallation."
Reboot # Reboot is needed after uninstalling, so new installs works fine
MessageBox MB_YESNO "$(^RebootMessage)" IDNO donotreboot
Reboot # Reboot is needed after uninstalling, so new installs works fine
donotreboot:
SectionEnd
# Installer functions
@ -182,3 +186,7 @@ LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)"
LangString ^UninstallLink ${LANG_FRENCH} "D<>sinstaller $(^Name)"
LangString ^UninstallLink ${LANG_GERMAN} "deinstallieren $(^Name)"
LangString ^RebootMessage ${LANG_ENGLISH} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will need to reboot."
LangString ^RebootMessage ${LANG_SPANISH} "¿Reiniciar el sistema para completar el proceso?$\nNota: es necesario reiniciar para instalar un nuevo $(^Name)."
LangString ^RebootMessage ${LANG_FRENCH} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will ned to reboot."
LangString ^RebootMessage ${LANG_GERMAN} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will ned to reboot."