Skip to content

Commit

Permalink
add make targets to dump file storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Spine committed May 6, 2021
1 parent 6bb370a commit fec3aea
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
.DEFAULT_GOAL := help

NOW := $(shell date +'%Y%m%d-%H%M%S')
STORAGE_PATH_RIPLOG := $(shell scripts/getconf STORAGE_PATH_RIPLOG)
STORAGE_PATH_RIPLOGHTML := $(shell scripts/getconf STORAGE_PATH_RIPLOGHTML)
STORAGE_PATH_TORRENT := $(shell scripts/getconf STORAGE_PATH_TORRENT)

.SILENT: help
.PHONY: help
help:
echo ' help - output this message'
echo ' build-css - build the CSS'
echo ' dump-all - create tarballs of the following:'
echo ' dump-riplog - create a tarball of the rip logs'
echo ' dump-riploghtml - create a tarball of the HTMLified rip logs'
echo ' dump-torrent - create a tarball of the rip logs'
echo ' lint-css - lint (style check) the CSS'
echo ' mysqldump - dump mysql database from docker to db/data/gazelle.sql'
echo ' ocelot-reload-conf - signal Ocelot to reload its configuration'
Expand All @@ -17,6 +26,21 @@ help:
build-css:
yarn build:scss

.PHONY: dump-all
dump-all: dump-riplog dump-riploghtml dump-torrent

.PHONY: dump-riplog
dump-riplog:
tar -C "$(STORAGE_PATH_RIPLOG)/.." -jcf riplog.$(NOW).tar.bz2 "$$(basename $(STORAGE_PATH_RIPLOG))"

.PHONY: dump-riploghtml
dump-riploghtml:
tar -C "$(STORAGE_PATH_RIPLOGHTML)/.." -jcf riploghtml.$(NOW).tar.bz2 "$$(basename $(STORAGE_PATH_RIPLOGHTML))"

.PHONY: dump-torrent
dump-torrent:
tar -C "$(STORAGE_PATH_TORRENT)/.." -jcf torrent.$(NOW).tar.bz2 "$$(basename $(STORAGE_PATH_TORRENT))"

.PHONY: lint-css
lint-css:
yarn lint:css
Expand Down
36 changes: 36 additions & 0 deletions scripts/getconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! /usr/bin/env php
<?php

/**
* A command-line tool to expose configuration values
* Switches:
* -j encode the output as JSON (useful for arrays)
*
* usage:
* getconf SQLPASS
* (prints the db password)
*
* getconf -j RANKING_WEIGHT
* try it :)
*/

require_once(__DIR__ . '/../classes/config.php');

array_shift($argv);
$multi = count($argv) > 1;
$json = false;

foreach ($argv as $arg) {
switch($arg) {
case '-j':
$json = !$json;
break;
default:
$value = get_defined_constants()[$arg];
if ($json) {
echo json_encode($multi ? [$arg => $value] : $value), "\n";
} else {
echo ($multi ? "$arg: $value" : $value), "\n";
}
}
}

0 comments on commit fec3aea

Please sign in to comment.