summaryrefslogtreecommitdiffstats
path: root/abs
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2013-11-05 23:42:22 (GMT)
committerBritney Fransen <brfransen@gmail.com>2013-11-05 23:42:22 (GMT)
commit01740e9b44790cc449ce7a2f414bc9ba062f2d83 (patch)
tree90878dcf4a2985670959cf5a4dbab97f1247ba1a /abs
parent1ba192c81b182943e580b2ad2b029b98210c6209 (diff)
downloadlinhes_pkgbuild-01740e9b44790cc449ce7a2f414bc9ba062f2d83.zip
linhes_pkgbuild-01740e9b44790cc449ce7a2f414bc9ba062f2d83.tar.gz
linhes_pkgbuild-01740e9b44790cc449ce7a2f414bc9ba062f2d83.tar.bz2
LinHES-system: add_storage.py: add fstype to conf file on install and if it is missing add it. closes #934
other cosmetic changes and clarifications
Diffstat (limited to 'abs')
-rwxr-xr-xabs/core/LinHES-system/PKGBUILD4
-rw-r--r--abs/core/LinHES-system/add_storage.py187
2 files changed, 125 insertions, 66 deletions
diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD
index c8d791e..a28ecfa 100755
--- a/abs/core/LinHES-system/PKGBUILD
+++ b/abs/core/LinHES-system/PKGBUILD
@@ -1,6 +1,6 @@
pkgname=LinHES-system
pkgver=8.0
-pkgrel=30
+pkgrel=31
arch=('i686' 'x86_64')
install=system.install
pkgdesc="Everything that makes LinHES an automated system"
@@ -94,7 +94,7 @@ md5sums=('5ee78704cab0e88ec58d1aab821fc1aa'
'bc69a520add58ede9b060c73e67ace13'
'26fdd26e945f0c187f9fdcf98a7a5bef'
'47e093e8cfe4b5b96602358e1f540832'
- 'a8e486f5d23913242b6edb862bf44c0e'
+ '2cc4a31e086f2370439156b027dec7cd'
'2c005d95312018bef80092136f80f254'
'6519d209e151cdc39ae7e1091d189c3e'
'8f474e019d5fcb775497aca355d61b0b'
diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py
index 1f166b1..72056f8 100644
--- a/abs/core/LinHES-system/add_storage.py
+++ b/abs/core/LinHES-system/add_storage.py
@@ -1,8 +1,9 @@
#!/usr/bin/python2
-#Program used to auto_add new storage to mythtv storage groups
-#If it's a new disk it will erase the entire disk and reformat
+#add_storage.py used to auto add new storage to MythTV storage groups
+#If it's a new disk it will erase the entire disk and reformat.
#
-#Drives that are mount, in fstab, size < 5000 bytes, optical or have already been seen will not be presented as an option.
+#Disks that are mounted, in fstab, size < 5000 bytes, optical or
+#have already been seen will not be presented as an option.
#
@@ -290,8 +291,10 @@ class disk_device:
return
def mkdirs(self,FS_LIST):
- print " Creating Directory stucture"
+ print " Creating directory structure:"
+ print " %s" %self.new_mount_point
for y in FS_LIST:
+ print " %s" %y
new_dir="%s/%s" %(self.new_mount_point,y)
try:
os.stat(new_dir)
@@ -319,7 +322,7 @@ class disk_device:
with DB as c:
try:
c.execute("""insert into storagegroup (groupname,hostname,dirname) values (%s,%s,%s)""",(gn,hn,dn))
- print " Adding location: %s to storagegroup %s" %(dn,gn)
+ print " Adding location: %s to storagegroup %s" %(dn,gn)
except:
print " *Error inserting %s into storage groups" %dn
@@ -339,10 +342,11 @@ class disk_device:
return
def write_config(self):
- print " Writing out storage.d conf file"
+ print " Writing /etc/storage.d conf file"
self.config.add_section('storage')
self.config.set('storage','uuid',self.uuid)
self.config.set('storage','mountpoint',self.new_mount_point)
+ self.config.set('storage','fstype',self.new_fstype)
self.config.set('storage','shareable','True')
self.config.set('storage','mmount',self.mmount)
self.config.set('storage','disk_num',self.disk_num)
@@ -352,24 +356,25 @@ class disk_device:
self.serial_number.replace(' ',''))
configfile="/etc/storage.d/%s" %filename
- print " %s" %configfile
+ print " %s" %configfile
with open(configfile, 'wb') as configfile:
self.config.write(configfile)
return
def symlink_disk(self):
- print " Creating symlink for disk number"
+ print " Creating symlink for disk%s" %self.disk_num
disk_ln="%s/disk%s" %(self.top_mount_dir,self.disk_num)
cmd = "ln -s %s %s" %(self.new_mount_point,disk_ln)
- print cmd
runcmd(cmd)
def symlink(self):
pass
- print " Creating symlink"
- cmd = "ln -s %s/media /myth " %(self.new_mount_point)
- runcmd(cmd)
-
+ print " Creating symlink for /myth"
+ if not os.path.exists("/myth"):
+ cmd = "ln -s %s/media /myth " %(self.new_mount_point)
+ runcmd(cmd)
+ else:
+ print " Skipping symlink, /myth already exists"
#end of class
@@ -442,16 +447,15 @@ def prompt_to_add(current_drive,destruction = True):
loop = True
if destruction :
prompt = '''
- Adding the drive will remove all contents on the drive.
+ Adding the disk will remove all contents on the disk.
- Do you wish enable this drive for MythTV storage(Y/N)?:
- '''
+ Do you wish enable this disk for MythTV storage(Y/N)?:'''
else:
prompt = '''
** Preserving existing data **
will not format or partition
- Do you wish enable this drive for MythTV storage(Y/N)?:
+ Do you wish enable this disk for MythTV storage(Y/N)?:
'''
while loop:
str1 = raw_input(prompt)
@@ -470,7 +474,7 @@ def prompt_to_continue():
loop = True
#while loop:
print "\n\n\n\n"
- str1 = raw_input("\n Ready to add additional storage!\n Press Y to continue, anything else to abort:")
+ str1 = raw_input("\n Ready to add additional storage!\n Press Y to add disk(s), anything else to abort:")
#if str1 in ['Y','N','y','n']:
# loop = False
@@ -487,15 +491,15 @@ def prompt_sg(dir_be_sg,dir_fe_sg):
#check for backend storage groups
if dir_be_sg != True:
loop = True
- print "*" * 40
+ print "*" * 60
prompt_string='''
- Backend Storage Groups are used for things like
- TV Recordings and database backups.
+ Backend Storage Groups are used for
+ database backups, TV recordings and streaming.
The content on these storage groups will
only be available while the system is online.
- Do you wish enable this system for Backend Storage Groups(Y/N)?:'''
+ Do you wish enable Backend Storage Groups(Y/N)?:'''
while loop:
str1 = raw_input(prompt_string)
@@ -514,13 +518,15 @@ def prompt_sg(dir_be_sg,dir_fe_sg):
#now for frontend storage groups
if dir_fe_sg != True:
loop = True
+ print ""
print "+" * 20
prompt_string='''
- Frontend Storage Groups are used for videos.
+ 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 this system for Frontend Storage Groups(Y/N)?:'''
+ Do you wish enable Frontend Storage Groups(Y/N)?:'''
while loop:
str1 = raw_input(prompt_string)
if str1 in ['Y','N','y','n']:
@@ -535,11 +541,14 @@ def prompt_sg(dir_be_sg,dir_fe_sg):
dir_fe_sg = False
print " ** Will NOT add Frontend Storage Groups!"
+ print ""
+ print "*" * 60
+
return dir_be_sg,dir_fe_sg
def remove_pickle():
try:
- print "* Resetting list of known drives."
+ print "* Resetting list of known disks."
os.remove(pickle_file)
except:
pass
@@ -565,6 +574,8 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg):
process_list=[]
no_process_list=[]
+ print "-" * 60
+ print " Scan for Disks"
for i in system_drive_list:
#print i.mount_path
@@ -575,8 +586,16 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg):
#print "--"
if search_for_match(i,known_drive_list) or i.in_use :
+ if search_for_match(i,known_drive_list) :
+ dstatus = " Ignoring - Disk has been previously skipped:"
+ if i.in_use :
+ dstatus = " Ignoring - Disk is mounted:"
+ if search_for_match(i,known_drive_list) and i.in_use :
+ dstatus = " Ignoring - Disk has been previously skipped and is mounted:"
+
print "\n"
- print " Storage is already in use or previously skipped:%s" %i.model
+ print dstatus
+ print " model: %s" %i.model
print " location: %s" %i.block_path
print " size: %s" %i.device_size
continue
@@ -584,10 +603,11 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg):
else:
if not scan_only:
print "\n"
- print "-------------------------------------------------------------"
- print " Found new hard drive: %s" %i.model
- print " location: %s" %i.block_path
- print " size: %s " %i.device_size
+ print " --------------------------------------------------------"
+ 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!"
@@ -596,15 +616,22 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg):
no_process_list.append(i)
else:
process_list.append(i)
- print " End of scan"
- print "---------------------------------------"
+ print "\n"
+ print " End of Scan"
+ print "-" * 60
if scan_only:
if len(process_list) > 0:
+ print " Unknown or unmounted disks:"
f = open('/tmp/scan_report', 'w')
for i in process_list:
- f.write("drive: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size))
- print "drive: %s , location: %s ,size: %s \n" %(i.model,i.block_path,i.device_size)
+ 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 " model: %s" %i.model
+ print " location: %s" %i.block_path
+ print " size: %s " %i.device_size
f.close()
sys.exit(0)
@@ -619,7 +646,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 storage to add.\n"
+ print "\nDid not find any new disks to add.\n"
write_known_drive_list(system_drive_list)
#BE = MythBE(db=DB)
@@ -630,14 +657,14 @@ def main(scan_only, destruction, no_mount, install_call , dir_fe_sg, dir_be_sg):
if len(process_list) > 0:
- print " Will add %s disks to systems" %len(process_list)
+ 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:
write_known_drive_list(system_drive_list)
disk_num = last_disk_num()
for i in process_list:
- print " Drive: %s" %(i.get_name())
+ print " Disk: %s" %(i.get_name())
disk_num = disk_num + 1
if destruction == True:
i.partition_disk()
@@ -713,7 +740,7 @@ def myth_main(no_mount,install_call,dir_fe_sg):
host=gethostname()
- print " Drive: %s" %(i.get_name())
+ print " Disk: %s" %(i.get_name())
i.set_mmount(True)
i.set_partition("7")
i.set_disk_num(0)
@@ -736,7 +763,7 @@ class reconstruct_path:
self.conf_file = conf_file
parser = SafeConfigParser()
parser.read(self.conf_file)
-
+ self.config = ConfigParser.RawConfigParser()
self.uuid = parser.get('storage', 'uuid')
self.mount_point = parser.get('storage', 'mountpoint')
@@ -745,9 +772,22 @@ class reconstruct_path:
self.bind = self.myth_mount
self.disk_num = parser.get('storage', 'disk_num')
self.top_mount_dir = os.path.dirname(self.mount_point)
+ try:
+ self.fstype = parser.get('storage', 'fstype')
+ except:
+ self.fstype = self.get_fstype()
+
+ def get_fstype(self):
+ cmd = "fsck -N UUID=%s" %self.uuid
+ tmpfstype = runcmd(cmd)
+ tmpfstype = tmpfstype[1].split('/sbin/fsck.')
+ tmpfstype = tmpfstype[1].split(' ')
+ self.fstype = tmpfstype[0]
+ self.write_config()
+ return self.fstype
def get_conf(self):
- return self.conf_file
+ return self.conf_file
def get_uuid(self):
return self.uuid
@@ -809,15 +849,15 @@ class reconstruct_path:
f.close()
def symlink(self):
- print " Creating symlink"
+ print " Creating symlink for /myth"
if not os.path.exists("/myth"):
cmd = "ln -s %s/media /myth " %(self.mount_point)
runcmd(cmd)
else:
- print " Skipping symlink, path already present"
+ print " Skipping symlink, /myth already exists"
def symlink_disk(self):
- print " Creating symlink for disk number"
+ print " Creating symlink for disk%s" %self.disk_num
disk_ln="%s/disk%s" %(self.top_mount_dir,self.disk_num)
cmd = "ln -s %s %s" %(self.mount_point,disk_ln)
runcmd(cmd)
@@ -825,14 +865,14 @@ class reconstruct_path:
def add_fstab(self):
#new_fstab_list=['UUID=', 'mount_point', 'auto', 'defaults', '0', '1']
- new_fstab_list=['UUID=', 'mount_point', self.new_fstype, 'defaults', '0', '1']
+ new_fstab_list=['UUID=', 'mount_point', self.fstype, 'defaults', '0', '1']
fstab=self.read_fstab()
if self.bind == "True":
self.symlink()
if self.check_in_fstab(fstab,self.uuid) == True:
- print " Found storage in fstab, will not add it"
+ print " Found disk in fstab, will not add it"
else:
print " Adding storage to fstab"
if self.bind == "True" :
@@ -861,8 +901,23 @@ class reconstruct_path:
runcmd(cmd)
return
+ def write_config(self):
+ print " Writing /etc/storage.d conf file"
+ self.config.add_section('storage')
+ self.config.set('storage','uuid',self.uuid)
+ self.config.set('storage','mountpoint',self.mount_point)
+ self.config.set('storage','fstype',self.fstype)
+ self.config.set('storage','shareable','True')
+ self.config.set('storage','mmount',self.myth_mount)
+ self.config.set('storage','disk_num',self.disk_num)
+
+ print " %s" %self.conf_file
+ with open(self.conf_file, 'wb') as self.conf_file:
+ self.config.write(self.conf_file)
+ return
+
def reconstruct_mounts(no_mount):
- print "Recreating devices based on contents of /etc/storage.d"
+ print "Recreating disks based on contents of /etc/storage.d"
for conf_file in glob.glob('%s/*.conf' %storage_dir):
print "\n"
cf = reconstruct_path(conf_file)
@@ -883,26 +938,34 @@ def reconstruct_mounts(no_mount):
def usage():
- help='''\n
- Add storage is designed to find and setup new disks for mythtv usage.
- It's a powerfull tool that could destroy data if not used correctly, so please be careful.
+ 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.
+
+ The file system type for disks added by add_storage.py is
+ automatically set to the type you selected at install.
+
Normal operations include (in this order):
Partition the disk
Format the disk
Add disk to /etc/fstab
Mount the disk
- Create the directory
+ Create the directories
Write out the config file to /etc/storage.d
- Add new locations to mythtv storage groups
-
- options:
-
- --no_mount : Do not mount the disk, only add it to /etc/fstab and create the dir.
- --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.
- --report : will scan the disks and print out if it found new storage.
- --add_fe_sg : Will only create the storage group dir for videos..excludes tv
- --add_be_sg : Will only create the storage group dir for TV, backups, streaming
+ 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.
+ --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.
+ --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)
@@ -961,7 +1024,3 @@ if __name__ == "__main__":
reconstruct_mounts(no_mount)
else:
main(scan_only,destruction,no_mount, install_call, dir_fe_sg, dir_be_sg)
-
-
-
-