Add script to build db for 0.6.7 and comments in INSTALL.md

This commit is contained in:
Retro_Guy 2020-12-24 20:12:50 -07:00
parent 3929441d33
commit c46e9a3767
2 changed files with 69 additions and 3 deletions

View File

@ -46,11 +46,17 @@ Upgrading:
1. Disable cron job and kill any running nntp servers (ps aux | grep nntp)
2. Run upgrade script and answer promts
2. BACKUP spool dir. Default example: 'cd /var/spool' then 'tar zcvf rslight.tgz rslight/*'
3. Compare upgrade config files in config dir /upgrade and change your exsiting config as necessary
3. Run upgrade script and answer prompts
4. Enable cron job and check that everything works after it runs the first time
4. Compare upgrade config files in config dir /upgrade and change your exsiting config as necessary
5. If upgrading from a version prior to 0.6.7 it is REQUIRED to run the provided
script 'build-overview-db.php' at this point. Read the script for instructions.
NOTE: If upgrading and your spool dir does not include any files ending in .db3, you need to do this.
6. Enable cron job and check that everything works after it runs the first time
If you have trouble, post to rocksolid.nodes.help and we'll try to help.

60
build-overview-db.php Normal file
View File

@ -0,0 +1,60 @@
<?php
####################
# This script creates articles-overview.db3 in your spool directory from
# pre 0.6.7 -overview files
# This is REQUIRED to upgrade from pre 0.6.7 versions
# This script MUST be run as your web user (debian = www-data)
#
# To create the file do the following:
# Disable access to site (to disallow posting)
# Disable cron job for rslight
# Disable rslight nntp servers running (kill PID)
# cd to your spool directory. Default is /var/spool/rslight
# For each section you must run this script:
# php /path/to/script rocksolid
# php /path/to/script spoolnews
# php /path/to/script othersection
# etc...
# Re-enable cron job and access to site
# That should be all that is necessary
####################
$database = 'articles-overview.db3';
$table = 'overview';
$dbh = rslight_db_open($database, $table);
$sql = "INSERT INTO overview(newsgroup, number, msgid, date, name, subject) VALUES(?,?,?,?,?,?)";
$stmt = $dbh->prepare($sql);
$overviewfp = fopen($argv[1].'-overview', 'r');
echo "Building $database";
$i = 0;
while($data=fgets($overviewfp)) {
$parts=preg_split("/(:#rsl#:|\t)/", $data);;
$stmt->execute([$parts[0], $parts[1], $parts[2], $parts[3], $parts[4], $parts[5]]);
if($i++ > 100) {
echo '.';
$i = 0;
}
}
echo "\nFinished.\n";
fclose($overviewfp);
$dbh = null;
function rslight_db_open($database, $table) {
try {
$dbh = new PDO('sqlite:'.$database);
} catch (PDOExeption $e) {
echo 'Connection failed: '.$e->getMessage();
exit;
}
$dbh->exec("CREATE TABLE IF NOT EXISTS $table(
id INTEGER PRIMARY KEY,
newsgroup TEXT,
number TEXT,
msgid TEXT,
date TEXT,
name TEXT,
subject TEXT)");
return($dbh);
}
?>