Add customizable backup, cache, and log directory

This commit is contained in:
JonnyWong16 2016-03-04 23:41:18 -08:00
parent 7f5d9bec87
commit 0569abd00d
3 changed files with 44 additions and 11 deletions

View file

@ -82,15 +82,15 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
</tr> </tr>
<tr> <tr>
<td>Backup Directory:</td> <td>Backup Directory:</td>
<td>${plexpy.CONFIG.BACKUP_DIR}</td> <td>${config['backup_dir']}</td>
</tr> </tr>
<tr> <tr>
<td>Cache Directory:</td> <td>Cache Directory:</td>
<td>${plexpy.CONFIG.CACHE_DIR}</td> <td>${config['cache_dir']}</td>
</tr> </tr>
<tr> <tr>
<td>Log Directory:</td> <td>Log Directory:</td>
<td>${plexpy.CONFIG.LOG_DIR}</td> <td>${config['log_dir']}</td>
</tr> </tr>
% if plexpy.ARGS: % if plexpy.ARGS:
<tr> <tr>
@ -169,6 +169,35 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
</label> </label>
<p class="help-block">Group successive play history by the same user as a single entry in the tables and watch statistics.</p> <p class="help-block">Group successive play history by the same user as a single entry in the tables and watch statistics.</p>
</div> </div>
<div class="padded-header">
<h3>Directories</h3>
</div>
<div class="form-group">
<label for="backup_dir">Backup Directory</label>
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control directory-settings" id="backup_dir" name="backup_dir" value="${config['backup_dir']}">
</div>
</div>
</div>
<div class="form-group">
<label for="cache_dir">Cache Directory</label>
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control directory-settings" id="cache_dir" name="cache_dir" value="${config['cache_dir']}">
</div>
</div>
</div>
<div class="form-group">
<label for="log_dir">Log Directory</label>
<div class="row">
<div class="col-md-6">
<input type="text" class="form-control directory-settings" id="log_dir" name="log_dir" value="${config['log_dir']}">
</div>
</div>
</div>
<p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p> <p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p>
</div> </div>
<div role="tabpanel" class="tab-pane" id="tabs-2"> <div role="tabpanel" class="tab-pane" id="tabs-2">
@ -1856,10 +1885,11 @@ $(document).ready(function() {
authChanged = false; authChanged = false;
httpChanged = false; httpChanged = false;
monitorChanged = false; monitorChanged = false;
directoryChanged = false;
// Alert the user that their changes require a restart. // Alert the user that their changes require a restart.
function postSaveChecks() { function postSaveChecks() {
if ((serverChanged && $('#monitoring_use_websocket').is(":checked")) || authChanged || httpChanged || monitorChanged) { if ((serverChanged && $('#monitoring_use_websocket').is(":checked")) || authChanged || httpChanged || monitorChanged || directoryChanged) {
$('#restart-modal').modal('show'); $('#restart-modal').modal('show');
} }
} }
@ -1972,6 +2002,10 @@ $(document).ready(function() {
monitorChanged = true; monitorChanged = true;
}); });
$( ".directory-settings" ).change(function() {
directoryChanged = true;
});
$( ".pms-settings" ).change(function() { $( ".pms-settings" ).change(function() {
serverChanged = true; serverChanged = true;
$("#pms_identifier").val(""); $("#pms_identifier").val("");

View file

@ -103,7 +103,7 @@ def initialize(config_file):
if not CONFIG.HTTPS_KEY: if not CONFIG.HTTPS_KEY:
CONFIG.HTTPS_KEY = os.path.join(DATA_DIR, 'server.key') CONFIG.HTTPS_KEY = os.path.join(DATA_DIR, 'server.key')
if not CONFIG.LOG_DIR.startswith(os.path.abspath(DATA_DIR)): if not CONFIG.LOG_DIR:
CONFIG.LOG_DIR = os.path.join(DATA_DIR, 'logs') CONFIG.LOG_DIR = os.path.join(DATA_DIR, 'logs')
if not os.path.exists(CONFIG.LOG_DIR): if not os.path.exists(CONFIG.LOG_DIR):
@ -120,8 +120,7 @@ def initialize(config_file):
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR, logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR,
verbose=VERBOSE) verbose=VERBOSE)
if not CONFIG.BACKUP_DIR.startswith(os.path.abspath(DATA_DIR)): if not CONFIG.BACKUP_DIR:
# Put the backup dir in the data dir for now
CONFIG.BACKUP_DIR = os.path.join(DATA_DIR, 'backups') CONFIG.BACKUP_DIR = os.path.join(DATA_DIR, 'backups')
if not os.path.exists(CONFIG.BACKUP_DIR): if not os.path.exists(CONFIG.BACKUP_DIR):
try: try:
@ -129,14 +128,13 @@ def initialize(config_file):
except OSError as e: except OSError as e:
logger.error("Could not create backup dir '%s': %s", BACKUP_DIR, e) logger.error("Could not create backup dir '%s': %s", BACKUP_DIR, e)
if not CONFIG.CACHE_DIR.startswith(os.path.abspath(DATA_DIR)): if not CONFIG.CACHE_DIR:
# Put the cache dir in the data dir for now
CONFIG.CACHE_DIR = os.path.join(DATA_DIR, 'cache') CONFIG.CACHE_DIR = os.path.join(DATA_DIR, 'cache')
if not os.path.exists(CONFIG.CACHE_DIR): if not os.path.exists(CONFIG.CACHE_DIR):
try: try:
os.makedirs(CONFIG.CACHE_DIR) os.makedirs(CONFIG.CACHE_DIR)
except OSError as e: except OSError as e:
logger.error("Could not create cache dir '%s': %s", DATA_DIR, e) logger.error("Could not create cache dir '%s': %s", CACHE_DIR, e)
# Initialize the database # Initialize the database
logger.info('Checking to see if the database has all tables....') logger.info('Checking to see if the database has all tables....')

View file

@ -1165,8 +1165,9 @@ class WebInterface(object):
"api_key": plexpy.CONFIG.API_KEY, "api_key": plexpy.CONFIG.API_KEY,
"update_db_interval": plexpy.CONFIG.UPDATE_DB_INTERVAL, "update_db_interval": plexpy.CONFIG.UPDATE_DB_INTERVAL,
"freeze_db": checked(plexpy.CONFIG.FREEZE_DB), "freeze_db": checked(plexpy.CONFIG.FREEZE_DB),
"log_dir": plexpy.CONFIG.LOG_DIR, "backup_dir": plexpy.CONFIG.BACKUP_DIR,
"cache_dir": plexpy.CONFIG.CACHE_DIR, "cache_dir": plexpy.CONFIG.CACHE_DIR,
"log_dir": plexpy.CONFIG.LOG_DIR,
"check_github": checked(plexpy.CONFIG.CHECK_GITHUB), "check_github": checked(plexpy.CONFIG.CHECK_GITHUB),
"interface_list": interface_list, "interface_list": interface_list,
"cache_sizemb": plexpy.CONFIG.CACHE_SIZEMB, "cache_sizemb": plexpy.CONFIG.CACHE_SIZEMB,