Readded network installers

* Only installers for supported years have launchers created
This commit is contained in:
Alan Mason 2017-11-21 15:00:20 -08:00
parent 65d710b72f
commit 4701ef77fd
6 changed files with 120 additions and 50 deletions

View file

@ -121,10 +121,15 @@ rem set args and copy setup files to system
rem NOTE: init_client_dir.cmd sets %client_dir% and creates %client_dir%\Office folder rem NOTE: init_client_dir.cmd sets %client_dir% and creates %client_dir%\Office folder
call "%bin%\Scripts\init_client_dir.cmd" /Office call "%bin%\Scripts\init_client_dir.cmd" /Office
echo Copying setup file(s) for %L_ITEM%... echo Copying setup file(s) for %L_ITEM%...
rem NOTE: If L_PATH == "2013" or "2016" extract the ODT setup/xml, otherwise copy from OFFICE_SERVER
set "_odt=False"
if %L_PATH% equ 2013 (set "_odt=True")
if %L_PATH% equ 2016 (set "_odt=True")
if "%_odt%" == "True" (
rem extract setup/xml and start installation rem extract setup/xml and start installation
set "setup=%L_PATH%\setup.exe" set "source=%L_PATH%\setup.exe"
set "dest=%client_dir%\Office\%L_PATH%" set "dest=%client_dir%\Office\%L_PATH%"
"%SEVEN_ZIP%" e "%cbin%\_Office.7z" -aoa -bso0 -bse0 -p%ARCHIVE_PASSWORD% -o"!dest!" !setup! !L_ITEM! || exit /b 1 "%SEVEN_ZIP%" e "%cbin%\_Office.7z" -aoa -bso0 -bse0 -p%ARCHIVE_PASSWORD% -o"!dest!" !source! !L_ITEM! || exit /b 1
"%systemroot%\System32\ping.exe" -n 2 127.0.0.1>nul "%systemroot%\System32\ping.exe" -n 2 127.0.0.1>nul
if not exist "!dest!\setup.exe" (goto ErrorOfficeSourceNotFound) if not exist "!dest!\setup.exe" (goto ErrorOfficeSourceNotFound)
if not exist "!dest!\!L_ITEM!" (goto ErrorOfficeSourceNotFound) if not exist "!dest!\!L_ITEM!" (goto ErrorOfficeSourceNotFound)
@ -134,6 +139,30 @@ rem start "" "setup.exe" /configure !L_ITEM! || popd & goto ErrorUnknown
rem # Going to assume it extracted correctly and blindly start setup.exe rem # Going to assume it extracted correctly and blindly start setup.exe
start "" "setup.exe" /configure !L_ITEM! start "" "setup.exe" /configure !L_ITEM!
popd popd
) else (
rem copy setup files from OFFICE_SERVER
set "fastcopy_args=/cmd=diff /no_ui /auto_close"
set "product=%L_PATH%\%L_ITEM%"
set "product_name=%L_ITEM%"
call :GetBasename product_name || goto ErrorBasename
set "source=\\%OFFICE_SERVER%\Office\!product!"
set "dest=%client_dir%\Office"
rem Verify source
if not exist "!source!" (goto ErrorOfficeSourceNotFound)
rem Copy setup file(s) to system
start "" /wait "%FASTCOPY%" !fastcopy_args! "!source!" /to="!dest!\"
rem Run setup
if exist "!dest!\!product_name!\setup.exe" (
start "" "!dest!\!product_name!\setup.exe" || goto ErrorUnknown
) else if "!product_name:~-3,3!" == "exe" (
start "" "!dest!\!product_name!" || goto ErrorUnknown
) else if "!product_name:~-3,3!" == "msi" (
start "" "!dest!\!product_name!" || goto ErrorUnknown
) else (
rem Office source not supported by this script
goto ErrorOfficeUnsupported
)
)
goto Exit goto Exit
:LaunchQuickBooksSetup :LaunchQuickBooksSetup

View file

