diff --git a/CHANGELOG.md b/CHANGELOG.md index a661fe65eb1b91dd678d607ad3c44bcef685125f..339cee741d0242ab1c4a9ef17564b4316098475d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,14 @@ The format is based on [Keep a Changelog] and this project adheres to [Semantic ## [Unreleased] ### Added ### Changed +- add.php test for pod meta like update.php ### Deprecated ### Removed ### Fixed +- init call on new setup sets up the needed items +- missing tables.sql item from version 2.5.2 +- missing table on tables.sql +- link to osada repo updated ### Security ## [2.5.2] - 2019-01-29 diff --git a/README.md b/README.md index 8a0fb048e4e16de576937d7c14afce16bc09c39c..feabde923de7b7868ecb50da679e47b9e9aef771 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Environmental items you need (debian based system assumed): OS Dependencies: ``` -php7.2 php7.2-curl php7.2-pgsql php7.2-bcmath php-geoip php7.2-cli php7.2-common php7.2-bcmath php7.2-json php7.2-readline php7.2-mbstring php7.2-xml php-cgi git curl postgresql postgresql-contrib dnsutils bind9 npm nodejs composer +php7.2 php7.2-curl php7.2-pgsql php7.2-bcmath php-geoip php7.2-cli php7.2-common php7.2-fpm php7.2-bcmath php7.2-json php7.2-readline php7.2-mbstring php7.2-xml php-cgi git curl postgresql postgresql-contrib dnsutils bind9 npm nodejs composer ``` Yarn is a separate install: https://yarnpkg.com @@ -41,10 +41,14 @@ Import database schema psql -U podupuser podupdb < db/tables.sql ``` +Configure your webserver (nginx example) +``` +see file http-server-config.example +``` + 1. Edit `config.php` to add your DB and file settings -2. Touch add.log in location you configured in config.php -3. Create your backup folder -4. Add a pod and run `php db/update.php init` +2. Create your backup folder +3. Add a pod and run `php db/update.php init` # To Use: diff --git a/db/add.php b/db/add.php index c967902d04bccd112021c49a06737ac759c0628b..7a28a52a5a27284204565b6f468a58e7f5502ff1 100644 --- a/db/add.php +++ b/db/add.php @@ -82,13 +82,20 @@ EOF; } if (!$stop) { - $link = 'https://' . $_domain . '/nodeinfo/1.0'; - $nodeinfo = curl('https://' . $_domain . '/.well-known/nodeinfo'); - if ($info = json_decode($nodeinfo['body'] ?: '', true)) { - $link = max($info['links'])['href']; + $nodeinfo_meta = curl("https://{$_domain}/.well-known/nodeinfo"); + + // Default link to fetch node info. + $nodeinfo_url = "https://{$_domain}/nodeinfo/1.0"; + + if ($info = json_decode($nodeinfo_meta['body'] ?: '', true)) { + if (count($info['links'], COUNT_RECURSIVE) === 2) { + $nodeinfo_url = $info['links']['href']; + } else { + $nodeinfo_url = max($info['links'])['href']; + } } - $output = curl($link, true); + $output = curl($nodeinfo_url, true); if ($output['body'] && stripos($output['body'], 'openRegistrations') !== false) { echo 'Your pod has ssl and is valid
'; @@ -125,6 +132,6 @@ if (!$stop) { echo 'Data successfully inserted! Your pod will be checked and live on the list in a few hours!'; } else { - echo 'Could not validate your pod, check your setup!
Take a look at your /nodeinfo'; + echo 'Could not validate your pod, check your setup!
Take a look at your nodeinfo'; } } diff --git a/db/tables.sql b/db/tables.sql index 9e4709351c698192c8e6a6a95c57010cb8b277de..e46bd5241c5168c8f28a788fdc4a6202ef5b07bd 100644 --- a/db/tables.sql +++ b/db/tables.sql @@ -96,6 +96,16 @@ CREATE TABLE masterversions ( date_checked timestamp DEFAULT current_timestamp ); +CREATE TABLE monthlystats ( + id serial8 UNIQUE PRIMARY KEY, + total_users int, + total_posts int, + total_comments int, + total_pods int, + total_uptime int, + date_checked timestamp DEFAULT current_timestamp +); + CREATE TABLE meta ( id serial8 UNIQUE PRIMARY KEY, name text, @@ -110,3 +120,4 @@ INSERT INTO meta (name) VALUES('federation_updated'); INSERT INTO meta (name) VALUES('statstable_updated'); INSERT INTO meta (name) VALUES('backup'); INSERT INTO meta (name) VALUES('pods_updated'); +INSERT INTO meta (name) VALUES('sitemap_updated'); \ No newline at end of file diff --git a/db/update-masterversions.php b/db/update-masterversions.php index 49c110fa31f0cafcf8d9711fb3bd8e1b44c0a2a4..e7dd490cabf3c0cf2217c68ec63dbfdc738e2da4 100644 --- a/db/update-masterversions.php +++ b/db/update-masterversions.php @@ -25,7 +25,7 @@ $softwares = [ 'writefreely' => ['repo' => 'writeas/writefreely', 'gitsite' => 'api.github.com', 'gittype' => 'github', 'devbranch' => 'develop'], 'ganggo' => ['repo' => 'ganggo%2fganggo', 'gitsite' => 'git.feneas.org', 'gittype' => 'gitlab', 'devbranch' => ''], 'funkwhale' => ['repo' => 'funkwhale%2ffunkwhale', 'gitsite' => 'code.eliotberriot.com', 'gittype' => 'gitlab', 'devbranch' => 'develop'], - 'osada' => ['repo' => 'macgirvin%2fosada', 'gitsite' => 'framagit.org', 'gittype' => 'gitlab', 'devbranch' => 'dev'], + 'osada' => ['repo' => 'zot%2fosada', 'gitsite' => 'framagit.org', 'gittype' => 'gitlab', 'devbranch' => 'dev'], ]; $opts = [ diff --git a/db/update-remote-data.php b/db/update-remote-data.php index 6ca48238eedc7885c7b5faf8121f5ecbf3872df2..8b3e0f7d2ebb2ce97021567b6314cb2cbbe8eb2a 100644 --- a/db/update-remote-data.php +++ b/db/update-remote-data.php @@ -33,7 +33,6 @@ $foundpods = []; //pulling all nodes for now $federationpods = curl('https://the-federation.info/graphql?query=%7Bnodes%7Bhost%20platform%7Bname%7Dprotocols%7Bname%7D%7D%7D&raw'); if ($pods = json_decode($federationpods['body'] ?: '', true)) { - ; foreach ($pods['data']['nodes'] ?? [] as $poddata) { $protocols = array_column($poddata['protocols'] ?? [], 'name'); diff --git a/db/update.php b/db/update.php index dc85e8722a144665d09e92445742f2e4407adfed..ad48ad23db61a39f197a16841d207b26dc1e7a30 100644 --- a/db/update.php +++ b/db/update.php @@ -29,6 +29,7 @@ if (!is_connected()) { $time_start = microtime(true); $debug = isset($_GET['debug']) || (isset($argv) && in_array('debug', $argv, true)); +$init = isset($_GET['init']) || (isset($argv) && in_array('init', $argv, true)); $sqldebug = isset($_GET['sqldebug']) || (isset($argv) && in_array('sqldebug', $argv, true)); $develop = isset($_GET['develop']) || (isset($argv) && in_array('develop', $argv, true)); $write = !(isset($_GET['nowrite']) || (isset($argv) && in_array('nowrite', $argv, true))); @@ -449,33 +450,33 @@ if (!$_domain) { $time_end = microtime(true); $execution_time = ($time_end - $time_start) / 60; updateMeta('pods_update_runtime', round($execution_time)); - if ($languagesupdated) { + if ($languagesupdated || $init) { updateMeta('languages_updated'); } - if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('masterversions_updated', 'date_created'))->diffInHours() > 12) { + if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('masterversions_updated', 'date_created'))->diffInHours() > 12 || $init) { require __DIR__ . '/update-masterversions.php'; } - if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('statstable_updated', 'date_created'))->diffInHours() > 23) { + if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('statstable_updated', 'date_created'))->diffInHours() > 23 || $init) { require __DIR__ . '/update-monthly-stats.php'; } - if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('cacert_updated', 'date_created'))->diffInHours() > 40) { + if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('cacert_updated', 'date_created'))->diffInHours() > 40 || $init) { copy('https://curl.haxx.se/ca/cacert.pem', c('cafullpath')); updateMeta('cacert_updated'); } - if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('sitemap_updated', 'date_created'))->diffInHours() > 2) { + if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('sitemap_updated', 'date_created'))->diffInHours() > 2 || $init) { require __DIR__ . '/update-sitemap.php'; } - if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('geoip_updated', 'date_created'))->diffInHours() > 45) { + if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('geoip_updated', 'date_created'))->diffInHours() > 45 || $init) { copy('compress.zlib://http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', c('geoip2db')); updateMeta('geoip_updated'); } - if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('federation_updated', 'date_created'))->diffInHours() > 9) { + if (Carbon::createFromFormat('Y-m-d H:i:s.u', getMeta('federation_updated', 'date_created'))->diffInHours() > 9 || $init) { require __DIR__ . '/update-remote-data.php'; }