mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
package .bin/ scripts as proper nix packages, delete .bin/
Packaged 14 scripts from .bin/ into packages/ with proper dependency declarations (writers.writeDashBin/writeBashBin/writePython3Bin): - 256color → two56color (terminal color chart) - avesta.sed → avesta (Avestan transliteration) - bvg.sh → bvg (Berlin transit disruptions) - unicode → charinfo (Unicode character info) - chunk-pdf → chunk-pdf (split PDFs by page count) - csv2json → csv2json (CSV to JSON converter) - fix-sd.sh → fix-sd (exFAT SD card recovery, improved output handling) - json2csv → json2csv (JSON to CSV converter) - mp3player-write → mp3player-write (audio conversion for MP3 players) - mushakkil.sh → mushakkil (Arabic diacritization) - nix-haddock-index → nix-haddock-index (GHC Haddock index generator) - pdf-ocr.sh → pdf-ocr (OCR PDFs via tesseract) - prospekte.sh → prospekte (German supermarket flyer browser) - readme → readme (GitHub README as man page) All added to overlay and packages output. .bin/ directory removed.
This commit is contained in:
34
packages/fix-sd.nix
Normal file
34
packages/fix-sd.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
# Recover files from a corrupted exFAT SD card
|
||||
{
|
||||
writers,
|
||||
exfatprogs,
|
||||
util-linux,
|
||||
coreutils,
|
||||
findutils,
|
||||
gnused,
|
||||
}:
|
||||
writers.writeDashBin "fix-sd" ''
|
||||
set -efu
|
||||
|
||||
drive="''${1:?Usage: fix-sd /dev/sdX [output-dir]}"
|
||||
output_dir="''${2:-$(${coreutils}/bin/mktemp -d "''${TMPDIR:-/tmp}/fix-sd-XXXXXX")}"
|
||||
mountpoint="$(${coreutils}/bin/mktemp -d "''${TMPDIR:-/tmp}/fix-sd-mount-XXXXXX")"
|
||||
|
||||
trap clean EXIT
|
||||
clean() {
|
||||
${util-linux}/bin/umount "$mountpoint" 2>/dev/null || true
|
||||
${coreutils}/bin/rmdir "$mountpoint" 2>/dev/null || true
|
||||
}
|
||||
|
||||
filenames="$(${exfatprogs}/bin/fsck.exfat "$drive" 2>&1 | ${gnused}/bin/sed -nE "s/.* file '(.*?)' is not allocated.*/\1/p")"
|
||||
${coreutils}/bin/mkdir -p "$mountpoint" "$output_dir"
|
||||
${util-linux}/bin/mount "$drive" "$mountpoint"
|
||||
|
||||
echo "$filenames" | while read -r filename; do
|
||||
[ -n "$filename" ] || continue
|
||||
${findutils}/bin/find "$mountpoint" -type f -name "$filename" -exec ${coreutils}/bin/cp {} "$output_dir" \;
|
||||
done
|
||||
|
||||
echo "Recovered files saved to $output_dir"
|
||||
${exfatprogs}/bin/fsck.exfat "$drive"
|
||||
''
|
||||
Reference in New Issue
Block a user