diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py new file mode 100644 index 00000000..00514fe8 --- /dev/null +++ b/.bin/Scripts/functions/ddrescue.py @@ -0,0 +1,58 @@ +# Wizard Kit: Functions - ddrescue + +import json +import re + +from functions.common import * + +# STATIC VARIABLES +USAGE=""" {script_name} clone [source [destination]] + {script_name} image [source [destination]] + (e.g. {script_name} clone /dev/sda /dev/sdb) +""" + +# Functions +def menu_clone(source_path, dest_path): + print_success('GNU ddrescue: Cloning Menu') + pass + +def menu_ddrescue(*args): + """Main ddrescue loop/menu.""" + args = list(args) + script_name = os.path.basename(args.pop(0)) + run_mode = '' + source_path = None + dest_path = None + + # Parse args + try: + run_mode = args.pop(0) + source_path = args.pop(0) + dest_path = args.pop(0) + except IndexError: + # We'll set the missing paths later + pass + + # Show proper menu or exit + if run_mode == 'clone': + menu_clone(source_path, dest_path) + elif run_mode == 'image': + menu_image(source_path, dest_path) + else: + if not re.search(r'(^$|help|-h|\?)', run_mode, re.IGNORECASE): + print_error('Invalid mode.') + show_usage(script_name) + exit_script() + +def menu_image(source_path, dest_path): + print_success('GNU ddrescue: Imaging Menu') + pass + +def show_usage(script_name): + print_info('Usage:') + print_standard(USAGE.format(script_name=script_name)) + +if __name__ == '__main__': + print("This file is not meant to be called directly.") + +# vim: sts=4 sw=4 ts=4 diff --git a/.bin/Scripts/wk-ddrescue b/.bin/Scripts/wk-ddrescue new file mode 100755 index 00000000..28ce6fb7 --- /dev/null +++ b/.bin/Scripts/wk-ddrescue @@ -0,0 +1,32 @@ +#!/bin/python3 +# +## Wizard Kit: TUI for ddrescue cloning and imaging + +import os +import sys + +# Init +os.chdir(os.path.dirname(os.path.realpath(__file__))) +sys.path.append(os.getcwd()) +from functions.ddrescue import * +from functions.hw_diags import * +init_global_vars() + +if __name__ == '__main__': + try: + # Prep + clear_screen() + + # Show menu + menu_ddrescue(*sys.argv) + + # Done + #print_standard('\nDone.') + #pause("Press Enter to exit...") + exit_script() + except SystemExit: + pass + except: + major_exception() + +# vim: sts=4 sw=4 ts=4