mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-18 22:22:36 +02:00
2024-11-05 Fred Gleason <fredg@paravelsystems.com>
* Added a rdautocheck(8) utility. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
823f058d7b
commit
4f6f869c21
@ -24930,3 +24930,5 @@
|
||||
run on Python 3.6.
|
||||
* Fixed a regression in rdautorest(8) that caused it to crash when
|
||||
run on Python 3.6.
|
||||
2024-11-05 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a rdautocheck(8) utility.
|
||||
|
@ -57,6 +57,9 @@ all-local: rdadmin.1\
|
||||
rdautoback.8\
|
||||
rdautoback.html\
|
||||
rdautoback.pdf\
|
||||
rdautocheck.8\
|
||||
rdautocheck.html\
|
||||
rdautocheck.pdf\
|
||||
rdautorest.8\
|
||||
rdautorest.html\
|
||||
rdautorest.pdf\
|
||||
@ -114,6 +117,8 @@ man_MANS = rdadmin.1\
|
||||
rdalsaconfig.1\
|
||||
rdautoback.8\
|
||||
rdautorest.8\
|
||||
rdautocheck.8\
|
||||
rdautocheck.8\
|
||||
rdclilogedit.1\
|
||||
rd.conf.5\
|
||||
rdconvert.1\
|
||||
@ -148,6 +153,10 @@ EXTRA_DIST = exitcodes.xml\
|
||||
rdautoback.html\
|
||||
rdautoback.pdf\
|
||||
rdautoback.xml\
|
||||
rdautocheck.8\
|
||||
rdautocheck.html\
|
||||
rdautocheck.pdf\
|
||||
rdautocheck.xml\
|
||||
rdautorest.8\
|
||||
rdautorest.html\
|
||||
rdautorest.pdf\
|
||||
|
74
docs/manpages/rdautocheck.xml
Normal file
74
docs/manpages/rdautocheck.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<refentry id="stdin" xmlns="http://docbook.org/ns/docbook" version="5.0">
|
||||
<!--
|
||||
Header
|
||||
-->
|
||||
<refmeta>
|
||||
<refentrytitle>rdautocheck</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
<refmiscinfo class='source'>November 2024</refmiscinfo>
|
||||
<refmiscinfo class='manual'>Linux Audio Manual</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>rdautocheck</refname>
|
||||
<refpurpose>Display metadata for coherent Rivendell backups</refpurpose>
|
||||
</refnamediv>
|
||||
<info>
|
||||
<author>
|
||||
<personname>
|
||||
<firstname>Fred</firstname>
|
||||
<surname>Gleason</surname>
|
||||
<email>fredg@paravelsystems.com</email>
|
||||
</personname>
|
||||
<contrib>Application Author</contrib>
|
||||
</author>
|
||||
</info>
|
||||
|
||||
<!--
|
||||
Body
|
||||
-->
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>rdautocheck</command>
|
||||
<arg choice='req'><replaceable>mount-pt1</replaceable></arg>
|
||||
<arg choice='opt'><replaceable>mount-pt2</replaceable></arg>
|
||||
<arg choice='opt'>...</arg>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id='description'><title>Description</title>
|
||||
<para>
|
||||
<command>rdautocheck</command><manvolnum>8</manvolnum> is a command-line
|
||||
tool used for displaying the metadata for one or more coherent backups
|
||||
(database+audiostore) of the Rivendell Radio Automation System generated
|
||||
by <command>rdautoback</command><manvolnum>8</manvolnum>.
|
||||
</para>
|
||||
<para>
|
||||
<command>rdautocheck</command><manvolnum>8</manvolnum> will attempt
|
||||
to mount the filesystem corresponding to each mount point specified in
|
||||
its invocation and, if successful, print the contents of the
|
||||
<computeroutput>INFO.txt</computeroutput> file in the mounted filesystem
|
||||
to standard output, following which the volume will be unmounted.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='see_also'><title>See Also</title>
|
||||
<para>
|
||||
<citerefentry>
|
||||
<refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum>
|
||||
</citerefentry>
|
||||
,
|
||||
<citerefentry>
|
||||
<refentrytitle>rdautoback</refentrytitle><manvolnum>8</manvolnum>
|
||||
</citerefentry>
|
||||
,
|
||||
<citerefentry>
|
||||
<refentrytitle>rdautorest</refentrytitle><manvolnum>8</manvolnum>
|
||||
</citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
@ -479,6 +479,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_mandir}/man8/rdmarkerset.8.gz
|
||||
%{_mandir}/man8/rdservice.8.gz
|
||||
%{_mandir}/man8/rdautoback.8.gz
|
||||
%{_mandir}/man8/rdautocheck.8.gz
|
||||
%{_mandir}/man8/rdautorest.8.gz
|
||||
@DOC_PATH@/*
|
||||
%{_libdir}/librd-@VERSION@.so
|
||||
@ -500,6 +501,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_bindir}/rdsinglestart
|
||||
%{_sbindir}/rddbmgr
|
||||
%{_sbindir}/rdautoback
|
||||
%{_sbindir}/rdautocheck
|
||||
%{_sbindir}/rdautorest
|
||||
@HPI_FILE1@
|
||||
@HPI_FILE2@
|
||||
|
@ -21,6 +21,8 @@
|
||||
#
|
||||
|
||||
import configparser
|
||||
import datetime
|
||||
import MySQLdb
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
@ -70,6 +72,42 @@ os.system(command=cmd)
|
||||
cmd='rsync -av --delete /var/snd '+mountpoint
|
||||
os.system(command=cmd)
|
||||
|
||||
#
|
||||
# Generate Info File
|
||||
#
|
||||
with open(mountpoint+'/INFO.txt','w') as f:
|
||||
f.write('[Backup]\n')
|
||||
f.write('Name='+mountpoint+'\n')
|
||||
with os.popen('date --iso-8601=seconds',mode='r') as f1:
|
||||
f.write('DateTime='+f1.read())
|
||||
f1.close()
|
||||
try:
|
||||
db=MySQLdb.connect(user=rd_config.get('mySQL','Loginname'),
|
||||
passwd=rd_config.get('mySQL','Password'),
|
||||
host=rd_config.get('mySQL','Hostname'),
|
||||
database=rd_config.get('mySQL','Database'),
|
||||
charset='utf8mb4')
|
||||
except TypeError:
|
||||
db=MySQLdb.connect(user=rd_config.get('mySQL','Loginname'),
|
||||
password=rd_config.get('mySQL','Password'),
|
||||
host=rd_config.get('mySQL','Hostname'),
|
||||
database=rd_config.get('mySQL','Database'),
|
||||
charset='utf8mb4')
|
||||
cursor=db.cursor()
|
||||
cursor.execute('select `REALM_NAME` from `SYSTEM`')
|
||||
f.write('RealmName='+cursor.fetchone()[0]+'\n')
|
||||
cursor.execute('select `DB` from `VERSION`')
|
||||
f.write('DatabaseSchema='+str(cursor.fetchone()[0])+'\n')
|
||||
db.close()
|
||||
with os.popen('du -h '+mountpoint+'/snd',mode='r') as f1:
|
||||
values=f1.read().split('\t')
|
||||
f.write('AudioStorage='+values[0]+'\n')
|
||||
f1.close()
|
||||
with os.popen('ls -1 '+mountpoint+'/snd | wc -l') as f1:
|
||||
f.write('AudioFiles='+f1.read())
|
||||
f1.close()
|
||||
f.close()
|
||||
|
||||
#
|
||||
# Unmount backup device
|
||||
#
|
||||
|
37
utils/rdautocheck/Makefile.am
Normal file
37
utils/rdautocheck/Makefile.am
Normal file
@ -0,0 +1,37 @@
|
||||
## Makefile.am
|
||||
##
|
||||
## utils/rdautocheck Makefile.am for Rivendell
|
||||
##
|
||||
## (C) Copyright 2024 Fred Gleason <fredg@paravelsystems.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License version 2 as
|
||||
## published by the Free Software Foundation.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public
|
||||
## License along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
##
|
||||
##
|
||||
## Use automake to process this into a Makefile.in
|
||||
|
||||
install-exec-local:
|
||||
mkdir -p $(DESTDIR)/usr/sbin
|
||||
../../helpers/install_python.sh rdautocheck.py $(DESTDIR)/usr/sbin/rdautocheck
|
||||
|
||||
uninstall-local:
|
||||
rm -f $(DESTDIR)/usr/sbin/rdautocheck
|
||||
|
||||
noinst_SCRIPTS = rdautocheck.py
|
||||
|
||||
EXTRA_DIST = rdautocheck.py
|
||||
|
||||
CLEANFILES = *~
|
||||
|
||||
MAINTAINERCLEANFILES = *~\
|
||||
Makefile.in
|
69
utils/rdautocheck/rdautocheck.py
Executable file
69
utils/rdautocheck/rdautocheck.py
Executable file
@ -0,0 +1,69 @@
|
||||
#!%PYTHON_BANGPATH%
|
||||
|
||||
# rdautocheck.py
|
||||
#
|
||||
# Read metadata for Rivendell backup sets.
|
||||
#
|
||||
# (C) Copyright 2024 Fred Gleason <fredg@paravelsystems.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
|
||||
import configparser
|
||||
import datetime
|
||||
import MySQLdb
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import syslog
|
||||
|
||||
def PrintMetadata(mntpt):
|
||||
#
|
||||
# Mount backup device
|
||||
#
|
||||
Path(mntpt).mkdir(parents=True,exist_ok=True)
|
||||
result=os.WEXITSTATUS(os.system(command='mount '+mntpt+" 2> /dev/null"))
|
||||
if((result!=0)and(result!=64)):
|
||||
print(mntpt+': [not found]')
|
||||
print()
|
||||
return
|
||||
os.system(command='sleep 5')
|
||||
|
||||
#
|
||||
# Read Info File
|
||||
#
|
||||
try:
|
||||
with open(mntpt+'/INFO.txt','r') as f:
|
||||
print(mntpt+':')
|
||||
print(f.read())
|
||||
f.close()
|
||||
except FileNotFoundError:
|
||||
print(mntpt+':')
|
||||
print('[no metadata found]')
|
||||
print()
|
||||
|
||||
#
|
||||
# Unmount backup device
|
||||
#
|
||||
os.system(command='umount '+mntpt)
|
||||
os.rmdir(mntpt)
|
||||
|
||||
USAGE='rdautocheck.py <backup-mountpoint1> [<backup-mountpoint2>] [...]'
|
||||
|
||||
if(len(sys.argv)<2):
|
||||
print(USAGE)
|
||||
exit(1)
|
||||
for arg in range(1,len(sys.argv)):
|
||||
PrintMetadata(sys.argv[arg])
|
||||
|
Loading…
x
Reference in New Issue
Block a user