lars
1c8db28989
simple partitioning interface finished order in navigation bar changed ignore extended partitions (in container list)
50 lines
983 B
Python
Executable file
50 lines
983 B
Python
Executable file
#!/usr/bin/env python2.4
|
|
|
|
## necessary: otherwise CryptoBoxRootActions.py will refuse to execute this script
|
|
PLUGIN_TYPE = "cryptobox"
|
|
|
|
SFDISK_BIN = "/sbin/sfdisk"
|
|
|
|
import subprocess
|
|
import re
|
|
import sys
|
|
import os
|
|
|
|
|
|
def __partitionDevice(device):
|
|
## do not use the "-q" flag, as this spoils the exit code of sfdisk (seems to be a bug)
|
|
proc = subprocess.Popen(
|
|
shell = False,
|
|
args = [
|
|
SFDISK_BIN,
|
|
"-uM",
|
|
device])
|
|
proc.communicate()
|
|
return proc.returncode == 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args = sys.argv[1:]
|
|
|
|
self_bin =sys.argv[0]
|
|
|
|
if len(args) > 2:
|
|
sys.stderr.write("%s: too many arguments (%s)\n" % (self_bin, args))
|
|
sys.exit(1)
|
|
|
|
if len(args) == 0:
|
|
sys.stderr.write("%s: no argument supplied\n" % self_bin)
|
|
sys.exit(1)
|
|
|
|
if args[0] == "partition":
|
|
if len(args) < 2:
|
|
sys.stderr.write("%s: not enough arguments (%s)\n" % (self_bin, args))
|
|
sys.exit(1)
|
|
if __partitionDevice(args[1]):
|
|
sys.exit(0)
|
|
else:
|
|
sys.exit(1)
|
|
else:
|
|
sys.exit(1)
|
|
|