@ -164,7 +164,12 @@ def mount_backup_shares():
if server['Mounted']: if server['Mounted']:
continue continue
# Else, test connection mount_network_share(server)
def mount_network_share(server):
"""Mount a network share defined by server."""
# Test connection
try: try:
ping(server['IP']) ping(server['IP'])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@ -172,7 +177,7 @@ def mount_backup_shares():
r'Failed to mount \\{Name}\{Share}, {IP} unreachable.'.format( r'Failed to mount \\{Name}\{Share}, {IP} unreachable.'.format(
**server)) **server))
sleep(1) sleep(1)
continue # Continue to next server return False
# Mount # Mount
cmd = r'net use \\{IP}\{Share} /user:{User} {Pass}'.format(**server) cmd = r'net use \\{IP}\{Share} /user:{User} {Pass}'.format(**server)
@ -560,14 +565,20 @@ def transfer_source(source_obj, dest_path, selected_items):
def umount_backup_shares(): def umount_backup_shares():
"""Unnount the backup shares regardless of current status.""" """Unnount the backup shares regardless of current status."""
for server in BACKUP_SERVERS: for server in BACKUP_SERVERS:
umount_network_share(server)
def umount_network_share(server):
"""Unnount a network share defined by server."""
cmd = r'net use \\{IP}\{Share} /delete'.format(**server)
cmd = cmd.split(' ')
try: try:
# Umount run_program(cmd)
run_program(r'net use \\{IP}\{Share} /delete'.format(**server))
print_info('Umounted {Name}'.format(**server))
server['Mounted'] = False
except Exception: except Exception:
print_error(r'Failed to umount \\{Name}\{Share}.'.format(**server)) print_error(r'Failed to umount \\{Name}\{Share}.'.format(**server))
sleep(1) sleep(1)
else:
print_info('Umounted {Name}'.format(**server))
server['Mounted'] = False
def wim_contains(source_path, file_path): def wim_contains(source_path, file_path):
"""Check if the WIM contains a file or folder.""" """Check if the WIM contains a file or folder."""

View file

@ -3,6 +3,7 @@
import requests import requests
from functions.common import * from functions.common import *
from functions.data import *
from settings.launchers import * from settings.launchers import *
from settings.music import * from settings.music import *
from settings.sources import * from settings.sources import *
@ -156,6 +157,29 @@ def resolve_dynamic_url(source_url, regex):
# Return # Return
return url return url
def scan_for_net_installers(server, family_name, min_year):
if not server['Mounted']:
mount_network_share(server)
if server['Mounted']:
for year in os.scandir(r'\\{IP}\{Share}'.format(**server)):
if int(year.name) < min_year:
# Don't support outdated installers
continue
for version in os.scandir(year.path):
section = r'Installers\Extras\{}\{}'.format(
family_name, year.name)
if section not in LAUNCHERS:
LAUNCHERS[section] = {}
if version.name not in LAUNCHERS[section]:
LAUNCHERS[section][version.name] = {
'L_TYPE': family_name,
'L_PATH': year.name,
'L_ITEM': version.name,
'L_CHCK': 'True',
}
umount_network_share(server)
## Data Recovery ## ## Data Recovery ##
def update_testdisk(): def update_testdisk():
# Stop running processes # Stop running processes

View file

@ -39,14 +39,6 @@ CLIENT_INFO_SERVER = {
'Share': '/srv/ClientInfo', 'Share': '/srv/ClientInfo',
'User': 'upload', 'User': 'upload',
} }
QUICKBOOKS_SERVER = {
'IP': QUICKBOOKS_SERVER_IP,
'Name': 'ServerOne',
'Mounted': False,
'Share': 'QuickBooks',
'User': 'restore',
'Pass': 'Abracadabra',
}
OFFICE_SERVER = { OFFICE_SERVER = {
'IP': OFFICE_SERVER_IP, 'IP': OFFICE_SERVER_IP,
'Name': 'ServerOne', 'Name': 'ServerOne',
@ -55,6 +47,14 @@ OFFICE_SERVER = {
'User': 'restore', 'User': 'restore',
'Pass': 'Abracadabra', 'Pass': 'Abracadabra',
} }
QUICKBOOKS_SERVER = {
'IP': QUICKBOOKS_SERVER_IP,
'Name': 'ServerOne',
'Mounted': False,
'Share': 'QuickBooks',
'User': 'restore',
'Pass': 'Abracadabra',
}
WINDOWS_SERVER = { WINDOWS_SERVER = {
'IP': '10.0.0.10', 'IP': '10.0.0.10',
'Name': 'ServerOne', 'Name': 'ServerOne',

View file

@ -117,6 +117,11 @@ if __name__ == '__main__':
width=40, width=40,
item = item) item = item)
## Search for network Office/QuickBooks installers & add to LAUNCHERS
print_success('Scanning for network installers')
scan_for_net_installers(OFFICE_SERVER, 'Office', min_year=2010)
scan_for_net_installers(QUICKBOOKS_SERVER, 'QuickBooks', min_year=2015)
## Generate Launchers ## Generate Launchers
print_success('Generating launchers') print_success('Generating launchers')
for section in sorted(LAUNCHERS.keys()): for section in sorted(LAUNCHERS.keys()):

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
**/__pycache__/* **/__pycache__/*
*.bak
*.exe *.exe
.bin/7-Zip/ .bin/7-Zip/
.bin/AIDA64/ .bin/AIDA64/
@ -35,4 +36,4 @@
.cbin/_Office/ .cbin/_Office/
.cbin/_vcredists/ .cbin/_vcredists/
.cbin/wimlib/ .cbin/wimlib/
OUT/ OUT*/