diff options
| author | Mattias Andrée <m@maandree.se> | 2026-02-22 14:11:06 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-02-22 14:11:06 +0100 |
| commit | ea1819ab01d0965950ddafde831b1908a3aadd62 (patch) | |
| tree | 929dfd379c32df54354dab6be27e3b2e54c002cb /bootcleanse.py | |
| parent | Update e-mail (diff) | |
| download | bootcleanse-ea1819ab01d0965950ddafde831b1908a3aadd62.tar.gz bootcleanse-ea1819ab01d0965950ddafde831b1908a3aadd62.tar.bz2 bootcleanse-ea1819ab01d0965950ddafde831b1908a3aadd62.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'bootcleanse.py')
| -rwxr-xr-x | bootcleanse.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/bootcleanse.py b/bootcleanse.py index 241f81b..90664e6 100755 --- a/bootcleanse.py +++ b/bootcleanse.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' bootcleanse – Cleanse your system from old MBR codes and boot flags @@ -31,15 +31,15 @@ mbrs = [] for arg in sys.argv[1:]: mbrs.append(arg) - print('Remove MBR code from and deactive boot flag on primary paritions in ' + arg) + print('Remove MBR code and deactivate the boot flag on primary partitions in ' + arg) if not (('a' <= arg[-1]) and (arg[-1] <= 'z') and (arg[:-1] in ('/dev/sd', '/dev/hd'))): print('\033[01;33mWarning:\033[21;39m Does not match /dev/(sd|hd)[a-z]') print() print('If you are not sure what you are doing, you may want') -print('to back up the first 512 byte of each defected file.') -print('To back up run `dd if=DEVICE bs=512 count=1 > DEV.backup`.') -print('To restore run `dd of=DEVICE bs=512 count=1 if=DEV.backup`.') +print('to back up the first 512 bytes of each affected file.') +print('To back up, run: dd if=DEVICE bs=512 count=1 > DEV.backup') +print('To restore, run: dd of=DEVICE bs=512 count=1 if=DEV.backup') print() print('\033[01mProceed? [yes/no]\033[21m') @@ -49,7 +49,7 @@ while True: break if yn == 'no': exit(128) - print('Only ‘yes’ and ‘no’ is valid') + print('Only ‘yes’ and ‘no’ are valid') def dd(pipe, i, o, *extra): cmd = ['sudo', 'dd'] @@ -64,7 +64,7 @@ def dd(pipe, i, o, *extra): if type(pipe) is str: cmd = ['\'' + a.replace('\'', '\'\\\'\'') + '\'' for a in cmd] cmd = ' '.join(cmd) - cmd = 'echo -e \'%s\' | %s' % (pipe, cmd) + cmd = 'printf \'%s\\n\' | %s' % (pipe, cmd) cmd = ['sudo', 'sh', '-c', cmd] return Popen(cmd, stdin=ch0, stdout=ch1, stderr=ch2).communicate() @@ -79,4 +79,3 @@ for mbr in mbrs: status = '0' + status status = '\\x' + status dd(status, None, mbr, 'bs=1', 'count=1', 'seek=%i' % (446 + 16 * p)) - |
