From f7d55306bec2806a968961348b134bc4630b36d7 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 15:11:36 -0600 Subject: [PATCH 01/18] Adjusted packages * Added ARandR * Added GPicView * Added XArchiver * Switched to Evince over MuPDF --- .linux_items/packages/live_add | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.linux_items/packages/live_add b/.linux_items/packages/live_add index 0bf86276..a297ca05 100644 --- a/.linux_items/packages/live_add +++ b/.linux_items/packages/live_add @@ -1,6 +1,7 @@ aic94xx-firmware alsa-utils antiword +arandr arc-gtk-theme bash-pipes bc @@ -12,16 +13,19 @@ cmatrix colordiff compton conky +cpio curl dmidecode dos2unix dunst e2fsprogs +evince feh ffmpeg firefox gnome-keyring gparted +gpicview-gtk3 gsmartcontrol hardinfo hexedit @@ -33,17 +37,18 @@ i3status inxi ldns leafpad +lha libewf libinput linux-firmware lm_sensors +lzip mdadm mediainfo mesa-demos mkvtoolnix-cli mprime mpv -mupdf ncdu network-manager-applet networkmanager @@ -80,6 +85,8 @@ ttf-inconsolata udevil udisks2 ufw +unarj +unrar unzip util-linux veracrypt @@ -89,6 +96,7 @@ virtualbox-guest-utils volumeicon wd719x-firmware wimlib +xarchiver xf86-input-libinput xf86-video-amdgpu xf86-video-fbdev @@ -99,4 +107,5 @@ xorg-xdpyinfo xorg-xev xorg-xinit xorg-xinput +zip zsh From f1700e5ba9f15fca6635714938ca0646805bbd74 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 15:13:26 -0600 Subject: [PATCH 02/18] Adjusted app associations in Thunar --- .../airootfs/etc/skel/.config/mimeapps.list | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.linux_items/include/airootfs/etc/skel/.config/mimeapps.list b/.linux_items/include/airootfs/etc/skel/.config/mimeapps.list index e8beceeb..5b4a6b92 100644 --- a/.linux_items/include/airootfs/etc/skel/.config/mimeapps.list +++ b/.linux_items/include/airootfs/etc/skel/.config/mimeapps.list @@ -1,25 +1,27 @@ [Added Associations] -application/pdf=mupdf.desktop; +application/pdf=evince.desktop; application/vnd.adobe.flash.movie=mpv.desktop; application/vnd.ms-asf=mpv.desktop; +application/x-desktop=leafpad.desktop; audio/flac=mpv.desktop; audio/mp4=mpv.desktop; audio/mpeg=mpv.desktop; audio/x-vorbis+ogg=mpv.desktop; -image/bmp=ristretto.desktop; -image/gif=ristretto.desktop; -image/jpeg=ristretto.desktop; -image/png=ristretto.desktop; -image/vnd.microsoft.icon=ristretto.desktop; +image/bmp=gpicview.desktop; +image/gif=gpicview.desktop; +image/jpeg=gpicview.desktop; +image/png=gpicview.desktop; +image/vnd.microsoft.icon=gpicview.desktop; inode/directory=exo-file-manager.desktop -text/plain=mousepad.desktop; +text/plain=leafpad.desktop; +text/x-log=leafpad.desktop; video/mp4=mpv.desktop; video/mpeg=mpv.desktop; video/quicktime=mpv.desktop; video/x-flv=mpv.desktop; video/x-matroska=mpv.desktop; -video/x-msvideo=mpv.desktop; video/x-ms-wmv=mpv.desktop; +video/x-msvideo=mpv.desktop; x-scheme-handler/http=exo-web-browser.desktop x-scheme-handler/https=exo-web-browser.desktop x-scheme-handler/trash=exo-file-manager.desktop From 1c3520806caee4601a44b7c0d197cb6f2c4dbb2d Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 15:17:14 -0600 Subject: [PATCH 03/18] Avoid nohup.out creation --- .bin/Scripts/functions/hw_diags.py | 2 +- .bin/Scripts/mount-all-volumes | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 5da13e7b..1ece188c 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -503,7 +503,7 @@ def run_tests(tests): # Open log if not TESTS['NVMe/SMART']['Quick']: try: - popen_program(['nohup', 'leafpad', global_vars['LogFile']]) + popen_program(['nohup', 'leafpad', global_vars['LogFile']], pipe=True) except Exception: print_error('ERROR: Failed to open log: {}'.format( global_vars['LogFile'])) diff --git a/.bin/Scripts/mount-all-volumes b/.bin/Scripts/mount-all-volumes index fdc76046..b547e6b6 100755 --- a/.bin/Scripts/mount-all-volumes +++ b/.bin/Scripts/mount-all-volumes @@ -29,7 +29,7 @@ if __name__ == '__main__': print_standard('\nDone.') if 'gui' in sys.argv: pause("Press Enter to exit...") - popen_program(['nohup', 'thunar', '/media']) + popen_program(['nohup', 'thunar', '/media'], pipe=True) exit_script() except SystemExit: pass From 598dea32c7bbe1ef1c66b31552a20cd4b92c9f2a Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 15:32:38 -0600 Subject: [PATCH 04/18] Save logs to tech's $HOME instead of root's --- .bin/Scripts/build-ufd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bin/Scripts/build-ufd b/.bin/Scripts/build-ufd index 06ad45b9..c7e4df82 100755 --- a/.bin/Scripts/build-ufd +++ b/.bin/Scripts/build-ufd @@ -436,7 +436,7 @@ function ask() { # VARIABLES DEST_DEV="${arg_u}" DEST_PAR="${DEST_DEV}1" -LOG_FILE="${HOME}/build-ufd_${DEST_DEV##*/}_$(date +%Y-%m-%d_%H%M_%z).log" +LOG_FILE="$(getent passwd tech | cut -d: -f6)/build-ufd_${DEST_DEV##*/}_$(date +%Y-%m-%d_%H%M_%z).log" MAIN_PY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/settings/main.py" RSYNC_ARGS="-hrtuvS --modify-window=1 --progress" MAIN_KIT="$(realpath "${arg_m:-}" 2>/dev/null || true)" From 223155b8429fa5d5b8ec765c8d8d86c8bf9877a4 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 16:26:07 -0600 Subject: [PATCH 05/18] Abort on failed download(s) * Fixes #29 --- .bin/Scripts/build_kit.ps1 | 2 +- .bin/Scripts/build_pe.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/build_kit.ps1 b/.bin/Scripts/build_kit.ps1 index 778c6bb8..25373389 100644 --- a/.bin/Scripts/build_kit.ps1 +++ b/.bin/Scripts/build_kit.ps1 @@ -34,7 +34,7 @@ function DownloadFile ($Path, $Name, $Url) { } catch { Write-Host (" ERROR: Failed to download file." ) -ForegroundColor "Red" - $DownloadErrors += 1 + $global:DownloadErrors += 1 } } function FindDynamicUrl ($SourcePage, $RegEx) { diff --git a/.bin/Scripts/build_pe.ps1 b/.bin/Scripts/build_pe.ps1 index a040a207..e5a92de3 100644 --- a/.bin/Scripts/build_pe.ps1 +++ b/.bin/Scripts/build_pe.ps1 @@ -70,7 +70,7 @@ function DownloadFile ($Path, $Name, $Url) { } catch { Write-Host (" ERROR: Failed to download file." ) -ForegroundColor "Red" - $DownloadErrors += 1 + $global:DownloadErrors += 1 } } function FindDynamicUrl ($SourcePage, $RegEx) { From 5ea499d6ffd9b28e88ed3f64c37f5ce0425ea4ed Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 17:09:22 -0600 Subject: [PATCH 06/18] Assign volume letters before finding source image * Fixes issue #33 --- .bin/Scripts/functions/winpe_menus.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.bin/Scripts/functions/winpe_menus.py b/.bin/Scripts/functions/winpe_menus.py index bdbfc11c..750f88a0 100644 --- a/.bin/Scripts/functions/winpe_menus.py +++ b/.bin/Scripts/functions/winpe_menus.py @@ -264,13 +264,14 @@ def menu_setup(): windows_version = select_windows_version() # Find Windows image + # NOTE: Reassign volume letters to ensure all devices are scanned + try_and_print( + message = 'Assigning volume letters...', + function = assign_volume_letters, + other_results = other_results) windows_image = find_windows_image(windows_version) # Scan disks - try_and_print( - message = 'Assigning letters...', - function = assign_volume_letters, - other_results = other_results) result = try_and_print( message = 'Getting disk info...', function = scan_disks, From 3114b72178cf821234ebe5becb8792d10c30001e Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 17:57:45 -0600 Subject: [PATCH 07/18] Add ticket toggle var and get_simple_string func * get_simple_string() will be used for backup prefixes --- .bin/Scripts/functions/common.py | 11 +++++++++++ .bin/Scripts/settings/main.py | 1 + 2 files changed, 12 insertions(+) diff --git a/.bin/Scripts/functions/common.py b/.bin/Scripts/functions/common.py index 050205e7..ed1d1938 100644 --- a/.bin/Scripts/functions/common.py +++ b/.bin/Scripts/functions/common.py @@ -196,6 +196,8 @@ def extract_item(item, filter='', silent=False): def get_ticket_number(): """Get TicketNumber from user, save in LogDir, and return as str.""" + if not ENABLED_TICKET_NUMBERS: + return None ticket_number = None while ticket_number is None: _input = input('Enter ticket number: ') @@ -208,6 +210,15 @@ def get_ticket_number(): f.write(ticket_number) return ticket_number +def get_simple_string(prompt='Enter string'): + """Get string from user (only alphanumeric/space chars) and return as str.""" + simple_string = None + while simple_string is None: + _input = input('{}: '.format(prompt)) + if re.match(r'^(\w|-| )+$', _input, re.ASCII): + simple_string = _input.strip() + return simple_string + def human_readable_size(size, decimals=0): """Convert size in bytes to a human-readable format and return a str.""" # Prep string formatting diff --git a/.bin/Scripts/settings/main.py b/.bin/Scripts/settings/main.py index 86b0fcee..c49da96e 100644 --- a/.bin/Scripts/settings/main.py +++ b/.bin/Scripts/settings/main.py @@ -2,6 +2,7 @@ # Features ENABLED_UPLOAD_DATA = False +ENABLED_TICKET_NUMBERS = False # STATIC VARIABLES (also used by BASH and BATCH files) ## NOTE: There are no spaces around the = for easier parsing in BASH and BATCH From bec947262b8bd9147317a002d78dea588b9f4786 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 18:03:53 -0600 Subject: [PATCH 08/18] Updated WinPE sections --- .bin/Scripts/functions/backup.py | 6 +++--- .bin/Scripts/functions/winpe_menus.py | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.bin/Scripts/functions/backup.py b/.bin/Scripts/functions/backup.py index fe0935fb..a787a0ed 100644 --- a/.bin/Scripts/functions/backup.py +++ b/.bin/Scripts/functions/backup.py @@ -32,7 +32,7 @@ def fix_path(path): """Replace invalid filename characters with underscores.""" return REGEX_BAD_PATH_NAMES.sub('_', path) -def prep_disk_for_backup(destination, disk, ticket_number): +def prep_disk_for_backup(destination, disk, backup_prefix): """Gather details about the disk and its partitions. This includes partitions that can't be backed up, @@ -71,10 +71,10 @@ def prep_disk_for_backup(destination, disk, ticket_number): par['Image Name'] = par['Name'] if par['Name'] else 'Unknown' if 'IP' in destination: par['Image Path'] = r'\\{}\{}\{}'.format( - destination['IP'], destination['Share'], ticket_number) + destination['IP'], destination['Share'], backup_prefix) else: par['Image Path'] = r'{}:\{}'.format( - ticket_number, destination['Letter']) + destination['Letter'], backup_prefix) par['Image Path'] += r'\{}_{}.wim'.format( par['Number'], par['Image Name']) par['Image Path'] = fix_path(par['Image Path']) diff --git a/.bin/Scripts/functions/winpe_menus.py b/.bin/Scripts/functions/winpe_menus.py index 750f88a0..c5d6dd99 100644 --- a/.bin/Scripts/functions/winpe_menus.py +++ b/.bin/Scripts/functions/winpe_menus.py @@ -75,10 +75,14 @@ def menu_backup(): }} set_title('{}: Backup Menu'.format(KIT_NAME_FULL)) - # Set ticket Number + # Set backup prefix clear_screen() print_standard('{}\n'.format(global_vars['Title'])) ticket_number = get_ticket_number() + if ENABLED_TICKET_NUMBERS: + backup_prefix = ticket_number + else: + backup_prefix = get_simple_string(prompt='Enter backup name prefix') # Mount backup shares mount_backup_shares(read_write=True) @@ -107,12 +111,13 @@ def menu_backup(): raise GenericAbort # "Prep" disk - prep_disk_for_backup(destination, disk, ticket_number) + prep_disk_for_backup(destination, disk, dest_prefix) # Display details for backup task clear_screen() print_info('Create Backup - Details:\n') - show_data(message='Ticket:', data=ticket_number) + if ENABLED_TICKET_NUMBERS: + show_data(message='Ticket:', data=ticket_number) show_data( message = 'Source:', data = '[{}] ({}) {} {}'.format( @@ -293,7 +298,8 @@ def menu_setup(): # Display details for setup task clear_screen() print_info('Setup Windows - Details:\n') - show_data(message='Ticket:', data=ticket_number) + if ENABLED_TICKET_NUMBERS: + show_data(message='Ticket:', data=ticket_number) show_data(message='Installing:', data=windows_version['Name']) show_data( message = 'Boot Method:', From db09236b262ac35a7f7ea7a9f6a87123e624e791 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 18:06:26 -0600 Subject: [PATCH 09/18] Updated user_data_transfer sections --- .bin/Scripts/functions/data.py | 40 +++++++++++++++--------------- .bin/Scripts/user_data_transfer.py | 15 +++++++++-- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/.bin/Scripts/functions/data.py b/.bin/Scripts/functions/data.py index 93ab07ce..5e06a188 100644 --- a/.bin/Scripts/functions/data.py +++ b/.bin/Scripts/functions/data.py @@ -534,21 +534,21 @@ def select_destination(folder_path, prompt='Select destination'): return path -def select_source(ticket_number): - """Select backup from those found on the BACKUP_SERVERS for the ticket.""" +def select_source(backup_prefix): + """Select backup from those found on the BACKUP_SERVERS matching the prefix.""" selected_source = None local_sources = [] remote_sources = [] sources = [] mount_backup_shares(read_write=False) - # Check for ticket folders on servers + # Check for prefix folders on servers for server in BACKUP_SERVERS: if server['Mounted']: print_standard('Scanning {}...'.format(server['Name'])) for d in os.scandir(r'\\{IP}\{Share}'.format(**server)): if (d.is_dir() - and d.name.lower().startswith(ticket_number.lower())): + and d.name.lower().startswith(backup_prefix.lower())): # Add folder to remote_sources remote_sources.append({ 'Name': '{:9}| File-Based: [DIR] {}'.format( @@ -558,19 +558,19 @@ def select_source(ticket_number): 'Source': d}) # Check for images and subfolders - for ticket_path in remote_sources.copy(): - for item in os.scandir(ticket_path['Source'].path): + for prefix_path in remote_sources.copy(): + for item in os.scandir(prefix_path['Source'].path): if item.is_dir(): # Add folder to remote_sources remote_sources.append({ 'Name': r'{:9}| File-Based: [DIR] {}\{}'.format( - ticket_path['Server']['Name'], # Server - ticket_path['Source'].name, # Ticket folder + prefix_path['Server']['Name'], # Server + prefix_path['Source'].name, # Prefix folder item.name, # Sub-folder ), - 'Server': ticket_path['Server'], + 'Server': prefix_path['Server'], 'Sort': r'{}\{}'.format( - ticket_path['Source'].name, # Ticket folder + prefix_path['Source'].name, # Prefix folder item.name, # Sub-folder ), 'Source': item}) @@ -586,15 +586,15 @@ def select_source(ticket_number): remote_sources.append({ 'Disabled': bool(not is_valid_wim_file(subitem)), 'Name': r'{:9}| Image-Based: {:>7} {}\{}\{}'.format( - ticket_path['Server']['Name'], # Server + prefix_path['Server']['Name'], # Server size, # Size (duh) - ticket_path['Source'].name, # Ticket folder + prefix_path['Source'].name, # Prefix folder item.name, # Sub-folder subitem.name, # Image file ), - 'Server': ticket_path['Server'], + 'Server': prefix_path['Server'], 'Sort': r'{}\{}\{}'.format( - ticket_path['Source'].name, # Ticket folder + prefix_path['Source'].name, # Prefix folder item.name, # Sub-folder subitem.name, # Image file ), @@ -608,14 +608,14 @@ def select_source(ticket_number): remote_sources.append({ 'Disabled': bool(not is_valid_wim_file(item)), 'Name': r'{:9}| Image-Based: {:>7} {}\{}'.format( - ticket_path['Server']['Name'], # Server + prefix_path['Server']['Name'], # Server size, # Size (duh) - ticket_path['Source'].name, # Ticket folder + prefix_path['Source'].name, # Prefix folder item.name, # Image file ), - 'Server': ticket_path['Server'], + 'Server': prefix_path['Server'], 'Sort': r'{}\{}'.format( - ticket_path['Source'].name, # Ticket folder + prefix_path['Source'].name, # Prefix folder item.name, # Image file ), 'Source': item}) @@ -682,8 +682,8 @@ def select_source(ticket_number): else: selected_source = sources[int(selection)-1]['Source'] else: - print_error('ERROR: No backups found for ticket: {}.'.format( - ticket_number)) + print_error('ERROR: No backups found using prefix: {}.'.format( + backup_prefix)) umount_backup_shares() pause("Press Enter to exit...") exit_script() diff --git a/.bin/Scripts/user_data_transfer.py b/.bin/Scripts/user_data_transfer.py index 1c787cfe..e0339f20 100644 --- a/.bin/Scripts/user_data_transfer.py +++ b/.bin/Scripts/user_data_transfer.py @@ -18,17 +18,28 @@ if __name__ == '__main__': stay_awake() clear_screen() print_info('{}: User Data Transfer Tool\n'.format(KIT_NAME_FULL)) + + # Get backup name prefix ticket_number = get_ticket_number() + if ENABLED_TICKET_NUMBERS: + backup_prefix = ticket_number + else: + backup_prefix = get_simple_string(prompt='Enter backup name prefix') + + # Set destination folder_path = r'{}\Transfer'.format(KIT_NAME_SHORT) dest = select_destination(folder_path=folder_path, prompt='Which disk are we transferring to?') - source = select_source(ticket_number) + + # Set source items + source = select_source(backup_prefix) items = scan_source(source, dest) # Transfer clear_screen() print_info('Transfer Details:\n') - show_data('Ticket:', ticket_number) + if ENABLED_TICKET_NUMBERS: + show_data('Ticket:', ticket_number) show_data('Source:', source.path) show_data('Destination:', dest) From 02054a804711800fefb4fd09a7139f36d9329a6e Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 18:07:18 -0600 Subject: [PATCH 10/18] Updated system checklist and diagnostic scripts --- .bin/Scripts/system_checklist.py | 7 +++++-- .bin/Scripts/system_diagnostics.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.bin/Scripts/system_checklist.py b/.bin/Scripts/system_checklist.py index e0f217ed..c24e9fb1 100644 --- a/.bin/Scripts/system_checklist.py +++ b/.bin/Scripts/system_checklist.py @@ -29,8 +29,11 @@ if __name__ == '__main__': 'FileNotFoundError': 'File not found', }, 'Warning': {}} - print_info('Starting System Checklist for Ticket #{}\n'.format( - ticket_number)) + if ENABLED_TICKET_NUMBERS: + print_info('Starting System Checklist for Ticket #{}\n'.format( + ticket_number)) + else: + print_info('Starting System Checklist\n') # Configure print_info('Configure') diff --git a/.bin/Scripts/system_diagnostics.py b/.bin/Scripts/system_diagnostics.py index 59e31465..518eee8c 100644 --- a/.bin/Scripts/system_diagnostics.py +++ b/.bin/Scripts/system_diagnostics.py @@ -31,8 +31,11 @@ if __name__ == '__main__': 'GenericRepair': 'Repaired', 'UnsupportedOSError': 'Unsupported OS', }} - print_info('Starting System Diagnostics for Ticket #{}\n'.format( - ticket_number)) + if ENABLED_TICKET_NUMBERS: + print_info('Starting System Diagnostics for Ticket #{}\n'.format( + ticket_number)) + else: + print_info('Starting System Diagnostics\n') # Sanitize Environment print_info('Sanitizing Environment') From 5902a51f9e4f3fc34e5ba37be806edb8023a7e60 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 18:15:39 -0600 Subject: [PATCH 11/18] Save build-ufd logs in ${SUDO_USER}'s $HOME/Logs --- .bin/Scripts/build-ufd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bin/Scripts/build-ufd b/.bin/Scripts/build-ufd index c7e4df82..a94bfe20 100755 --- a/.bin/Scripts/build-ufd +++ b/.bin/Scripts/build-ufd @@ -436,13 +436,14 @@ function ask() { # VARIABLES DEST_DEV="${arg_u}" DEST_PAR="${DEST_DEV}1" -LOG_FILE="$(getent passwd tech | cut -d: -f6)/build-ufd_${DEST_DEV##*/}_$(date +%Y-%m-%d_%H%M_%z).log" +LOG_FILE="$(getent passwd "$SUDO_USER" | cut -d: -f6)/Logs/build-ufd_${DEST_DEV##*/}_$(date +%Y-%m-%d_%H%M_%z).log" MAIN_PY="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/settings/main.py" RSYNC_ARGS="-hrtuvS --modify-window=1 --progress" MAIN_KIT="$(realpath "${arg_m:-}" 2>/dev/null || true)" LINUX_ISO="$(realpath "${arg_l:-}" 2>/dev/null || true)" WINPE_ISO="$(realpath "${arg_w:-}" 2>/dev/null || true)" EXTRA_DIR="$(realpath "${arg_e:-}" 2>/dev/null || true)" +mkdir -p "$(dirname "$LOG_FILE")" # COLORS CLEAR="\e[0m" From b997a523853c62c2452d8281ade11b586fc2831f Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 18:17:36 -0600 Subject: [PATCH 12/18] Updated hw-diags section * Use date_time instead of ticket_number if disabled --- .bin/Scripts/functions/hw_diags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 1ece188c..63942ed2 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -125,9 +125,9 @@ def menu_diags(*args): if diag_modes[int(selection)-1]['Name'] != 'Quick drive test': # Save log for non-quick tests ticket_number = get_ticket_number() - global_vars['LogDir'] = '{}/Tickets/{}'.format( + global_vars['LogDir'] = '{}/Logs/{}'.format( global_vars['Env']['HOME'], - ticket_number) + ticket_number if ticket_number else global_vars['Date-Time']) os.makedirs(global_vars['LogDir'], exist_ok=True) global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format( global_vars['LogDir']) From 27953bde5acdb45283ec4dfcabce518415c7f761 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 20:54:45 -0600 Subject: [PATCH 13/18] Update backup/restore code * Added support for local backups * Added volume label detection for local backups * Replace spaces in backup_prefix with underscores --- .bin/Scripts/functions/backup.py | 51 +++++++++++++++++++++++++-- .bin/Scripts/functions/winpe_menus.py | 13 ++++--- .bin/Scripts/user_data_transfer.py | 1 + 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/.bin/Scripts/functions/backup.py b/.bin/Scripts/functions/backup.py index a787a0ed..e33cea2c 100644 --- a/.bin/Scripts/functions/backup.py +++ b/.bin/Scripts/functions/backup.py @@ -1,5 +1,7 @@ # Wizard Kit: Functions - Backup +import ctypes + from functions.disk import * # Regex @@ -30,7 +32,39 @@ def backup_partition(disk, par): def fix_path(path): """Replace invalid filename characters with underscores.""" - return REGEX_BAD_PATH_NAMES.sub('_', path) + local_drive = path[1:2] == ':' + new_path = REGEX_BAD_PATH_NAMES.sub('_', path) + if local_drive: + new_path = '{}:{}'.format(new_path[0:1], new_path[2:]) + return new_path + +def get_volume_display_name(mountpoint): + """Get display name from volume mountpoint and label, returns str.""" + name = mountpoint + try: + kernel32 = ctypes.windll.kernel32 + vol_name_buffer = ctypes.create_unicode_buffer(1024) + fs_name_buffer = ctypes.create_unicode_buffer(1024) + serial_number = None + max_component_length = None + file_system_flags = None + + vol_info = kernel32.GetVolumeInformationW( + ctypes.c_wchar_p(mountpoint), + vol_name_buffer, + ctypes.sizeof(vol_name_buffer), + serial_number, + max_component_length, + file_system_flags, + fs_name_buffer, + ctypes.sizeof(fs_name_buffer) + ) + + name = '{} "{}"'.format(name, vol_name_buffer.value) + except: + pass + + return name def prep_disk_for_backup(destination, disk, backup_prefix): """Gather details about the disk and its partitions. @@ -114,7 +148,20 @@ def select_backup_destination(auto_select=True): actions = [ {'Name': 'Main Menu', 'Letter': 'M'}, ] - + + # Add local disks + for d in psutil.disk_partitions(): + if re.search(r'^{}'.format(global_vars['Env']['SYSTEMDRIVE']), d.mountpoint, re.IGNORECASE): + # Skip current OS drive + pass + elif 'fixed' in d.opts: + # Skip DVD, etc + destinations.append({ + 'Name': 'Local Disk - {}'.format( + get_volume_display_name(d.mountpoint)), + 'Letter': re.sub(r'^(\w):\\.*$', r'\1', d.mountpoint), + }) + # Size check for dest in destinations: if 'IP' in dest: diff --git a/.bin/Scripts/functions/winpe_menus.py b/.bin/Scripts/functions/winpe_menus.py index c5d6dd99..6d8d10bc 100644 --- a/.bin/Scripts/functions/winpe_menus.py +++ b/.bin/Scripts/functions/winpe_menus.py @@ -83,7 +83,14 @@ def menu_backup(): backup_prefix = ticket_number else: backup_prefix = get_simple_string(prompt='Enter backup name prefix') + backup_prefix = backup_prefix.replace(' ', '_') + # Assign drive letters + try_and_print( + message = 'Assigning letters...', + function = assign_volume_letters, + other_results = other_results) + # Mount backup shares mount_backup_shares(read_write=True) @@ -91,10 +98,6 @@ def menu_backup(): destination = select_backup_destination(auto_select=False) # Scan disks - try_and_print( - message = 'Assigning letters...', - function = assign_volume_letters, - other_results = other_results) result = try_and_print( message = 'Getting disk info...', function = scan_disks, @@ -111,7 +114,7 @@ def menu_backup(): raise GenericAbort # "Prep" disk - prep_disk_for_backup(destination, disk, dest_prefix) + prep_disk_for_backup(destination, disk, backup_prefix) # Display details for backup task clear_screen() diff --git a/.bin/Scripts/user_data_transfer.py b/.bin/Scripts/user_data_transfer.py index e0339f20..ce572f69 100644 --- a/.bin/Scripts/user_data_transfer.py +++ b/.bin/Scripts/user_data_transfer.py @@ -25,6 +25,7 @@ if __name__ == '__main__': backup_prefix = ticket_number else: backup_prefix = get_simple_string(prompt='Enter backup name prefix') + backup_prefix = backup_prefix.replace(' ', '_') # Set destination folder_path = r'{}\Transfer'.format(KIT_NAME_SHORT) From e305b3e60f91ef1d860d0e1a45fbc3756330dd4f Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 20:56:55 -0600 Subject: [PATCH 14/18] Add warning for missing archive in extract_item() --- .bin/Scripts/functions/common.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bin/Scripts/functions/common.py b/.bin/Scripts/functions/common.py index ed1d1938..f5a2ef95 100644 --- a/.bin/Scripts/functions/common.py +++ b/.bin/Scripts/functions/common.py @@ -190,6 +190,9 @@ def extract_item(item, filter='', silent=False): print_standard('Extracting "{item}"...'.format(item=item)) try: run_program(cmd) + except FileNotFoundError: + if not silent: + print_warning('WARNING: Archive not found') except subprocess.CalledProcessError: if not silent: print_warning('WARNING: Errors encountered while exctracting data') From 50a200535e99c51bca1179b7d007005bca687cb6 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 20:59:57 -0600 Subject: [PATCH 15/18] Fix log dir permissions --- .bin/Scripts/build-ufd | 1 + 1 file changed, 1 insertion(+) diff --git a/.bin/Scripts/build-ufd b/.bin/Scripts/build-ufd index a94bfe20..cabc7ba0 100755 --- a/.bin/Scripts/build-ufd +++ b/.bin/Scripts/build-ufd @@ -444,6 +444,7 @@ LINUX_ISO="$(realpath "${arg_l:-}" 2>/dev/null || true)" WINPE_ISO="$(realpath "${arg_w:-}" 2>/dev/null || true)" EXTRA_DIR="$(realpath "${arg_e:-}" 2>/dev/null || true)" mkdir -p "$(dirname "$LOG_FILE")" +chown "$SUDO_USER:$SUDO_USER" -R "$(dirname "$LOG_FILE")" # COLORS CLEAR="\e[0m" From 1d3be750b44a589c6c6b019405a62e6fc69a450f Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 21:39:33 -0600 Subject: [PATCH 16/18] Bump tool versions --- .bin/Scripts/build_kit.ps1 | 10 +++++----- .bin/Scripts/build_pe.ps1 | 26 +++++++++++++------------- .bin/Scripts/settings/sources.py | 7 ++++--- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.bin/Scripts/build_kit.ps1 b/.bin/Scripts/build_kit.ps1 index 25373389..dafaa2c8 100644 --- a/.bin/Scripts/build_kit.ps1 +++ b/.bin/Scripts/build_kit.ps1 @@ -78,11 +78,11 @@ if ($MyInvocation.InvocationName -ne ".") { $Path = $Temp # 7-Zip - DownloadFile -Path $Path -Name "7z-installer.msi" -Url "http://www.7-zip.org/a/7z1801.msi" - DownloadFile -Path $Path -Name "7z-extra.7z" -Url "http://www.7-zip.org/a/7z1801-extra.7z" + DownloadFile -Path $Path -Name "7z-installer.msi" -Url "https://www.7-zip.org/a/7z1805.msi" + DownloadFile -Path $Path -Name "7z-extra.7z" -Url "https://www.7-zip.org/a/7z1805-extra.7z" # ConEmu - $Url = "https://github.com/Maximus5/ConEmu/releases/download/v18.02.06/ConEmuPack.180206.7z" + $Url = "https://github.com/Maximus5/ConEmu/releases/download/v18.05.06/ConEmuPack.180506.7z" DownloadFile -Path $Path -Name "ConEmuPack.7z" -Url $Url # Notepad++ @@ -90,9 +90,9 @@ if ($MyInvocation.InvocationName -ne ".") { DownloadFile -Path $Path -Name "npp.7z" -Url $Url # Python - $Url = "https://www.python.org/ftp/python/3.6.4/python-3.6.4-embed-win32.zip" + $Url = "https://www.python.org/ftp/python/3.6.5/python-3.6.5-embed-win32.zip" DownloadFile -Path $Path -Name "python32.zip" -Url $Url - $Url = "https://www.python.org/ftp/python/3.6.4/python-3.6.4-embed-amd64.zip" + $Url = "https://www.python.org/ftp/python/3.6.5/python-3.6.5-embed-amd64.zip" DownloadFile -Path $Path -Name "python64.zip" -Url $Url # Python: psutil diff --git a/.bin/Scripts/build_pe.ps1 b/.bin/Scripts/build_pe.ps1 index e5a92de3..e2f614c4 100644 --- a/.bin/Scripts/build_pe.ps1 +++ b/.bin/Scripts/build_pe.ps1 @@ -130,16 +130,16 @@ if ($MyInvocation.InvocationName -ne ".") { ## Download Tools ## $ToolSources = @( # 7-Zip - @("7z-installer.msi", "http://www.7-zip.org/a/7z1801.msi"), - @("7z-extra.7z", "http://www.7-zip.org/a/7z1801-extra.7z"), + @("7z-installer.msi", "https://www.7-zip.org/a/7z1805.msi"), + @("7z-extra.7z", "https://www.7-zip.org/a/7z1805-extra.7z"), # Blue Screen View - @("bluescreenview64.zip", "http://www.nirsoft.net/utils/bluescreenview-x64.zip"), @("bluescreenview32.zip", "http://www.nirsoft.net/utils/bluescreenview.zip"), + @("bluescreenview64.zip", "http://www.nirsoft.net/utils/bluescreenview-x64.zip"), # ConEmu - @("ConEmuPack.7z", "https://github.com/Maximus5/ConEmu/releases/download/v18.02.06/ConEmuPack.180206.7z"), + @("ConEmuPack.7z", "https://github.com/Maximus5/ConEmu/releases/download/v18.05.06/ConEmuPack.180506.7z"), # Fast Copy - @("fastcopy64.zip", "http://ftp.vector.co.jp/69/93/2323/FastCopy341_x64.zip"), @("fastcopy32.zip", "http://ftp.vector.co.jp/69/93/2323/FastCopy341.zip"), + @("fastcopy64.zip", "http://ftp.vector.co.jp/69/93/2323/FastCopy341_x64.zip"), # HWiNFO @("hwinfo.zip", "http://app.oldfoss.com:81/download/HWiNFO/hwi_582.zip"), # Killer Network Drivers @@ -148,19 +148,19 @@ if ($MyInvocation.InvocationName -ne ".") { ("http://www.killernetworking.com"+(FindDynamicUrl "http://www.killernetworking.com/driver-downloads/item/killer-drivers-inf" "Download Killer-Ethernet").replace('&', '&')) ), # Notepad++ - @("npp_amd64.7z", "https://notepad-plus-plus.org/repository/7.x/7.5.6/npp.7.5.6.bin.minimalist.x64.7z"), @("npp_x86.7z", "https://notepad-plus-plus.org/repository/7.x/7.5.6/npp.7.5.6.bin.minimalist.7z"), + @("npp_amd64.7z", "https://notepad-plus-plus.org/repository/7.x/7.5.6/npp.7.5.6.bin.minimalist.x64.7z"), # NT Password Editor @("ntpwed.zip", "http://cdslow.org.ru/files/ntpwedit/ntpwed07.zip"), # Prime95 - @("prime95_64.zip", "http://www.mersenne.org/ftp_root/gimps/p95v294b8.win64.zip"), @("prime95_32.zip", "http://www.mersenne.org/ftp_root/gimps/p95v294b7.win32.zip"), + @("prime95_64.zip", "http://www.mersenne.org/ftp_root/gimps/p95v294b8.win64.zip"), # ProduKey - @("produkey64.zip", "http://www.nirsoft.net/utils/produkey-x64.zip"), @("produkey32.zip", "http://www.nirsoft.net/utils/produkey.zip"), + @("produkey64.zip", "http://www.nirsoft.net/utils/produkey-x64.zip"), # Python - @("python64.zip", "https://www.python.org/ftp/python/3.6.4/python-3.6.4-embed-amd64.zip"), - @("python32.zip", "https://www.python.org/ftp/python/3.6.4/python-3.6.4-embed-win32.zip"), + @("python32.zip", "https://www.python.org/ftp/python/3.6.5/python-3.6.5-embed-win32.zip"), + @("python64.zip", "https://www.python.org/ftp/python/3.6.5/python-3.6.5-embed-amd64.zip"), # Python: psutil @( "psutil64.whl", @@ -171,14 +171,14 @@ if ($MyInvocation.InvocationName -ne ".") { (FindDynamicUrl "https://pypi.org/project/psutil/" "href=.*-cp36-cp36m-win32.whl") ), # Q-Dir - @("qdir64.zip", "https://www.softwareok.com/Download/Q-Dir_Portable_x64.zip"), @("qdir32.zip", "https://www.softwareok.com/Download/Q-Dir_Portable.zip"), + @("qdir64.zip", "https://www.softwareok.com/Download/Q-Dir_Portable_x64.zip"), # TestDisk / PhotoRec - @("testdisk64.zip", "https://www.cgsecurity.org/testdisk-7.1-WIP.win64.zip"), @("testdisk32.zip", "https://www.cgsecurity.org/testdisk-7.1-WIP.win.zip"), + @("testdisk64.zip", "https://www.cgsecurity.org/testdisk-7.1-WIP.win64.zip"), # wimlib-imagex - @("wimlib64.zip", "https://wimlib.net/downloads/wimlib-1.12.0-windows-x86_64-bin.zip"), @("wimlib32.zip", "https://wimlib.net/downloads/wimlib-1.12.0-windows-i686-bin.zip") + @("wimlib64.zip", "https://wimlib.net/downloads/wimlib-1.12.0-windows-x86_64-bin.zip"), ) foreach ($Tool in $ToolSources) { DownloadFile -Path $Temp -Name $Tool[0] -Url $Tool[1] diff --git a/.bin/Scripts/settings/sources.py b/.bin/Scripts/settings/sources.py index 2dddc86c..f1782ded 100644 --- a/.bin/Scripts/settings/sources.py +++ b/.bin/Scripts/settings/sources.py @@ -2,7 +2,7 @@ SOURCE_URLS = { 'AIDA64': 'http://download.aida64.com/aida64engineer597.zip', - 'Adobe Reader DC': 'http://ardownload.adobe.com/pub/adobe/reader/win/AcrobatDC/1801120035/AcroRdrDC1801120035_en_US.exe', + 'Adobe Reader DC': 'http://ardownload.adobe.com/pub/adobe/reader/win/AcrobatDC/1801120040/AcroRdrDC1801120040_en_US.exe', 'AdwCleaner': 'https://toolslib.net/downloads/finish/1-adwcleaner/', 'Autoruns': 'https://download.sysinternals.com/files/Autoruns.zip', 'BleachBit': 'https://download.bleachbit.org/BleachBit-2.0-portable.zip', @@ -16,7 +16,7 @@ SOURCE_URLS = { 'Everything64': 'https://www.voidtools.com/Everything-1.4.1.895.x64.zip', 'FastCopy32': 'http://ftp.vector.co.jp/69/93/2323/FastCopy341.zip', 'FastCopy64': 'http://ftp.vector.co.jp/69/93/2323/FastCopy341_x64.zip', - 'Firefox uBO': 'https://addons.cdn.mozilla.net/user-media/addons/607454/ublock_origin-1.15.10-an+fx.xpi?filehash=sha256%3A30b258803fd6cd988c5ba479f2f6ff5b4e9b40110c81e3421a6867b20ec718a6', + 'Firefox uBO': 'https://addons.mozilla.org/firefox/downloads/file/956394/ublock_origin-1.16.6-an+fx.xpi', 'HWiNFO': 'http://app.oldfoss.com:81/download/HWiNFO/hwi_582.zip', 'HitmanPro32': 'https://dl.surfright.nl/HitmanPro.exe', 'HitmanPro64': 'https://dl.surfright.nl/HitmanPro_x64.exe', @@ -25,7 +25,7 @@ SOURCE_URLS = { 'KVRT': 'http://devbuilds.kaspersky-labs.com/devbuilds/KVRT/latest/full/KVRT.exe', 'NotepadPlusPlus': 'https://notepad-plus-plus.org/repository/7.x/7.5.6/npp.7.5.6.bin.minimalist.7z', 'Office Deployment Tool 2013': 'https://download.microsoft.com/download/6/2/3/6230F7A2-D8A9-478B-AC5C-57091B632FCF/officedeploymenttool_x86_4827-1000.exe', - 'Office Deployment Tool 2016': 'https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_8529.3600.exe', + 'Office Deployment Tool 2016': 'https://download.microsoft.com/download/2/7/A/27AF1BE6-DD20-4CB4-B154-EBAB8A7D4A7E/officedeploymenttool_9326.3600.exe', 'ProduKey32': 'http://www.nirsoft.net/utils/produkey.zip', 'ProduKey64': 'http://www.nirsoft.net/utils/produkey-x64.zip', 'PuTTY': 'https://the.earth.li/~sgtatham/putty/latest/w32/putty.zip', @@ -196,6 +196,7 @@ RST_SOURCES = { 'SetupRST_14.8.exe': 'https://downloadmirror.intel.com/26759/eng/setuprst.exe', 'SetupRST_15.8.exe': 'https://downloadmirror.intel.com/27442/eng/SetupRST.exe', 'SetupRST_15.9.exe': 'https://downloadmirror.intel.com/27400/eng/SetupRST.exe', + 'SetupRST_16.0.exe': 'https://downloadmirror.intel.com/27681/eng/SetupRST.exe', } From 7e8f9df87786fcc9f7f4b667309388c70754a8f5 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 21:40:44 -0600 Subject: [PATCH 17/18] Set Intel RST 16.0 as current release --- .bin/Scripts/settings/launchers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/settings/launchers.py b/.bin/Scripts/settings/launchers.py index fa65c06e..1875ccc7 100644 --- a/.bin/Scripts/settings/launchers.py +++ b/.bin/Scripts/settings/launchers.py @@ -294,8 +294,8 @@ LAUNCHERS = { 'Intel RST (Current Release)': { 'L_TYPE': 'Executable', 'L_PATH': '_Drivers\Intel RST', - 'L_ITEM': 'SetupRST_15.9.exe', - 'L_7ZIP': 'SetupRST_15.9.exe', + 'L_ITEM': 'SetupRST_16.0.exe', + 'L_7ZIP': 'SetupRST_16.0.exe', }, 'Intel RST (Previous Releases)': { 'L_TYPE': 'Folder', From 352bf042b0b8162324821f85c9f856463a4df0d7 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Thu, 17 May 2018 21:47:56 -0600 Subject: [PATCH 18/18] Fixed typo --- .bin/Scripts/build_pe.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/build_pe.ps1 b/.bin/Scripts/build_pe.ps1 index e2f614c4..7329aa82 100644 --- a/.bin/Scripts/build_pe.ps1 +++ b/.bin/Scripts/build_pe.ps1 @@ -177,8 +177,8 @@ if ($MyInvocation.InvocationName -ne ".") { @("testdisk32.zip", "https://www.cgsecurity.org/testdisk-7.1-WIP.win.zip"), @("testdisk64.zip", "https://www.cgsecurity.org/testdisk-7.1-WIP.win64.zip"), # wimlib-imagex - @("wimlib32.zip", "https://wimlib.net/downloads/wimlib-1.12.0-windows-i686-bin.zip") - @("wimlib64.zip", "https://wimlib.net/downloads/wimlib-1.12.0-windows-x86_64-bin.zip"), + @("wimlib32.zip", "https://wimlib.net/downloads/wimlib-1.12.0-windows-i686-bin.zip"), + @("wimlib64.zip", "https://wimlib.net/downloads/wimlib-1.12.0-windows-x86_64-bin.zip") ) foreach ($Tool in $ToolSources) { DownloadFile -Path $Temp -Name $Tool[0] -Url $Tool[1]