From 4701ef77fd80831bdca9f328708fbeba810a7ef6 Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Tue, 21 Nov 2017 15:00:20 -0800 Subject: [PATCH] Readded network installers * Only installers for supported years have launchers created --- .bin/Scripts/Launch.cmd | 55 +++++++++++++++++++------- .bin/Scripts/functions/data.py | 67 +++++++++++++++++++------------- .bin/Scripts/functions/update.py | 24 ++++++++++++ .bin/Scripts/settings/main.py | 16 ++++---- .bin/Scripts/update_kit.py | 5 +++ .gitignore | 3 +- 6 files changed, 120 insertions(+), 50 deletions(-) diff --git a/.bin/Scripts/Launch.cmd b/.bin/Scripts/Launch.cmd index 6b95c37a..efcc37f7 100644 --- a/.bin/Scripts/Launch.cmd +++ b/.bin/Scripts/Launch.cmd @@ -121,19 +121,48 @@ rem set args and copy setup files to system rem NOTE: init_client_dir.cmd sets %client_dir% and creates %client_dir%\Office folder call "%bin%\Scripts\init_client_dir.cmd" /Office echo Copying setup file(s) for %L_ITEM%... -rem extract setup/xml and start installation -set "setup=%L_PATH%\setup.exe" -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 -"%systemroot%\System32\ping.exe" -n 2 127.0.0.1>nul -if not exist "!dest!\setup.exe" (goto ErrorOfficeSourceNotFound) -if not exist "!dest!\!L_ITEM!" (goto ErrorOfficeSourceNotFound) -pushd "!dest!" -rem # The line below jumps to ErrorUnknown even though setup.exe is run correctly?? -rem start "" "setup.exe" /configure !L_ITEM! || popd & goto ErrorUnknown -rem # Going to assume it extracted correctly and blindly start setup.exe -start "" "setup.exe" /configure !L_ITEM! -popd +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 + set "source=%L_PATH%\setup.exe" + set "dest=%client_dir%\Office\%L_PATH%" + "%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 + if not exist "!dest!\setup.exe" (goto ErrorOfficeSourceNotFound) + if not exist "!dest!\!L_ITEM!" (goto ErrorOfficeSourceNotFound) + pushd "!dest!" + rem # The line below jumps to ErrorUnknown even though setup.exe is run correctly?? + rem start "" "setup.exe" /configure !L_ITEM! || popd & goto ErrorUnknown + rem # Going to assume it extracted correctly and blindly start setup.exe + start "" "setup.exe" /configure !L_ITEM! + 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 :LaunchQuickBooksSetup diff --git a/.bin/Scripts/functions/data.py b/.bin/Scripts/functions/data.py index 62cc7b4d..fa324df5 100644 --- a/.bin/Scripts/functions/data.py +++ b/.bin/Scripts/functions/data.py @@ -164,28 +164,33 @@ def mount_backup_shares(): if server['Mounted']: continue - # Else, test connection - try: - ping(server['IP']) - except subprocess.CalledProcessError: - print_error( - r'Failed to mount \\{Name}\{Share}, {IP} unreachable.'.format( - **server)) - sleep(1) - continue # Continue to next server + mount_network_share(server) + - # Mount - cmd = r'net use \\{IP}\{Share} /user:{User} {Pass}'.format(**server) - cmd = cmd.split(' ') - try: - run_program(cmd) - except Exception: - print_warning(r'Failed to mount \\{Name}\{Share} ({IP})'.format( +def mount_network_share(server): + """Mount a network share defined by server.""" + # Test connection + try: + ping(server['IP']) + except subprocess.CalledProcessError: + print_error( + r'Failed to mount \\{Name}\{Share}, {IP} unreachable.'.format( **server)) - sleep(1) - else: - print_info('Mounted {Name}'.format(**server)) - server['Mounted'] = True + sleep(1) + return False + + # Mount + cmd = r'net use \\{IP}\{Share} /user:{User} {Pass}'.format(**server) + cmd = cmd.split(' ') + try: + run_program(cmd) + except Exception: + print_warning(r'Failed to mount \\{Name}\{Share} ({IP})'.format( + **server)) + sleep(1) + else: + print_info('Mounted {Name}'.format(**server)) + server['Mounted'] = True def run_fast_copy(items, dest): """Copy items to dest using FastCopy.""" @@ -560,14 +565,20 @@ def transfer_source(source_obj, dest_path, selected_items): def umount_backup_shares(): """Unnount the backup shares regardless of current status.""" for server in BACKUP_SERVERS: - try: - # Umount - run_program(r'net use \\{IP}\{Share} /delete'.format(**server)) - print_info('Umounted {Name}'.format(**server)) - server['Mounted'] = False - except Exception: - print_error(r'Failed to umount \\{Name}\{Share}.'.format(**server)) - sleep(1) + 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: + run_program(cmd) + except Exception: + print_error(r'Failed to umount \\{Name}\{Share}.'.format(**server)) + sleep(1) + else: + print_info('Umounted {Name}'.format(**server)) + server['Mounted'] = False def wim_contains(source_path, file_path): """Check if the WIM contains a file or folder.""" diff --git a/.bin/Scripts/functions/update.py b/.bin/Scripts/functions/update.py index cf3d4e3e..2f3474e1 100644 --- a/.bin/Scripts/functions/update.py +++ b/.bin/Scripts/functions/update.py @@ -3,6 +3,7 @@ import requests from functions.common import * +from functions.data import * from settings.launchers import * from settings.music import * from settings.sources import * @@ -156,6 +157,29 @@ def resolve_dynamic_url(source_url, regex): # Return 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 ## def update_testdisk(): # Stop running processes diff --git a/.bin/Scripts/settings/main.py b/.bin/Scripts/settings/main.py index d797f9c1..e8c828d4 100644 --- a/.bin/Scripts/settings/main.py +++ b/.bin/Scripts/settings/main.py @@ -39,14 +39,6 @@ CLIENT_INFO_SERVER = { 'Share': '/srv/ClientInfo', 'User': 'upload', } -QUICKBOOKS_SERVER = { - 'IP': QUICKBOOKS_SERVER_IP, - 'Name': 'ServerOne', - 'Mounted': False, - 'Share': 'QuickBooks', - 'User': 'restore', - 'Pass': 'Abracadabra', -} OFFICE_SERVER = { 'IP': OFFICE_SERVER_IP, 'Name': 'ServerOne', @@ -55,6 +47,14 @@ OFFICE_SERVER = { 'User': 'restore', 'Pass': 'Abracadabra', } +QUICKBOOKS_SERVER = { + 'IP': QUICKBOOKS_SERVER_IP, + 'Name': 'ServerOne', + 'Mounted': False, + 'Share': 'QuickBooks', + 'User': 'restore', + 'Pass': 'Abracadabra', +} WINDOWS_SERVER = { 'IP': '10.0.0.10', 'Name': 'ServerOne', diff --git a/.bin/Scripts/update_kit.py b/.bin/Scripts/update_kit.py index 3f5cc069..9aee428a 100644 --- a/.bin/Scripts/update_kit.py +++ b/.bin/Scripts/update_kit.py @@ -117,6 +117,11 @@ if __name__ == '__main__': width=40, 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 print_success('Generating launchers') for section in sorted(LAUNCHERS.keys()): diff --git a/.gitignore b/.gitignore index fb551c93..460518a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/__pycache__/* +*.bak *.exe .bin/7-Zip/ .bin/AIDA64/ @@ -35,4 +36,4 @@ .cbin/_Office/ .cbin/_vcredists/ .cbin/wimlib/ -OUT/ +OUT*/