Modifications to tools/nocem scripts to move config to config file.
This commit is contained in:
parent
5ec9cf5501
commit
d8d54b4d66
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/*
|
||||
* First, configure this file to match your system and needs.
|
||||
*
|
||||
* Copy messages to add to NoCeM list to $workpath/incoming
|
||||
* One message per file.
|
||||
*
|
||||
* Then run nocemlist.php to create nocem.out and header.out files
|
||||
* You may view these files before sending if you wish to confirm
|
||||
* all is working properly.
|
||||
*
|
||||
* Then run nocempost.sh to send NoCeM message to news server
|
||||
*
|
||||
* NOTE: If nocempost.sh does not exist, it will be created when
|
||||
* you run nocemlist.php
|
||||
*/
|
||||
|
||||
// Where these scripts reside and messages are created: (end with '/')
|
||||
// You must have write access to this directory
|
||||
$workpath = "/home/paris/BBS/nocem/";
|
||||
|
||||
$domain = "your_domain";
|
||||
$organization = "your_organization";
|
||||
$from = "from_address <from@example.com>";
|
||||
$from_email = "from@example.com";
|
||||
$contact = "your_email_address";
|
||||
|
||||
$gpglocaluser = "XXXXXXXX";
|
||||
$nntpserver = "news.example.com";
|
||||
$nntpuser = "nntpusername";
|
||||
$nntppassword = "nntppassword";
|
||||
|
||||
// Your gpg signing key:
|
||||
$signing_key = "XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX";
|
||||
// URL to view/download key:
|
||||
$key_location = "https://<key_url>";
|
||||
|
||||
// Comma separated list of newsgroups to send this message:
|
||||
$spamgroup = "alt.test,misc.test";
|
||||
|
||||
// The hierarchies where these nocem may apply.
|
||||
// Example: de.* or ALL
|
||||
$hierarchies = "the alt.* and de.* hierarchies";
|
||||
// $hierarchies = "ALL hierarchies";
|
||||
|
||||
// EDIT THE BELOW LINES to reflect your specific needs
|
||||
// NOTE: You may comment out any lines below you do not want
|
||||
|
||||
// Where to find your statement about how messages get listed
|
||||
$link_to_statement = "https://www.example.com/nocem/my_statement.html";
|
||||
|
||||
// Statement about the scope of your NoCeM messages:
|
||||
$scope = 'The scope of these messages is '. $hierarchies;
|
||||
|
||||
// Statement about where to find details of your nocem:
|
||||
$statement = "You may find information about how messages are listed here:\n" . $link_to_statement;
|
||||
|
||||
|
||||
/* ***** Please do not change anything below this line ***** */
|
||||
|
||||
$spamdir = $workpath."incoming";
|
||||
$nocem = $workpath."nocem.out";
|
||||
$headerdat = $workpath."header.out";
|
||||
|
||||
/* This creates nocempost.sh */
|
||||
|
||||
$nocempost = "#!/bin/bash\n\n";
|
||||
$nocempost .= "gpg2 --local-user $gpglocaluser --clearsign -a nocem.out\n\n";
|
||||
|
||||
$nocempost .= "newsserver=$nntpserver\n";
|
||||
$nocempost .= 'rpost $newsserver '."-U $nntpuser -P $nntppassword <<%end\n";
|
||||
$nocempost .= '$(<header.out)'."\n\n";
|
||||
|
||||
$nocempost .= '$(<nocem.out.asc)'."\n\n";
|
||||
|
||||
$nocempost .= '%end';
|
||||
|
||||
// If config is newer than nocempost.sh, trigger to recreate
|
||||
$nocempost_filename = $workpath . '/nocempost.sh';
|
||||
|
||||
$nocemconfig_mtime = filemtime($workpath . '/nocemlist.inc.php');
|
||||
if(file_exists($nocempost_filename)) {
|
||||
$nocempost_mtime = filemtime($nocempost_filename);
|
||||
} else {
|
||||
$nocempost_mtime = 0;
|
||||
}
|
||||
|
||||
if($nocemconfig_mtime > $nocempost_mtime) {
|
||||
$create_post = true;
|
||||
} else {
|
||||
$create_post = false;
|
||||
}
|
|
@ -1,45 +1,6 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* First, configure this file, and nocempost.sh to match
|
||||
* your system and needs.
|
||||
*
|
||||
* Copy messages to add to NoCeM list to $workpath/incoming
|
||||
* One message per file. (Move or delete these files when all
|
||||
* is complete)
|
||||
*
|
||||
* Then run nocemlist.php to create nocem.out and header.out files
|
||||
* You may view these files before sending if you wish to confirm
|
||||
* all is working properly.
|
||||
*
|
||||
* Then run nocempost.sh to send NoCeM message to news server
|
||||
*/
|
||||
|
||||
// Where these scripts reside and messages are created: (end with '/')
|
||||
$workpath = "/home/user/SPAM/";
|
||||
|
||||
$domain = "<your_domain>";
|
||||
$organization = "<your_organization>";
|
||||
$from = "from_address <from@example.com>";
|
||||
$from_email = "<from@example.com";
|
||||
$contact = "your_email_address";
|
||||
|
||||
// Your gpg signing key:
|
||||
$signing_key = "XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX";
|
||||
// URL to view/download key:
|
||||
$key_location = "https://<key_url>";
|
||||
|
||||
// Comma separated list of newsgroups to send this message:
|
||||
$spamgroup = "<where to send this message>";
|
||||
// Statement about the scope of your NoCeM messages:
|
||||
$scope = "The scope of these messages is the <my_hier>.* hierarchy";
|
||||
|
||||
/* END CONFIG */
|
||||
|
||||
$spamdir = $workpath."incoming";
|
||||
$nocem = $workpath."nocem.out";
|
||||
$headerdat = $workpath."header.out";
|
||||
include "nocemlist.inc.php";
|
||||
|
||||
$newspam = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($spamdir));
|
||||
$count = 0;
|
||||
|
@ -55,7 +16,7 @@ foreach($newspam as $spam) {
|
|||
$is_header = 1;
|
||||
foreach($spam_lines as $response) {
|
||||
if (trim($response) == "" && $lines > 0) {
|
||||
$is_header = 0;
|
||||
break;
|
||||
}
|
||||
if ($is_header == 1) {
|
||||
$lines ++;
|
||||
|
@ -115,6 +76,7 @@ fwrite($nocem_file, "The GPG key needed to verify the signature of cancels\n");
|
|||
fwrite($nocem_file, "issued by $from_email is available at:\n");
|
||||
fwrite($nocem_file, "$key_location\n\n");
|
||||
|
||||
fwrite($nocem_file, $statement."\n\n");
|
||||
fwrite($nocem_file, "For information contact $contact.\n\n");
|
||||
|
||||
fwrite($nocem_file, "@@BEGIN NCM HEADERS\n");
|
||||
|
@ -133,4 +95,10 @@ foreach($nocem_list as $list) {
|
|||
|
||||
fwrite($nocem_file, "@@END NCM BODY");
|
||||
fclose($nocem_file);
|
||||
|
||||
// Create nocempost.sh if it is older than config
|
||||
if($create_post) {
|
||||
file_put_contents($nocempost_filename, $nocempost);
|
||||
chmod($nocempost_filename, 0700);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
gpglocaluser="XXXXXXXX"
|
||||
nntpserver="news.example.com"
|
||||
nntpuser="nntpusername"
|
||||
nntppassword="nntppassword"
|
||||
|
||||
gpg2 --local-user $gpglocaluser --clearsign -a nocem.out
|
||||
|
||||
newsserver=$nntpserver
|
||||
today=$(date -u +%F-%H:%M)
|
||||
id=$(od -xvAn -N8 < /dev/urandom | tr -cd 0-9a-f)
|
||||
rpost $newsserver -U $nntpuser -P $nntppassword <<%end
|
||||
$(<header.out)
|
||||
|
||||
$(<nocem.out.asc)
|
||||
|
||||
%end
|
Loading…
Reference in New Issue