diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index cf518ea0..4af88e84 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -219,6 +219,7 @@ class DevObj(BaseObj): sep='_' if self.label else '', c_label=self.label) self.prefix = self.prefix.strip().replace(' ', '_') + self.prefix = self.prefix.strip().replace('/', '_') class DirObj(BaseObj): diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 7e4e2db6..3b98e708 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -286,7 +286,7 @@ def get_smart_value(smart_data, smart_id): def get_status_color(s): """Get color based on status, returns str.""" color = COLORS['CLEAR'] - if s in ['Denied', 'NS', 'OVERRIDE']: + if s in ['Denied', 'ERROR', 'NS', 'OVERRIDE']: color = COLORS['RED'] elif s in ['Aborted', 'Unknown', 'Working', 'Skipped']: color = COLORS['YELLOW'] @@ -757,10 +757,10 @@ def run_iobenchmark(ticket_number): dev_size = int(dev_size) except: # Failed to get dev size, requires manual testing instead - TESTS['iobenchmark']['Status'][name] = 'Unknown' + TESTS['iobenchmark']['Status'][name] = 'ERROR' continue if dev_size < IO_VARS['Minimum Dev Size']: - TESTS['iobenchmark']['Status'][name] = 'Unknown' + TESTS['iobenchmark']['Status'][name] = 'ERROR' continue # Calculate dd values diff --git a/.bin/Scripts/photorec-sort b/.bin/Scripts/photorec-sort new file mode 100755 index 00000000..6f11b0a6 --- /dev/null +++ b/.bin/Scripts/photorec-sort @@ -0,0 +1,150 @@ +#!/bin/bash +# +## sort photorec results into something usefull + +## Set paths +recup_dir="${1%/}" +[ -n "$recup_dir" ] || recup_dir="." +recup_dir="$(realpath "$recup_dir")" +out_dir="$recup_dir/Recovered" +bad_dir="$recup_dir/Corrupt" + +## Test path before starting (using current dir if not specified) +for d in $recup_dir/recup*; do + ### Source: http://stackoverflow.com/a/6364244 + ## Check if the glob gets expanded to existing files. + ## If not, f here will be exactly the pattern above + ## and the exists test will evaluate to false. + [ -e "$d" ] && echo "Found recup folder(s)" || { + echo "ERROR: No recup folders found" + echo "Usage: $0 recup_dir" + exit 1 + } + + ## This is all we needed to know, so we can break after the first iteration + break +done + +# Hard link files into folders by type +for d in $recup_dir/recup*; do + if [ -d "$d" ]; then + echo "Linking $d" + pushd $d >/dev/null + find -type f | while read k; do + file="$(basename "$k")" + src="$(realpath "$k")" + ext="$(echo "${file##*.}" | tr '[:upper:]' '[:lower:]')" + ext_dir="$out_dir/$ext" + if [ "${file##*.}" = "$file" ]; then + ext_dir="$out_dir/_MISC_" + elif [ "$ext" = "jpg" ] && [ "${file:0:1}" = "t" ]; then + ext_dir="$out_dir/jpg-thumbnail" + fi + #echo " $file -> $ext_dir" + [ -d "$ext_dir" ] || mkdir -p "$ext_dir" + ln "$src" "$ext_dir" + done + popd >/dev/null + else + echo "ERROR: '$d' not a directory" + fi +done + +## Check the files output by photorec for corruption +pushd "$out_dir" >/dev/null + +# Check archives with 7-Zip +#for d in 7z bz2 gz lzh lzo rar tar xz zip; do +# if [ -d "$d" ]; then +# echo "Checking $d files" +# pushd "$d" >/dev/null +# for f in *; do +# if ! 7z t "$f" >/dev/null 2>&1; then +# #echo " BAD: $f" +# [ -d "$bad_dir/$d" ] || mkdir -p "$bad_dir/$d" +# mv -n "$f" "$bad_dir/$d/$f" +# fi +# done +# popd >/dev/null +# fi +#done + +# Check Audio/Video files with ffprobe +for d in avi flac flv m4a m4p m4v mkv mid mov mp2 mp3 mp4 mpg mpg2 ogg ts vob wav; do + if [ -d "$d" ]; then + echo "Checking $d files" + pushd "$d" >/dev/null + for f in *; do + if ! ffprobe "$f" >/dev/null 2>&1; then + #echo " BAD: $f" + [ -d "$bad_dir/$d" ] || mkdir -p "$bad_dir/$d" + mv -n "$f" "$bad_dir/$d/$f" + fi + done + popd >/dev/null + fi +done + +# Check .doc files with antiword +if [ -d "doc" ]; then + echo "Checking doc files" + pushd "doc" >/dev/null + for f in *doc; do + if ! antiword "$f" >/dev/null 2>&1; then + #echo " BAD: $f" + [ -d "$bad_dir/doc" ] || mkdir -p "$bad_dir/doc" + mv -n "$f" "$bad_dir/doc/$f" + fi + done + popd >/dev/null +fi + +# Check .docx files with 7z and grep +if [ -d "docx" ]; then + echo "Checking docx files" + pushd "docx" >/dev/null + for f in *docx; do + if ! 7z l "$f" | grep -q -s "word/document.xml"; then + #echo " BAD: $f" + [ -d "$bad_dir/docx" ] || mkdir -p "$bad_dir/docx" + mv -n "$f" "$bad_dir/docx/$f" + fi + done + popd >/dev/null +fi + +# Sort pictures by date (only for common camera formats) +for d in jpg mrw orf raf raw rw2 tif x3f; do + if [ -d "$d" ]; then + echo "Sorting $d files by date" + pushd "$d" >/dev/null + for f in *; do + date_dir="$(date -d "$(stat -c %y "$f")" +"%F")" + [ -d "$date_dir" ] || mkdir "$date_dir" + mv -n "$f" "$date_dir/" + done + popd >/dev/null + fi +done + +# Sort mov files by encoded date +if [ -d "mov" ]; then + echo "Sorting mov files by date" + pushd "mov" >/dev/null + for f in *mov; do + enc_date="$(mediainfo "$f" | grep -i "Encoded date" | head -1 | sed -r 's/.*: //')" + date_dir="$(date -d "$enc_date" +"%F")" + echo "$date_dir" | grep -E -q -s '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' || date_dir="Unknown Date" + [ -d "$date_dir" ] || mkdir "$date_dir" + mv -n "$f" "$date_dir/" + done + popd >/dev/null +fi + +## sort audio files by tags + +## sort matroska files by metadata + +## return to original dir +popd >/dev/null + diff --git a/.linux_items/include/airootfs/etc/skel/.aliases b/.linux_items/include/airootfs/etc/skel/.aliases index bf7507bc..d6486258 100644 --- a/.linux_items/include/airootfs/etc/skel/.aliases +++ b/.linux_items/include/airootfs/etc/skel/.aliases @@ -10,7 +10,6 @@ alias du='du -sch --apparent-size' alias fix-perms='find -type d -exec chmod 755 "{}" \; && find -type f -exec chmod 644 "{}" \;' alias hexedit='hexedit --color' alias hw-info='sudo hw-info | less -S' -alias inxi='echo -e "\e[33mWARNING: inxi is being replaced and will be removed in a future WizardKit release\e[0m"; echo -e " \e[32mReplacements include:\e[0m 'hw-drive-info', 'hw-info', & 'hw-sensors'"; echo ""; inxi' alias less='less -S' alias ls='ls --color=auto' alias mkdir='mkdir -p' diff --git a/.linux_items/include/airootfs/etc/skel/.config/i3/config b/.linux_items/include/airootfs/etc/skel/.config/i3/config index cf09a2ca..ca1a5439 100644 --- a/.linux_items/include/airootfs/etc/skel/.config/i3/config +++ b/.linux_items/include/airootfs/etc/skel/.config/i3/config @@ -319,3 +319,5 @@ bar { status_command i3status height 26 } + +exec --no-startup-id /home/tech/.update_x diff --git a/.linux_items/include/airootfs/etc/skel/.config/openbox/autostart b/.linux_items/include/airootfs/etc/skel/.config/openbox/autostart old mode 100644 new mode 100755 index 6eaa6cc3..13b9088c --- a/.linux_items/include/airootfs/etc/skel/.config/openbox/autostart +++ b/.linux_items/include/airootfs/etc/skel/.config/openbox/autostart @@ -1,20 +1,3 @@ -# -# These things are run when an Openbox X Session is started. -# You may place a similar script in $HOME/.config/openbox/autostart -# to run user-specific things. -# +#openbox-autostart -# If you want to use GNOME config tools... -# -#if test -x /usr/lib/openbox/gnome-settings-daemon >/dev/null; then -# /usr/lib/openbox/gnome-settings-daemon & -#elif which gnome-settings-daemon >/dev/null 2>&1; then -# gnome-settings-daemon & -#fi - -# If you want to use XFCE config tools... -# -#xfce-mcs-manager & - -tint2 & -cbatticon --hide-notification & +$HOME/.update_x & diff --git a/.linux_items/include/airootfs/etc/skel/.update_hostname b/.linux_items/include/airootfs/etc/skel/.update_hostname deleted file mode 100755 index 3c1bd7c2..00000000 --- a/.linux_items/include/airootfs/etc/skel/.update_hostname +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -IP="$(ip a show scope global \ - | grep inet \ - | head -1 \ - | sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+.)/.*#\1#')" -HOSTNAME="$(dig +noall +answer +short -x "$IP" \ - | head -1 \ - | sed 's/\.$//')" - -# Set hostname and renew DHCP lease -sudo hostnamectl set-hostname "${HOSTNAME}" -sudo dhclient -r -sleep 1 -sudo dhclient - diff --git a/.linux_items/include/airootfs/etc/skel/.update_network b/.linux_items/include/airootfs/etc/skel/.update_network new file mode 100755 index 00000000..97b5783b --- /dev/null +++ b/.linux_items/include/airootfs/etc/skel/.update_network @@ -0,0 +1,22 @@ +## .update_network ## +#!/bin/env bash +# +## Connect to network and update hostname + +# Connect +connect-to-network + +IP="$(ip a show scope global \ + | grep inet \ + | head -1 \ + | sed -r 's#.*inet ([0-9]+.[0-9]+.[0-9]+.[0-9]+.)/.*#\1#')" +HOSTNAME="$(dig +noall +answer +short -x "$IP" \ + | grep -v ';' \ + | head -1 \ + | sed 's/\.$//')" + +# Set hostname +if [[ "${HOSTNAME:+x}" ]]; then + sudo hostnamectl set-hostname "${HOSTNAME}" +fi + diff --git a/.linux_items/include/airootfs/etc/skel/.update_dpi_settings b/.linux_items/include/airootfs/etc/skel/.update_x similarity index 80% rename from .linux_items/include/airootfs/etc/skel/.update_dpi_settings rename to .linux_items/include/airootfs/etc/skel/.update_x index 2287508c..4763a175 100755 --- a/.linux_items/include/airootfs/etc/skel/.update_dpi_settings +++ b/.linux_items/include/airootfs/etc/skel/.update_x @@ -1,6 +1,6 @@ #!/bin/env bash # -## Calculate DPI and adjust display settings if necesary +## Calculate DPI, update settings if necessary, then start desktop apps REGEX_XRANDR='^.* ([0-9]+)x([0-9]+)\+[0-9]+\+[0-9]+.* ([0-9]+)mm x ([0-9]+)mm.*$' REGEX_URXVT='(URxvt.geometry:\s+).*' @@ -66,3 +66,29 @@ fi # Update URxvt (Always) urxvt_geometry="${width_urxvt}x${height_urxvt}+${offset_urxvt}+${offset_urxvt}" sed -i -r "s/${REGEX_URXVT}/\1${urxvt_geometry}/" "${HOME}/.Xresources" + +# Update X +xset s off +xset -dpms +xrdb -merge $HOME/.Xresources + +# Start common desktop apps +feh --bg-fill "$HOME/.wallpaper" +compton --backend xrender --xrender-sync --xrender-sync-fence & +sleep 1s +x0vncserver -display :0 -passwordfile $HOME/.vnc/passwd -AlwaysShared & +conky & +nm-applet & +volumeicon & + +# Start WM specific apps +if fgrep -q "i3" /proc/cmdline; then + # i3 + i3-msg restart +else + # openbox + openbox --restart + tint2 & + cbatticon --hide-notification & +fi + diff --git a/.linux_items/include/airootfs/etc/skel/.xinitrc b/.linux_items/include/airootfs/etc/skel/.xinitrc index abb71f45..7085a4df 100755 --- a/.linux_items/include/airootfs/etc/skel/.xinitrc +++ b/.linux_items/include/airootfs/etc/skel/.xinitrc @@ -1,19 +1,7 @@ #!/bin/sh dbus-update-activation-environment --systemd DISPLAY -$HOME/.update_dpi_settings -xrdb -merge $HOME/.Xresources -xset s off -xset -dpms eval $(ssh-agent) export SSH_AUTH_SOCK -compton --backend xrender --xrender-sync --xrender-sync-fence & -sleep 1s -conky -d -nm-applet & -volumeicon & -connect-to-network & -$HOME/.update_hostname & -feh --bg-fill "$HOME/.wallpaper" & -x0vncserver -display :0 -passwordfile $HOME/.vnc/passwd -AlwaysShared & exec openbox-session + diff --git a/.linux_items/include/airootfs/etc/skel/.zlogin b/.linux_items/include/airootfs/etc/skel/.zlogin index f592c932..f507afcf 100644 --- a/.linux_items/include/airootfs/etc/skel/.zlogin +++ b/.linux_items/include/airootfs/etc/skel/.zlogin @@ -1,5 +1,8 @@ setterm -blank 0 -powerdown 0 if [ "$(fgconsole 2>/dev/null)" -eq "1" ]; then + # Connect to network and update hostname + $HOME/.update_network + # Trust added root CAs sudo trust extract-compat @@ -19,4 +22,3 @@ if [ "$(fgconsole 2>/dev/null)" -eq "1" ]; then hw-diags cli fi fi - diff --git a/.linux_items/packages/aur b/.linux_items/packages/aur index 11874fa5..326ca732 100644 --- a/.linux_items/packages/aur +++ b/.linux_items/packages/aur @@ -2,7 +2,6 @@ aic94xx-firmware bash-pipes hfsprogs i3lock-fancy-git -inxi mprime nvme-cli openbox-patched diff --git a/.linux_items/packages/live_add b/.linux_items/packages/live_add index 7ac1faf5..a23f2884 100644 --- a/.linux_items/packages/live_add +++ b/.linux_items/packages/live_add @@ -34,7 +34,6 @@ htop i3-gaps i3lock-fancy-git i3status -inxi ldns leafpad lha diff --git a/Build Linux b/Build Linux index ec136c6e..56233d51 100755 --- a/Build Linux +++ b/Build Linux @@ -229,7 +229,8 @@ function update_live_env() { ssh-keygen -b 4096 -C "$username@$hostname" -N "" -f "$SKEL_DIR/.ssh/id_rsa" echo 'rm /root/.ssh/id*' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh" echo 'rm /root/.zlogin' >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh" - sed -i -r 's/^(.*PermitRootLogin.*)$/PermitRootLogin no/' "$LIVE_DIR/airootfs/root/customize_airootfs.sh" + sed -i -r '/.*PermitRootLogin.*/d' "$LIVE_DIR/airootfs/root/customize_airootfs.sh" + echo "sed -i -r '/.*PermitRootLogin.*/d' /etc/ssh/sshd_config" >> "$LIVE_DIR/airootfs/root/customize_airootfs.sh" cp "$ROOT_DIR/.linux_items/authorized_keys" "$SKEL_DIR/.ssh/authorized_keys" # Root user diff --git a/README.md b/README.md index 6228b18a..06f6d88d 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ There's a `build-ufd` script which does the following: * Mount the device(s) or network share(s) that contain the Linux ISO, WinPE ISO, and Main Kit folder. * Connect the UFD but don't mount it. * Get the device name of the UFD. - * You can use $ `inxi -Dxx` or $ `lsblk --fs` to help. + * You can use $ `hw-drive-info` to help. * $ `sudo build-ufd --ufd-device [device] --linux-iso [path] --main-kit [path] --winpe-iso [path]` * **2nd Warning**: All data will be erased from the UFD resulting in **DATA LOSS**. * NOTE: The Main Kit folder will be renamed on the UFD using `$KIT_NAME_FULL`