From 41b818ad9950b9fab52117e8fc5266a0609e406b Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Sat, 30 Dec 2017 18:45:55 -0700 Subject: [PATCH 1/7] v1.3.1 - Wizard Hat Trick ## Main Kit ## * Updated several tool versions * Various bugfixes * _(Including another fixed set-eol.ps1 call)_ ## Windows PE ## * Fixed using local Windows sources * Various bugfixes ## Linux ## * New build script * Better package handling * Packages split into build dependencies, aur, and live * Isolinux/pxelinux/syslinux/refind setup during build process * main.py settings has replaced arch.conf and wifi.conf * Hardware diagnostic scripts * All scripts rewritten in Python * Prime95 * Added ablity to abort test without cancelling other tests * The tempuratures are saved from the end of the test * NVMe/SMART * New NVMe tests since SMART support is limited for NVMe devices * Progress is displayed for SMART self-tests * The script waits on the self-test for the polling-time + 5min * Unless it detects completion after 60 seconds * badblocks * Optionally run when the device health is unknown * These overrides are done per-device * Results screen * Final temps from Prime95 tests displayed * Tempurature sensors rewritten * Rewritten in python * Report CoreTemps first then others (CPU temps) * Wrap into two columns as necessary (if the window is big enough) --- Build Kit.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build Kit.cmd b/Build Kit.cmd index d50b9209..45d444bc 100644 --- a/Build Kit.cmd +++ b/Build Kit.cmd @@ -22,7 +22,7 @@ attrib +h OUT_KIT\.cbin >nul 2>&1 rem Rewrite main.py using PowerShell to have CRLF/`r`n lineendings set "script=OUT_KIT\.bin\Scripts\borrowed\set-eol.ps1" set "main=OUT_KIT\.bin\Scripts\settings\main.py" -powershell -executionpolicy bypass -noprofile -file %script% -lineEndings win -file %main% || goto ErrorUnknown +powershell -executionpolicy bypass -noprofile -file %script% -lineEnding win -file %main% || goto ErrorUnknown :Launch set "script=OUT_KIT\.bin\Scripts\build_kit.ps1" From 10cf7a15758d8b4716f02f1b29fd56d9a0b3c567 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Mon, 15 Jan 2018 12:57:27 -0700 Subject: [PATCH 2/7] Updated hw-sensors * Filter out non-temp sensors * Adjusted formatting * Partially addresses issue #9 --- .bin/Scripts/hw-sensors | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.bin/Scripts/hw-sensors b/.bin/Scripts/hw-sensors index bfaddc7e..36655911 100755 --- a/.bin/Scripts/hw-sensors +++ b/.bin/Scripts/hw-sensors @@ -61,12 +61,9 @@ def get_feature_string(chip, feature): skipname = len(feature.name)+1 # skip common prefix data = {} - if feature.type == sensors.feature.INTRUSION: - vals = [sensors.get_value(chip, sf.number) for sf in sfs] - # short path for INTRUSION to demonstrate type usage - status = "alarm" if int(vals[0]) == 1 else "normal" - print_standard(' {:18} {}'.format(label, status)) - return + if feature.type != sensors.feature.TEMP: + # Skip non-temperature sensors + return None for sf in sfs: name = sf.name[skipname:].decode("utf-8").strip() @@ -94,7 +91,7 @@ def get_feature_string(chip, feature): list_data.append('{}: {}'.format(item, data.pop(item))) list_data.extend( ['{}: {}'.format(k, v) for k, v in sorted(data.items())]) - data_str = '{:18} {} ({})'.format( + data_str = '{:18} {} {}'.format( label, main_temp, ', '.join(list_data)) else: list_data.extend(sorted(data.items())) @@ -119,10 +116,13 @@ if __name__ == '__main__': chip_name = '{} ({})'.format( sensors.chip_snprintf_name(chip), sensors.get_adapter_name(chip.bus)) - chip_temps[chip_name] = [chip_name] - for feature in sensors.FeatureIterator(chip): - chip_temps[chip_name].append(get_feature_string(chip, feature)) - chip_temps[chip_name].append('') + chip_feats = [get_feature_string(chip, feature) + for feature in sensors.FeatureIterator(chip)] + # Strip empty/None items + chip_feats = [f for f in chip_feats if f] + + if chip_feats: + chip_temps[chip_name] = [chip_name, *chip_feats, ''] # Sort chips sensor_temps = [] From 0e87bf55a0f4e1a10720d9cadec43344f37e4514 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Mon, 15 Jan 2018 13:45:58 -0700 Subject: [PATCH 3/7] Enable HW-Diags for more devices * Skip all removable WizardKit devices * Fixes issue #8 --- .bin/Scripts/functions/hw_diags.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 8b2c164e..99a6a3ed 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -410,10 +410,18 @@ def scan_disks(): json_data = json.loads(result.stdout.decode()) devs = {} for d in json_data.get('blockdevices', []): - if d['type'] == 'disk' and d['hotplug'] == '0': - devs[d['name']] = {'lsblk': d} - TESTS['NVMe/SMART']['Status'][d['name']] = 'Pending' - TESTS['badblocks']['Status'][d['name']] = 'Pending' + if d['type'] == 'disk': + if d['hotplug'] == '0': + devs[d['name']] = {'lsblk': d} + TESTS['NVMe/SMART']['Status'][d['name']] = 'Pending' + TESTS['badblocks']['Status'][d['name']] = 'Pending' + else: + # Skip WizardKit devices + wk_label = '{}_LINUX'.format(KIT_NAME_SHORT) + if wk_label not in [c.get('label', '') for c in d['children']]: + devs[d['name']] = {'lsblk': d} + TESTS['NVMe/SMART']['Status'][d['name']] = 'Pending' + TESTS['badblocks']['Status'][d['name']] = 'Pending' for dev, data in devs.items(): # Get SMART attributes From 480ac48aae7907786268294a9f9c56322e87bebc Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Mon, 15 Jan 2018 14:13:35 -0700 Subject: [PATCH 4/7] Removed '+' from positive temps in hw-sensors --- .bin/Scripts/hw-sensors | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/hw-sensors b/.bin/Scripts/hw-sensors index 36655911..2a1a46e0 100755 --- a/.bin/Scripts/hw-sensors +++ b/.bin/Scripts/hw-sensors @@ -51,7 +51,7 @@ def color_temp(temp): color = COLORS['CLEAR'] return '{color}{prefix}{temp:2.0f}°C{CLEAR}'.format( color = color, - prefix = '+' if temp>0 else '-', + prefix = '-' if temp < 0 else '', temp = temp, **COLORS) @@ -78,7 +78,7 @@ def get_feature_string(chip, feature): data[name] = ' {}°C'.format(val) else: data[name] = '{}{:2.0f}°C'.format( - '+' if temp>0 else '-', + '-' if temp < 0 else '', temp) else: data[name] = color_temp(val) From 3bc45e983203f3a89b76bc07c9fb1781188a2ece Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Mon, 15 Jan 2018 14:16:59 -0700 Subject: [PATCH 5/7] Fix issue #7 by switching to Font Awesome v4 --- .../airootfs/etc/skel/.config/i3status/config | 14 +++++++------- .linux_items/packages/aur | 2 +- .linux_items/packages/live | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.linux_items/include/airootfs/etc/skel/.config/i3status/config b/.linux_items/include/airootfs/etc/skel/.config/i3status/config index d783b408..d36294a4 100644 --- a/.linux_items/include/airootfs/etc/skel/.config/i3status/config +++ b/.linux_items/include/airootfs/etc/skel/.config/i3status/config @@ -21,7 +21,7 @@ order += "tztime local" #order += "tztime utc" cpu_usage { - format = ". %usage" + format = " %usage" max_threshold = 90 #format_above_threshold = " %usage" degraded_threshold = 75 @@ -29,19 +29,19 @@ cpu_usage { } wireless _first_ { - format_up = ". (%quality at %essid) %ip" - format_down = ". Down" + format_up = " (%quality at %essid) %ip" + format_down = " Down" } ethernet _first_ { # if you use %speed, i3status requires root privileges - format_up = ". %ip" - format_down = ". Down" + format_up = " %ip" + format_down = " Down" } battery all { integer_battery_capacity = true - format = "%status. %percentage" + format = "%status %percentage" format_down = "" status_chr = "" status_bat = "" @@ -53,7 +53,7 @@ battery all { } volume master { - format = ". %volume" + format = " %volume" format_muted = " muted" device = "pulse" } diff --git a/.linux_items/packages/aur b/.linux_items/packages/aur index 9de0855e..13aef81f 100644 --- a/.linux_items/packages/aur +++ b/.linux_items/packages/aur @@ -11,6 +11,6 @@ papirus-icon-theme pasystray smartmontools-svn testdisk-wip -ttf-font-awesome +ttf-font-awesome-4 wd719x-firmware wimlib diff --git a/.linux_items/packages/live b/.linux_items/packages/live index efc1e1d8..892b0bf2 100644 --- a/.linux_items/packages/live +++ b/.linux_items/packages/live @@ -50,6 +50,7 @@ networkmanager nvme-cli oblogout openbox-patched +otf-font-awesome-4 p7zip papirus-icon-theme pasystray @@ -75,7 +76,7 @@ tint2 tk tmux tree -ttf-font-awesome +ttf-font-awesome-4 ttf-inconsolata udevil udisks2 From 5a1f9f096113331ad40a7b298f39cebc1a9799f4 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Mon, 15 Jan 2018 14:28:31 -0700 Subject: [PATCH 6/7] Added Cleanup CBS launcher --- .bin/Scripts/settings/launchers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.bin/Scripts/settings/launchers.py b/.bin/Scripts/settings/launchers.py index f3e6b0a2..7d52cd51 100644 --- a/.bin/Scripts/settings/launchers.py +++ b/.bin/Scripts/settings/launchers.py @@ -441,6 +441,12 @@ LAUNCHERS = { }, }, r'Misc': { + 'Cleanup CBS Temp Files': { + 'L_TYPE': 'PyScript', + 'L_PATH': 'Scripts', + 'L_ITEM': 'cbs_fix.py', + 'L_ELEV': 'True', + }, 'ConEmu (as ADMIN)': { 'L_TYPE': 'Executable', 'L_PATH': 'ConEmu', From fbd7f47749c0f76f445fd6d6b855c5f6d9f30c08 Mon Sep 17 00:00:00 2001 From: 2Shirt <1923621+2Shirt@users.noreply.github.com> Date: Mon, 15 Jan 2018 17:30:47 -0700 Subject: [PATCH 7/7] Added build-ufd script * Includes safety checks to avoid unintentional data loss --- .bin/Scripts/build-ufd | 201 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100755 .bin/Scripts/build-ufd diff --git a/.bin/Scripts/build-ufd b/.bin/Scripts/build-ufd new file mode 100755 index 00000000..a3508beb --- /dev/null +++ b/.bin/Scripts/build-ufd @@ -0,0 +1,201 @@ +#!/bin/bash +# +## Wizard Kit: UFD Build Tool + +DEST_DEV="$1" +DEST_PARTITION="${DEST_DEV}1" +MAIN_PY="/usr/local/bin/settings/main.py" +WD=$(pwd) +EXTRA_DIR="${WD}/Extras" +MAIN_KIT="$(dirname $(find $WD -type d -name '.bin') 2>/dev/null)" +LINUX_ISO="$(find $WD -type f -iname '*Linux*iso' | head -1)" +WINPE_ISO="$(find $WD -type f -iname '*WinPE*iso' | head -1)" +if [ "$2" == "--silent" ]; then + SILENT="True" +fi + +# COLORS +CLEAR="\e[0m" +RED="\e[31m" +GREEN="\e[32m" +YELLOW="\e[33m" +BLUE="\e[34m" + +# Functions +function ask() { + if [ "$SILENT" == "True" ]; then + echo -e "$1 Yes ${BLUE}(Silent)${CLEAR}" + return 0 + fi + while :; do + read -p "$1 " -r answer + if echo "$answer" | egrep -iq '^(y|yes|sure)$'; then + return 0 + elif echo "$answer" | egrep -iq '^(n|no|nope)$'; then + return 1 + fi + done +} + +die () { + echo "$0:" "$@" >&2 + echo "" + read -p "Press Enter to exit... " -r + exit 1 +} + +# Load main.py settings +if [ ! -f "$MAIN_PY" ]; then + echo -e "${RED}ERROR${CLEAR}: $MAIN_PY not found." + die "Aborted." +fi +while read line; do + if echo "$line" | egrep -q "^\w+='"; then + line="$(echo "$line" | sed -r 's/[\r\n]+//')" + eval "$line" + fi +done < "$MAIN_PY" +if [ -z ${KIT_NAME_FULL+x} ]; then + # KIT_NAME_FULL is not set, assume main.py missing or malformatted + echo -e "${RED}ERROR${CLEAR}: failed to load settings from $MAIN_PY" + die "Aborted." +fi +UFD_LABEL="${KIT_NAME_SHORT}_LINUX" + +# Check if root +if [[ "$EUID" -ne 0 ]]; then + echo -e "${RED}ERROR${CLEAR}: This script must be run as root." + die "Aborted." +fi + +# Check if in tmux +if ! tmux list-session | grep -q "build-ufd"; then + # Reload in tmux + tmux new-session -s "build-ufd" "$0" $* + exit 0 +fi + +# Header +echo -e "${GREEN}$KIT_NAME_FULL${CLEAR}: UFD Build Tool" +echo "" + +# Dest and Sources Check +abort="False" +if [ ! -b "$DEST_DEV" ]; then + echo -e "${RED}ERROR${CLEAR}: Device $DEST_DEV not found." + abort="True" +fi +if [ ! -f "$LINUX_ISO" ]; then + echo -e "${RED}ERROR${CLEAR}: Linux ISO not found." + abort="True" +fi +if [ ! -f "$WINPE_ISO" ]; then + echo -e "${RED}ERROR${CLEAR}: WinPE ISO not found." + abort="True" +fi +if [ ! -d "$MAIN_KIT" ]; then + echo -e "${RED}ERROR${CLEAR}: Wizard Kit directory not found." + abort="True" +fi +if [ ! -d "$EXTRA_DIR" ]; then + # Warn but don't abort + echo -e "${YELLOW}WARNING${CLEAR}: $EXTRA_DIR not found." + echo "" + EXTRA_DIR='__None__' +fi +if [ "$abort" == "True" ]; then + echo "" + die "Aborted." +fi + +# Display Job Settings +echo -e "${BLUE}Sources${CLEAR}" +echo "Main Kit: $MAIN_KIT" +echo "Linux ISO: $LINUX_ISO" +echo "WinPE ISO: $WINPE_ISO" +echo "Extras: $EXTRA_DIR" +echo "" +echo -e "${BLUE}Destination${CLEAR}" +lsblk -n -o NAME,LABEL,SIZE,MODEL,SERIAL $DEST_DEV + +# Ask before starting job +echo "" +if ask "Is the above information correct?"; then + echo "" + echo -e "${YELLOW}SAFETY CHECK${CLEAR}" + echo "All data will be DELETED from the disk and partition(s) listed above." + echo -e "This is irreversible and will lead to ${RED}DATA LOSS.${CLEAR}" + if ! ask "Asking again to confirm, is this correct?"; then + die "Aborted." + fi +else + die "Aborted." +fi + +# Start Build +echo "" +echo -e "${GREEN}Building Kit${CLEAR}" + +# Format +echo "Formatting drive..." +parted "$DEST_DEV" -s -- mklabel msdos mkpart primary fat32 1MiB -1s +parted "$DEST_DEV" set 1 boot on +mkfs.vfat -F 32 -n "$UFD_LABEL" "$DEST_PARTITION" >/dev/null 2>&1 + +# Mount sources and dest +echo "Mounting sources and destination..." +mkdir /mnt/{Dest,Linux,WinPE} -p +mount $DEST_PARTITION /mnt +mount "$LINUX_ISO" /mnt/Linux -r +mount "$WINPE_ISO" /mnt/WinPE -r + +# Copy files +echo "Copying Linux files..." +tmux split-window -l 15 cp -Lrv /mnt/Linux/* /mnt/ + +echo "Copying WinPE files..." +tmux split-window -l 15 cp -Lrv /mnt/WinPE/{Boot,bootmgr{,.efi},en-us,sources} /mnt/ +tmux split-window -l 15 cp -Lrv /mnt/WinPE/EFI/Microsoft /mnt/EFI/ +tmux split-window -l 15 cp -Lrv /mnt/WinPE/EFI/Boot/* /mnt/EFI/Microsoft/ +tmux split-window -l 15 cp -Lrv /mnt/WinPE/{Boot/{BCD,boot.sdi},bootmgr} /mnt/sources/ + +echo "Copying Main Kit..." +tmux split-window -l 15 cp -Lrv "$MAIN_KIT" /mnt/ +if [ "$EXTRA_DIR" != "__None__" ]; then + echo "Copying Extra files..." + tmux split-window -l 15 cp -Lrv "$EXTRA_DIR"/* /mnt/ +fi + +# Install syslinux +echo "Copying Syslinux files..." +tmux split-window -l 15 cp -Lrv /usr/lib/syslinux/bios/*.c32 /mnt/arch/boot/syslinux/ +syslinux --install -d /arch/boot/syslinux/ $DEST_PARTITION >/dev/null 2>&1 + +echo "Unmounting destination..." +umount /mnt +sync + +echo "Installing Syslinux MBR..." +dd bs=440 count=1 if=/usr/lib/syslinux/bios/mbr.bin of=$DEST_DEV >/dev/null 2>&1 +sync + +# Cleanup +echo "Hiding boot files..." +echo "drive s: file=\"$DEST_PARTITION\"" > /root/.mtoolsrc +echo 'mtools_skip_check=1' >> /root/.mtoolsrc +for item in BOOT{,MGR,MGR.EFI} EFI EN-US ISOLINUX LOADER SOURCES SYSLINUX.CFG; do + yes | mattrib +h S:/$item >/dev/null 2>&1 +done +sync + +# Unmount Sources +echo "Unmounting sources..." +umount /mnt/* -R + +# Done +echo "" +echo "Done." +echo "" +read -p "Press Enter to exit..." -r +exit 0 +