mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Compare commits
3 Commits
5b06778a32
...
773e1aa199
Author | SHA1 | Date | |
---|---|---|---|
773e1aa199 | |||
4fd848abf2 | |||
013be7aa24 |
@ -1,5 +1,5 @@
|
|||||||
This assumes that you have Docker (version 17.05 or greater)
|
This assumes that you have Docker (version 19.03 or greater)
|
||||||
and Docker Compose (version 1.6.0 or greater) already installed.
|
and the Docker Compose CLI (version 1.27.0 or greater) already installed.
|
||||||
|
|
||||||
### Prepare things
|
### Prepare things
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ and Docker Compose (version 1.6.0 or greater) already installed.
|
|||||||
|
|
||||||
This pulls the latest containers from docker.io:
|
This pulls the latest containers from docker.io:
|
||||||
```console
|
```console
|
||||||
user@host:szuru$ docker-compose pull
|
user@host:szuru$ docker compose pull
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have modified the application's source and would like to manually
|
If you have modified the application's source and would like to manually
|
||||||
@ -49,17 +49,17 @@ and Docker Compose (version 1.6.0 or greater) already installed.
|
|||||||
|
|
||||||
For first run, it is recommended to start the database separately:
|
For first run, it is recommended to start the database separately:
|
||||||
```console
|
```console
|
||||||
user@host:szuru$ docker-compose up -d sql
|
user@host:szuru$ docker compose up -d sql
|
||||||
```
|
```
|
||||||
|
|
||||||
To start all containers:
|
To start all containers:
|
||||||
```console
|
```console
|
||||||
user@host:szuru$ docker-compose up -d
|
user@host:szuru$ docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
To view/monitor the application logs:
|
To view/monitor the application logs:
|
||||||
```console
|
```console
|
||||||
user@host:szuru$ docker-compose logs -f
|
user@host:szuru$ docker compose logs -f
|
||||||
# (CTRL+C to exit)
|
# (CTRL+C to exit)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -84,13 +84,13 @@ and Docker Compose (version 1.6.0 or greater) already installed.
|
|||||||
2. Build the containers:
|
2. Build the containers:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
user@host:szuru$ docker-compose build
|
user@host:szuru$ docker compose build
|
||||||
```
|
```
|
||||||
|
|
||||||
That will attempt to build both containers, but you can specify `client`
|
That will attempt to build both containers, but you can specify `client`
|
||||||
or `server` to make it build only one.
|
or `server` to make it build only one.
|
||||||
|
|
||||||
If `docker-compose build` spits out:
|
If `docker compose build` spits out:
|
||||||
|
|
||||||
```
|
```
|
||||||
ERROR: Service 'server' failed to build: failed to parse platform : "" is an invalid component of "": platform specifier component must match "^[A-Za-z0-9_-]+$": invalid argument
|
ERROR: Service 'server' failed to build: failed to parse platform : "" is an invalid component of "": platform specifier component must match "^[A-Za-z0-9_-]+$": invalid argument
|
||||||
@ -102,7 +102,7 @@ and Docker Compose (version 1.6.0 or greater) already installed.
|
|||||||
user@host:szuru$ export DOCKER_BUILDKIT=1; export COMPOSE_DOCKER_CLI_BUILD=1
|
user@host:szuru$ export DOCKER_BUILDKIT=1; export COMPOSE_DOCKER_CLI_BUILD=1
|
||||||
```
|
```
|
||||||
|
|
||||||
...and run `docker-compose build` again.
|
...and run `docker compose build` again.
|
||||||
|
|
||||||
*Note: If your changes are not taking effect in your builds, consider building
|
*Note: If your changes are not taking effect in your builds, consider building
|
||||||
with `--no-cache`.*
|
with `--no-cache`.*
|
||||||
@ -117,7 +117,7 @@ with `--no-cache`.*
|
|||||||
run from docker:
|
run from docker:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
user@host:szuru$ docker-compose run server ./szuru-admin --help
|
user@host:szuru$ docker compose run server ./szuru-admin --help
|
||||||
```
|
```
|
||||||
|
|
||||||
will give you a breakdown on all available commands.
|
will give you a breakdown on all available commands.
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
## Example Docker Compose configuration
|
## Example Docker Compose configuration
|
||||||
##
|
##
|
||||||
## Use this as a template to set up docker-compose, or as guide to set up other
|
## Use this as a template to set up docker compose, or as guide to set up other
|
||||||
## orchestration services
|
## orchestration services
|
||||||
version: '2'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
server:
|
server:
|
||||||
|
@ -13,7 +13,7 @@ from getpass import getpass
|
|||||||
from sys import stderr
|
from sys import stderr
|
||||||
|
|
||||||
from szurubooru import config, db, errors, model
|
from szurubooru import config, db, errors, model
|
||||||
from szurubooru.func import files, images
|
from szurubooru.func import files, images, snapshots
|
||||||
from szurubooru.func import posts as postfuncs
|
from szurubooru.func import posts as postfuncs
|
||||||
from szurubooru.func import users as userfuncs
|
from szurubooru.func import users as userfuncs
|
||||||
|
|
||||||
@ -100,6 +100,48 @@ def regenerate_thumbnails() -> None:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def delete_posts(parameters: list) -> None:
|
||||||
|
verification: str = input("Do you really want to delete all posts with the given ID's [y/n]: ").lower()
|
||||||
|
|
||||||
|
if "y" != verification:
|
||||||
|
return
|
||||||
|
|
||||||
|
def delete_one_post(post_id: int) -> None:
|
||||||
|
print("Deleting post %d" % post_id)
|
||||||
|
|
||||||
|
try:
|
||||||
|
post: model.Post = postfuncs.get_post_by_id(post_id)
|
||||||
|
except postfuncs.PostNotFoundError:
|
||||||
|
print("Post with ID %d not found" % post_id)
|
||||||
|
return
|
||||||
|
|
||||||
|
postfuncs.delete(post)
|
||||||
|
snapshots.delete(post, None)
|
||||||
|
|
||||||
|
def delete_multiple_posts(start_id: int, end_id: int) -> None:
|
||||||
|
if start_id > end_id:
|
||||||
|
start_id, end_id = end_id, start_id
|
||||||
|
|
||||||
|
for post_id in range(start_id, end_id + 1):
|
||||||
|
delete_one_post(post_id)
|
||||||
|
|
||||||
|
for parameter in parameters:
|
||||||
|
try:
|
||||||
|
if "-" not in parameter:
|
||||||
|
delete_one_post(int(parameter))
|
||||||
|
continue
|
||||||
|
|
||||||
|
post_range: list = [int(number) for number in parameter.split("-", 2)]
|
||||||
|
delete_multiple_posts(*post_range)
|
||||||
|
except ValueError:
|
||||||
|
print("One of the specified parameters is not a number")
|
||||||
|
return
|
||||||
|
|
||||||
|
db.get_session().commit()
|
||||||
|
|
||||||
|
print("All posts were deleted")
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
parser_top = ArgumentParser(
|
parser_top = ArgumentParser(
|
||||||
description="Collection of CLI commands for an administrator to use",
|
description="Collection of CLI commands for an administrator to use",
|
||||||
@ -129,6 +171,14 @@ def main() -> None:
|
|||||||
help="regenerate the thumbnails for posts if the "
|
help="regenerate the thumbnails for posts if the "
|
||||||
"thumbnail files are missing",
|
"thumbnail files are missing",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--delete-posts",
|
||||||
|
metavar="<post_ids>",
|
||||||
|
nargs='+',
|
||||||
|
help="Delete all posts with the specified ID, separated by a space. "
|
||||||
|
"Multiple posts can be deleted at once by specifying them as follows, "
|
||||||
|
"including the upper and lower limits: 37-47"
|
||||||
|
)
|
||||||
command = parser_top.parse_args()
|
command = parser_top.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -140,6 +190,8 @@ def main() -> None:
|
|||||||
reset_filenames()
|
reset_filenames()
|
||||||
elif command.regenerate_thumbnails:
|
elif command.regenerate_thumbnails:
|
||||||
regenerate_thumbnails()
|
regenerate_thumbnails()
|
||||||
|
elif command.delete_posts:
|
||||||
|
delete_posts(command.delete_posts)
|
||||||
except errors.BaseError as e:
|
except errors.BaseError as e:
|
||||||
print(e, file=stderr)
|
print(e, file=stderr)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user