2018-11-01 Fred Gleason <fredg@paravelsystems.com>

* Modified rdselect_helper(8) to use the automounter for managing
	audio store mounts.
This commit is contained in:
Fred Gleason 2018-11-01 13:14:49 -04:00
parent 171246c81f
commit f9e0e152ba
15 changed files with 133 additions and 33 deletions

View File

@ -17952,3 +17952,6 @@
* Incremented the package version to 3.0.0alpha01.
2018-10-30 Patrick Linstruth <patrick@deltecent.com>
* Added display of warnings from rddbmgr(8) to rddbconfig(8).
2018-11-01 Fred Gleason <fredg@paravelsystems.com>
* Modified rdselect_helper(8) to use the automounter for managing
audio store mounts.

View File

@ -681,6 +681,10 @@
<source>Open RDAdmin-&gt;ManageHosts-&gt;Add to create one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to update automounter configuration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -677,6 +677,10 @@
<source>Open RDAdmin-&gt;ManageHosts-&gt;Add to create one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to update automounter configuration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -677,6 +677,10 @@
<source>Open RDAdmin-&gt;ManageHosts-&gt;Add to create one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to update automounter configuration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -647,6 +647,10 @@
<source>Open RDAdmin-&gt;ManageHosts-&gt;Add to create one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to update automounter configuration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -677,6 +677,10 @@
<source>Open RDAdmin-&gt;ManageHosts-&gt;Add to create one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to update automounter configuration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -677,6 +677,10 @@
<source>Open RDAdmin-&gt;ManageHosts-&gt;Add to create one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to update automounter configuration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -677,6 +677,10 @@
<source>Open RDAdmin-&gt;ManageHosts-&gt;Add to create one.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unable to update automounter configuration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -814,6 +814,10 @@ QString RDConfig::rdselectExitCodeText(RDSelectExitCode code)
ret=QObject::tr("mount(8) crashed");
break;
case RDConfig::RDSelectCantAccessAutomount:
ret=QObject::tr("Unable to update automounter configuration");
break;
case RDConfig::RDSelectLast:
break;
}

View File

@ -51,7 +51,8 @@ class RDConfig
RDSelectSymlinkFailed=11,
RDSelectInvalidName=12,
RDSelectMountCrashed=13,
RDSelectLast=14};
RDSelectCantAccessAutomount=14,
RDSelectLast=15};
RDConfig();
RDConfig(const QString &filename);
QString filename() const;

View File

@ -1,6 +1,6 @@
## Makefile.am
##
## (C) Copyright 2012,2016-2018 Fred Gleason <fredg@paravelsystems.com>
## (C) Copyright 2012-2018 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
@ -30,9 +30,13 @@ moc_%.cpp: %.h
install-exec-hook:
mkdir -p $(DESTDIR)$(prefix)/share/rivendell
cp rdselect_*.qm $(DESTDIR)$(prefix)/share/rivendell
mkdir -p $(DESTDIR)/etc/auto.master.d
cp rd.audiostore.autofs $(DESTDIR)/etc/auto.master.d/
touch $(DESTDIR)/etc/auto.rd.audiostore
uninstall-local:
rm -f $(DESTDIR)$(prefix)/share/rivendell/rdselect_*.qm
rm -f $(DESTDIR)/etc/auto.master.d/rd.audiostore.autofs
all:
lupdate-qt4 rdselect.pro
@ -46,7 +50,8 @@ nodist_rdselect_SOURCES = moc_rdselect.cpp
rdselect_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ -lQt3Support
EXTRA_DIST = rdselect.pro\
EXTRA_DIST = rd.audiostore.autofs\
rdselect.pro\
rdselect_cs.ts\
rdselect_de.ts\
rdselect_es.ts\

View File

@ -0,0 +1 @@
/- /etc/auto.rd.audiostore

View File

@ -45,7 +45,7 @@ Requires: rivendell = @VERSION@, rivendell-webapi = @VERSION@
%package select
Summary: The RDSelect system selector tool for Rivendell.
Requires: rivendell = @VERSION@
Requires: rivendell = @VERSION@, autofs
%description
@ -141,6 +141,7 @@ cp scripts/rd_backup_system.sh $RPM_BUILD_ROOT/@DOC_PATH@/scripts/
cp scripts/rd_restore_system.sh $RPM_BUILD_ROOT/@DOC_PATH@/scripts/
cp scripts/engine_conv.py $RPM_BUILD_ROOT/@DOC_PATH@
cp scripts/init_template_host.py $RPM_BUILD_ROOT/@DOC_PATH@
rm -f $RPM_BUILD_ROOT/etc/auto.rd.audiostore
%post
@ -467,10 +468,20 @@ rm -rf $RPM_BUILD_ROOT
%files select
@LOCAL_PREFIX@/bin/rdselect
%attr(4755,root,root) @LOCAL_PREFIX@/bin/rdselect_helper
/etc/auto.master.d/rd.audiostore.autofs
@LOCAL_PREFIX@/bin/rdmonitor
/etc/X11/xinit/xinitrc.d/start-rdmonitor.sh
%post select
touch /etc/auto.rd.audiostore
systemctl restart autofs
%postun select
systemctl restart autofs
%changelog
* @RPM_DATESTAMP@ Fred Gleason <fredg@paravelsystems.com> - @VERSION@-@RPM_RELEASE@
-- Autogenerated from build tree.

