diff options
author | Britney Fransen <brfransen@gmail.com> | 2013-11-08 18:41:57 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2013-11-08 18:41:57 (GMT) |
commit | 75f54194c0e1cf6e2f8f9c685888439d00f4df9c (patch) | |
tree | afa9d345c173e19fd0c23e5e2ea1cc06d4e2cd2b /abs | |
parent | 1468cf62b07b10ab3d87bca6f54b20dc8b816abd (diff) | |
download | linhes_pkgbuild-75f54194c0e1cf6e2f8f9c685888439d00f4df9c.zip linhes_pkgbuild-75f54194c0e1cf6e2f8f9c685888439d00f4df9c.tar.gz linhes_pkgbuild-75f54194c0e1cf6e2f8f9c685888439d00f4df9c.tar.bz2 |
LinHES-system: add_storage.py: add more explaination of what the tool is going to do and improve help text.
Diffstat (limited to 'abs')
-rwxr-xr-x | abs/core/LinHES-system/PKGBUILD | 4 | ||||
-rw-r--r-- | abs/core/LinHES-system/add_storage.py | 133 |
2 files changed, 85 insertions, 52 deletions
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 0c2a055..3234ee2 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=8.0 -pkgrel=33 +pkgrel=34 arch=('i686' 'x86_64') install=system.install pkgdesc="Everything that makes LinHES an automated system" @@ -94,7 +94,7 @@ md5sums=('5ee78704cab0e88ec58d1aab821fc1aa' 'bc69a520add58ede9b060c73e67ace13' '26fdd26e945f0c187f9fdcf98a7a5bef' '47e093e8cfe4b5b96602358e1f540832' - 'c9f6f08c415b8adee2c45ebeb5c11edb' + 'f2b16283a8c89b08d5e5360f7bf4c026' '2c005d95312018bef80092136f80f254' '6519d209e151cdc39ae7e1091d189c3e' 'ca63946920ba33de1f15abda83e74e40' diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py index 3badbdc..600c8fe 100644 --- a/abs/core/LinHES-system/add_storage.py +++ b/abs/core/LinHES-system/add_storage.py @@ -153,7 +153,7 @@ class disk_device: def partition_disk(self): - print " Creating new partiton table" + print " Creating new partition table" cmd = "parted -s -a optimal %s mklabel gpt" %self.block_path runcmd(cmd) cmd = "parted -s -a optimal %s mkpart primary \" 1 -1\"" %self.block_path @@ -190,20 +190,23 @@ class disk_device: break return fstype - - def format_disk(self): + def lookup_format(self): fstab = self.read_fstab() - #lookup format current_media_mount = self.find_options_type(fstab)[1] new_fstype = self.find_fstype(current_media_mount) #setting self.new_fstype so that it can be referenced when setting fstab self.new_fstype = new_fstype + return + + def format_disk(self): + #lookup format + #self.lookup_format() #do format - if new_fstype == "xfs": - cmd = "mkfs -t %s -f %s " %(new_fstype,self.block_partition) + if self.new_fstype == "xfs": + cmd = "mkfs -t %s -f %s " %(self.new_fstype,self.block_partition) else: - cmd = "mkfs -t %s %s " %(new_fstype,self.block_partition) - print " Formating %s with %s" %(self.block_partition,new_fstype) + cmd = "mkfs -t %s %s " %(self.new_fstype,self.block_partition) + print " Formatting %s with %s" %(self.block_partition,self.new_fstype) runcmd(cmd) return @@ -286,8 +289,13 @@ class disk_device: except: os.makedirs(self.new_mount_point) if no_mount == False: - cmd = "mount %s" %self.new_mount_point - runcmd(cmd) + if os.path.ismount(self.new_mount_point): + print " Disk already mounted, will not mount:\n %s" %self.new_mount_point + pass + else: + print " Mounting %s" %self.new_mount_point + cmd = "mount %s" %self.new_mount_point + runcmd(cmd) return def mkdirs(self,FS_LIST): @@ -447,16 +455,16 @@ def prompt_to_add(current_drive,destruction = True): loop = True if destruction : prompt = ''' - Adding the disk will remove all contents on the disk. + ** Adding this disk will remove all contents on the disk. ** + This disk will be partitioned and formatted. - Do you wish enable this disk for MythTV storage(Y/N)?:''' + Enable this disk for MythTV storage (Y/N)?:''' else: prompt = ''' - ** Preserving existing data ** - will not format or partition + ** Preserving existing contents on the disk. ** + This disk will NOT be partitioned or formatted. - Do you wish enable this disk for MythTV storage(Y/N)?: - ''' + Enable this disk for MythTV storage (Y/N)?:''' while loop: str1 = raw_input(prompt) @@ -470,11 +478,17 @@ def prompt_to_add(current_drive,destruction = True): rc = False return rc -def prompt_to_continue(): +def prompt_to_continue(process_list): loop = True #while loop: - print "\n\n\n\n" - str1 = raw_input("\n Ready to add additional storage!\n Press Y to add disk(s), anything else to abort:") + print "\n\n\n Ready to add additional storage!\n" + if destruction: + print "** WARNING: These disk(s) WILL be partitioned and formatted. **\n ** All content on these disk(s) will be erased. **" + else: + print " ** These disk(s) will NOT be partitioned and formatted. **" + for i in process_list: + print " %s" %(i.get_name()) + str1 = raw_input("\n Press Y to add disk(s), any other key to cancel:") #if str1 in ['Y','N','y','n']: # loop = False @@ -484,6 +498,7 @@ def prompt_to_continue(): rc = True else: rc = False + print "\nCancelled: No disk(s) added to your system." print "-----" return rc @@ -499,7 +514,7 @@ def prompt_sg(dir_be_sg,dir_fe_sg): The content on these storage groups will only be available while the system is online. - Do you wish enable Backend Storage Groups(Y/N)?:''' + Enable Backend Storage Groups (Y/N)?:''' while loop: str1 = raw_input(prompt_string) @@ -519,14 +534,14 @@ def prompt_sg(dir_be_sg,dir_fe_sg): if dir_fe_sg != True: loop = True print "" - print "+" * 20 + print " ++++++++++++++++++++" prompt_string=''' Frontend Storage Groups are used for artwork and videos. The content on these storage groups will only be available while the system is online. - Do you wish enable Frontend Storage Groups(Y/N)?:''' + Enable Frontend Storage Groups (Y/N)?:''' while loop: str1 = raw_input(prompt_string) if str1 in ['Y','N','y','n']: @@ -548,7 +563,7 @@ def prompt_sg(dir_be_sg,dir_fe_sg): def remove_pickle(): try: - print "* Resetting list of known disks." + print "\n* Removing list of known disks.\n" os.remove(pickle_file) except: pass @@ -594,6 +609,7 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): dstatus = " Ignoring - Disk has been previously skipped and is mounted:" print "\n" + print " --------------------------------------------------------" print dstatus print " model: %s" %i.model print " location: %s" %i.block_path @@ -604,31 +620,31 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): if not scan_only: print "\n" print " --------------------------------------------------------" - print " Found new disk:" + print " Found New Disk:" print " model: %s" %i.model print " location: %s" %i.block_path print " size: %s " %i.device_size if prompt_to_add(i,destruction) : - print "\n Disk will be added to the storage pool!" + print "\n %s will be added to your system!" %i.model process_list.append(i) else: no_process_list.append(i) else: process_list.append(i) print "\n" - print " End of Scan" + print " Scan Finished" print "-" * 60 if scan_only: if len(process_list) > 0: - print " Unknown or unmounted disks:" + print " Unknown or Unmounted Disks:" f = open('/tmp/scan_report', 'w') for i in process_list: f.write("disk: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size)) print "\n" print " ---------------------------------------------------------" - print " Found new disk:" + print " Found New Disk:" print " model: %s" %i.model print " location: %s" %i.block_path print " size: %s " %i.device_size @@ -646,7 +662,7 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): system_drive_list.remove(y) write_known_drive_list(system_drive_list) else: - print "\nDid not find any new disks to add.\n" + print "\nThere are no disks to add to your system.\n\nFor more options: add_storage.py --help\n" write_known_drive_list(system_drive_list) #BE = MythBE(db=DB) @@ -660,12 +676,13 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg): print "\n Will add %s disk(s) to your system." %len(process_list) dir_be_sg , dir_fe_sg = prompt_sg(dir_be_sg,dir_fe_sg) - if prompt_to_continue() == True: + if prompt_to_continue(process_list) == True: write_known_drive_list(system_drive_list) disk_num = last_disk_num() for i in process_list: print " Disk: %s" %(i.get_name()) disk_num = disk_num + 1 + i.lookup_format() if destruction == True: i.partition_disk() i.format_disk() @@ -862,7 +879,6 @@ class reconstruct_path: cmd = "ln -s %s %s" %(self.mount_point,disk_ln) runcmd(cmd) - def add_fstab(self): #new_fstab_list=['UUID=', 'mount_point', 'auto', 'defaults', '0', '1'] new_fstab_list=['UUID=', 'mount_point', self.fstype, 'defaults', '0', '1'] @@ -897,8 +913,13 @@ class reconstruct_path: except: os.makedirs(self.mount_point) if no_mount == False : - cmd = "mount %s" %self.mount_point - runcmd(cmd) + if os.path.ismount(self.mount_point): + print " Disk already mounted, will not mount:\n %s" %self.mount_point + pass + else: + print " Mounting %s" %self.mount_point + cmd = "mount %s" %self.mount_point + runcmd(cmd) return def write_config(self): @@ -917,14 +938,14 @@ class reconstruct_path: return def reconstruct_mounts(no_mount): - print "Recreating disks based on contents of /etc/storage.d" + print "\nRecreating disks from contents of /etc/storage.d/" for conf_file in glob.glob('%s/*.conf' %storage_dir): print "\n" cf = reconstruct_path(conf_file) #print cf.get_conf() #print cf.get_uuid() - print " %s" %cf.get_mount_point() + print " Recreating %s" %cf.get_mount_point() #print cf.get_shareable() #print cf.get_is_myth_mount() #print cf.get_disk_num() @@ -934,6 +955,7 @@ def reconstruct_mounts(no_mount): cf.symlink_disk() cf.mount_disk(no_mount) + print "\n\nDone recreating disks.\n" pass @@ -941,31 +963,43 @@ def usage(): help=''' add_storage.py finds and sets up disks for MythTV usage. It's a powerful tool that could destroy data if not used correctly, - so please be careful. + please be careful. + + Scanned disks are ignored if they are mounted or have been + previously skipped by add_storage.py. The file system type for disks added by add_storage.py is - automatically set to the type you selected at install. + automatically set to the type selected for the data partition + at install. - Normal operations include (in this order): + Normal operations without options include (in this order): Partition the disk Format the disk Add disk to /etc/fstab Mount the disk Create the directories - Write out the config file to /etc/storage.d + Write out the disk config file to /etc/storage.d/ + Create disk# symlink at /data/storage/ + Create /myth symlink (if applicable) Add new locations to MythTV storage groups Options: - --no_mount: Do not mount the disk, only add it to /etc/fstab - and create the directory. + --add_be_sg: Create the storage group directories for backup, + tv and streaming. Excludes artwork and video. + --add_fe_sg: Create the storage group directories for artwork + and video. Excludes backup, tv and streaming. + -h, --help: Show this help message. + --new_init: Erase the list of known disks and rescan. --no_destruction: Will not partition or format the disk. - This can be used to import disks from other systems. - --new_init: Erase the list of new disks and rescan. + All other normal operations will be performed. + Can be used to import disks from other systems. + --no_mount: Do not mount the disk. + All other normal operations will be performed. + --reconstruct: Recreate mount point, /myth symlink, fstab entry, + /data/storage/disk# symlink, and mount the disk. + no_mount is the only option that works with + reconstruct. --report: Scan disks and print new found disks. - --add_fe_sg: Create the storage group directories for artwork - and video. Excludes backup, tv and streaming. - --add_be_sg: Create the storage group directories for backup, - tv and streaming. ''' print help sys.exit(0) @@ -988,9 +1022,9 @@ if __name__ == "__main__": pass if not os.geteuid()==0: - sys.exit("\nRoot access is required to run this program\n") + sys.exit("\nRoot access is required to run this program.\n") - if "--help" in sys.argv: + if "--help" in sys.argv or "-h" in sys.argv: usage() if "--install_call" in sys.argv: @@ -1014,7 +1048,6 @@ if __name__ == "__main__": if "--add_be_sg" in sys.argv: dir_be_sg = True - if "--reconstruct" in sys.argv: reconstruct = True |