-
-
Save maluta/1100234 to your computer and use it in GitHub Desktop.
dd wrapper to avoid mistakes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import subprocess | |
def usage(): | |
return " \n Misssing config file, you must create a file called ~/.blocklist-dd and insert which device dd should avoid \n\n \ | |
Ex: \n \ | |
$ echo \"/dev/sda\" > ~/.blocklist-dd \n \ | |
$ echo \"/dev/sdb\" >> ~/.blocklist-dd \n \ | |
" | |
try: | |
f = open("~/.blocklist-dd","r") | |
except: | |
print usage() | |
sys.exit(0) | |
pattern = f.readlines() | |
f.close() | |
for p in pattern: | |
for param in sys.argv: | |
if param.find(p[:-1]) != -1: | |
print "ooops, you are associating a blocked device (%s) on dd, proceed? (Y/n) (Y/n)" % p[:-1] | |
op = raw_input() | |
if op != "Y": | |
sys.exit(0) | |
sys.argv[0] = "dd" | |
subprocess.call(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment