Skip to content

Commit

Permalink
merge .bin/ and scripts/ into a common bin/
Browse files Browse the repository at this point in the history
  • Loading branch information
Spine committed Sep 19, 2023
1 parent 2ba7991 commit d9358fc
Show file tree
Hide file tree
Showing 35 changed files with 28 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .docker/web/bootstrap-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ do
done

composer --version && composer install --no-progress
scripts/local-patch
bin/local-patch

echo "Create postgres database..."
#hostname:port:database:username:password
Expand Down Expand Up @@ -88,9 +88,9 @@ fi
if [ ! -d /var/lib/gazelle/torrent ]; then
echo "Generate file storage directories..."
time (
perl "${CI_PROJECT_DIR}/scripts/generate-storage-dirs" /var/lib/gazelle/torrent 2 100
perl "${CI_PROJECT_DIR}/scripts/generate-storage-dirs" /var/lib/gazelle/riplog 2 100
perl "${CI_PROJECT_DIR}/scripts/generate-storage-dirs" /var/lib/gazelle/riploghtml 2 100
perl "${CI_PROJECT_DIR}/bin/generate-storage-dirs" /var/lib/gazelle/torrent 2 100
perl "${CI_PROJECT_DIR}/bin/generate-storage-dirs" /var/lib/gazelle/riplog 2 100
perl "${CI_PROJECT_DIR}/bin/generate-storage-dirs" /var/lib/gazelle/riploghtml 2 100
)
chown -R gazelle /var/lib/gazelle
fi
Expand Down
2 changes: 1 addition & 1 deletion .docker/web/crontab
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PATH=$PATH:/var/www/scripts
PATH=$PATH:/var/www/bin
*/15 * * * * scheduler >> /tmp/schedule.log
6 changes: 3 additions & 3 deletions .docker/web/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ fi

if [ ! -d /var/lib/gazelle/torrent ]; then
echo "Generate file storage directories..."
perl /var/www/scripts/generate-storage-dirs /var/lib/gazelle/torrent 2 100
perl /var/www/scripts/generate-storage-dirs /var/lib/gazelle/riplog 2 100
perl /var/www/scripts/generate-storage-dirs /var/lib/gazelle/riploghtml 2 100
perl /var/www/bin/generate-storage-dirs /var/lib/gazelle/torrent 2 100
perl /var/www/bin/generate-storage-dirs /var/lib/gazelle/riplog 2 100
perl /var/www/bin/generate-storage-dirs /var/lib/gazelle/riploghtml 2 100
chown -R gazelle /var/lib/gazelle
fi

Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ phpstan:
- .composer
script:
- composer install --no-progress
- /bin/sh scripts/local-patch
- /bin/sh bin/local-patch
- phpstan analyse --no-progress --configuration misc/phpstan.neon

e2e-tests:
Expand Down Expand Up @@ -102,7 +102,7 @@ e2e-tests:
coverage: /^\s*Lines:\s*\d+.\d+\%/
script:
- /bin/bash "${CI_PROJECT_DIR}/.docker/web/bootstrap-base.sh"
- su gazelle -c "scripts/twig-parse \$(find templates -type f)"
- su gazelle -c "bin/twig-parse \$(find templates -type f)"
- /bin/bash "${CI_PROJECT_DIR}/.docker/web/start-services.sh"
- su gazelle -c "composer exec -- phpunit --configuration misc/phpunit.xml --coverage-php /tmp/coverage/phpunit.cov --exclude-group no-ci"
- /bin/bash "${CI_PROJECT_DIR}/.docker/web/bootstrap-yarn.sh"
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.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)
STORAGE_PATH_RIPLOG := $(shell bin/getconf STORAGE_PATH_RIPLOG)
STORAGE_PATH_RIPLOGHTML := $(shell bin/getconf STORAGE_PATH_RIPLOGHTML)
STORAGE_PATH_TORRENT := $(shell bin/getconf STORAGE_PATH_TORRENT)

.SILENT: help
.PHONY: help
Expand Down Expand Up @@ -63,7 +63,7 @@ lint-php:

.PHONY: lint-twig
lint-twig:
scripts/twig-parse $(find templates -type f)
bin/twig-parse $(find templates -type f)

.PHONY: mysqldump
mysqldump:
Expand Down
2 changes: 1 addition & 1 deletion app/Manager/SSLHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function lookup(string $hostname, int $port): array {
}
$notBefore = null;
$notAfter = null;
$output = explode("\n", trim((string)shell_exec(SERVER_ROOT . "/scripts/ssl-check $hostname $port")));
$output = explode("\n", trim((string)shell_exec(SERVER_ROOT . "/bin/ssl-check $hostname $port")));
if (count($output) != 2) {
return [];
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions scripts/migrate-logs.php → bin/migrate-logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
define('CHUNK', 100);

$offset = 0;
$last = 0;
$processed = 0;
$newLog = 0;
$errLog = 0;
Expand All @@ -40,8 +41,8 @@
while (list($logId, $torrentId, $log) = $db->next_record(MYSQLI_NUM, false)) {
$last = $logId;
++$processed;
if (file_exists($logFiler->pathLegacy([$torrentId, $logId])) && !file_exists($logFiler->path([$torrentId, $logId]))) {
if (!copy($logFiler->pathLegacy([$torrentId, $logId]), $logFiler->path([$torrentId, $logId]))) {
if (file_exists($logFiler->pathLegacy([$torrentId, $logId])) && !file_exists($logFiler->path([$torrentId, $logId]))) { /** @phpstan-ignore-line */
if (!copy($logFiler->pathLegacy([$torrentId, $logId]), $logFiler->path([$torrentId, $logId]))) { /** @phpstan-ignore-line */
++$errLog;
}
++$newLog;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
continue;
}
$db_digest = md5($db->scalar($config['MD5'], ...array_slice($match, 1)) . ($config['NEWLN'] ? "\n" : ''));
$file_digest = md5(file_get_contents($file));
$file_digest = md5((string)file_get_contents($file));
if ($db_digest != $file_digest) {
echo "$file contents $file_digest does not match db $db_digest\n";
++$mismatch;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/03-Voting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ will be 5 rows (from the five voters) in the users_votes table, and the
torrents_votes table will contain one row with Total = 5, Ups = 3.

If the `torrents_votes` is ever corrupted, it may be recreated with
`scripts/rebuild-votes`. There is some discrepancy in the code between the
`bin/rebuild-votes`. There is some discrepancy in the code between the
above formula and the use of binomial_ci(Ups, Total).

The user and group vote information are both cached. As the user object can
Expand Down
2 changes: 1 addition & 1 deletion docs/crontab
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# These are the cron jobs.
# Adjust PATH according to where the repository is checked out on the filesystem

PATH=$PATH:/var/www/scripts
PATH=$PATH:/var/www/bin

0,15,30,45 * * * * scheduler >> /tmp/schedule.log
* * * * * /usr/bin/indexer -c /etc/sphinx/sphinx.conf --rotate delta requests_delta log_delta > /dev/null
Expand Down
2 changes: 1 addition & 1 deletion lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
// Path for storing temporary files (should be moved out of the root partition)
defined('TMPDIR') or define('TMPDIR', '/tmp');

// Paths for storing uploaded assets outside the database. See scripts/generate-storage-dirs
// Paths for storing uploaded assets outside the database. See bin/generate-storage-dirs
// Should also be moved out of the root partition.
defined('STORAGE_PATH_TORRENT') or define('STORAGE_PATH_TORRENT', '/var/lib/gazelle/torrent');
defined('STORAGE_PATH_RIPLOG') or define('STORAGE_PATH_RIPLOG', '/var/lib/gazelle/riplog');
Expand Down
15 changes: 0 additions & 15 deletions misc/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2180,21 +2180,6 @@ parameters:
count: 1
path: ../classes/view.class.php

-
message: "#^Call to an undefined method Gazelle\\\\File\\\\RipLog\\:\\:pathLegacy\\(\\)\\.$#"
count: 2
path: ../scripts/migrate-logs.php

-
message: "#^Variable \\$last might not be defined\\.$#"
count: 2
path: ../scripts/migrate-logs.php

-
message: "#^Parameter \\#1 \\$string of function md5 expects string, string\\|false given\\.$#"
count: 1
path: ../scripts/recheck-file-storage.php

-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
Expand Down
4 changes: 2 additions & 2 deletions misc/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ parameters:
paths:
- ../lib/util.php
- ../app
- ../bin
- ../classes
- ../misc/phinx
- ../scripts
- ../tests
- ../sections
parallel:
Expand Down Expand Up @@ -92,7 +92,7 @@ parameters:
-
message: '/^Variable \$(?:Cache|DB|Debug|SessionID|Twig|Viewer) might not be defined\.$/'
paths:
- ../scripts/*
- ../bin/*
- ../sections/*
-
message: '/^Variable \$Router might not be defined\.$/'
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"prod": "cross-env NODE_ENV=production yarn build",
"build": "yarn build:scss && yarn build:previews",
"build:scss": "webpack --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"build:previews": "node scripts/render_styles_preview.js",
"build:previews": "node bin/render_styles_preview.js",
"start": "yarn build:scss -- --watch",
"lint:css": "stylelint \"sass/**/*.scss\" || exit 0",
"lint:css-checkstyle": "stylelint \"sass/**/*.scss\" --custom-formatter ./node_modules/stylelint-checkstyle-formatter/index.js || exit 0",
"lint:php:internal": "find . -path './vendor' -prune -o -path ./node_modules -prune -o -path './.docker' -prune -o -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | (! grep -v \"No syntax errors detected\" )",
"lint:php:phpcs": "vendor/bin/phpcs -p --report-width 1000",
"lint:php": "yarn lint:php:internal && yarn lint:php:phpcs",
"lint:php:fix": "./.bin/phpcbf",
"lint:php:fix": "bin/phpcbf",
"pre-commit": "yarn lint:php:fix",
"prepare": "husky install"
},
Expand Down Expand Up @@ -44,8 +44,8 @@
"lint-staged": {
"*.php": [
"vendor/bin/phpstan analyze --no-progress --configuration=misc/phpstan.neon --memory-limit 512M",
".bin/phpcs",
".bin/phpcbf"
"bin/phpcs",
"bin/phpcbf"
]
},
"browserslist": [
Expand Down

0 comments on commit d9358fc

Please sign in to comment.