View File

@ -96,38 +96,35 @@ void MainObject::Startup()
{
QStringList args;
QProcess *proc=NULL;
FILE *f=NULL;
//
// Mount the audio store
//
if(!helper_config->audioStoreMountSource().isEmpty()) {
args.clear();
if(!helper_config->audioStoreMountType().isEmpty()) {
args.push_back("-t");
args.push_back(helper_config->audioStoreMountType());
//
// Stop the Automounter
//
ControlAutomounter("stop");
//
// Update the Automounter
//
if((f=fopen(RDSELECT_AUTOMOUNT_CONFIG,"w"))==NULL) {
fprintf(stderr,
"rdselect_helper: unable to open automount configuration \"%s\" [%s]\n",
RDSELECT_AUTOMOUNT_CONFIG,
strerror(errno));
exit(RDConfig::RDSelectCantAccessAutomount);
}
args.push_back("-o");
if(helper_config->audioStoreMountOptions().isEmpty()) {
args.push_back("defaults");
}
else {
args.push_back(helper_config->audioStoreMountOptions());
}
args.push_back(helper_config->audioStoreMountSource());
args.push_back(helper_config->audioRoot());
proc=new QProcess(this);
proc->start("/bin/mount",args);
proc->waitForFinished();
if(proc->exitStatus()!=QProcess::NormalExit) {
fprintf(stderr,"rdselect_helper: mount(8) command crashed\n");
exit(RDConfig::RDSelectMountCrashed);
}
if(proc->exitCode()!=0) {
fprintf(stderr,"rdselect_helper: mount exited with error code %d\n",
proc->exitCode());
exit(RDConfig::RDSelectAudioMountFailed);
}
delete proc;
fprintf(f,"%s",RDSELECT_AUTOMOUNT_WARNING);
fprintf(f,"%s\t-fstype=%s\t%s\n",
(const char *)helper_config->audioRoot().toUtf8(),
(const char *)helper_config->audioStoreMountType().toUtf8(),
(const char *)helper_config->audioStoreMountSource().toUtf8());
fclose(f);
//
// Restart the Automounter
//
ControlAutomounter("start");
}
//
@ -160,6 +157,7 @@ void MainObject::Startup()
void MainObject::Shutdown()
{
QStringList args;
FILE *f=NULL;
//
// Stop Rivendell Service
@ -179,6 +177,11 @@ void MainObject::Shutdown()
}
delete proc;
//
// Stop the Automounter
//
ControlAutomounter("stop");
//
// Unmount the audio store
//
@ -190,6 +193,46 @@ void MainObject::Shutdown()
exit(RDConfig::RDSelectAudioUnmountFailed);
}
}
//
// Update the Automounter
//
if((f=fopen(RDSELECT_AUTOMOUNT_CONFIG,"w"))==NULL) {
fprintf(stderr,
"rdselect_helper: unable to open automount configuration \"%s\" [%s]\n",
RDSELECT_AUTOMOUNT_CONFIG,
strerror(errno));
exit(RDConfig::RDSelectCantAccessAutomount);
}
fprintf(f,"%s",RDSELECT_AUTOMOUNT_WARNING);
fclose(f);
//
// Restart the Automounter
//
ControlAutomounter("start");
}
void MainObject::ControlAutomounter(const QString &cmd)
{
QStringList args;
args.push_back(cmd);
args.push_back("autofs");
QProcess *proc=new QProcess(this);
proc->start("/bin/systemctl",args);
proc->waitForFinished();
if(proc->exitStatus()!=QProcess::NormalExit) {
fprintf(stderr,"rdselect_helper: systemctl(8) crashed\n");
exit(RDConfig::RDSelectSystemctlCrashed);
}
if(proc->exitCode()!=0) {
fprintf(stderr,
"rdselect_helper: automounter control failed [systemctl exit code: %d]\n",
proc->exitCode());
}
delete proc;
}

View File

@ -29,6 +29,9 @@
#include "rdconfig.h"
#define RDSELECT_AUTOMOUNT_CONFIG "/etc/auto.rd.audiostore"
#define RDSELECT_AUTOMOUNT_WARNING "# THE CONTENTS OF THIS FILE ARE MANAGED BY RIVENDELL'S RDSELECT SYSTEM!\n# DO NOT HAND EDIT!\n\n"
class MainObject : public QObject
{
Q_OBJECT;
@ -38,6 +41,7 @@ class MainObject : public QObject
private:
void Startup();
void Shutdown();
void ControlAutomounter(const QString &cmd);
bool ProcessActive(const QStringList &cmds) const;
bool ModulesActive() const;
QString helper_config_filename;