aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-11-11 01:12:29 +0800
committerYuqian Yang <crupest@crupest.life>2025-01-20 22:54:25 +0800
commit907eff64f175822e1113887a8b547490dadf9687 (patch)
tree572b99b62ea2edd2f2f34389b7d36d091b862546
parent5c76a1257b4a058bf919af3e31cc9461a39c2f33 (diff)
downloadcrupest-907eff64f175822e1113887a8b547490dadf9687.tar.gz
crupest-907eff64f175822e1113887a8b547490dadf9687.tar.bz2
crupest-907eff64f175822e1113887a8b547490dadf9687.zip
HALF WORK: 2024.1.20 - 3
-rw-r--r--.gitignore14
-rw-r--r--docker/v2ray/Dockerfile1
-rw-r--r--templates/README.md21
-rw-r--r--templates/docker-compose.yaml.template6
-rw-r--r--tools/cru-py/cru/service/_base.py23
5 files changed, 32 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore
index 9cc84ff..246ccc5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,11 +4,13 @@
/backup
/generated
-docker-compose.yaml
-crupest-api-config.json
-nginx-config
-v2ray-config.json
-v2ray-client-config.json
-forgejo.app.ini.init
+# old generated files
+/mailserver.env
+/docker-compose.yaml
+/crupest-api-config.json
+/nginx-config
+/v2ray-config.json
+/v2ray-client-config.json
+/forgejo.app.ini.init
tools/docker-mailserver-setup.sh
diff --git a/docker/v2ray/Dockerfile b/docker/v2ray/Dockerfile
index 003b545..250a6b8 100644
--- a/docker/v2ray/Dockerfile
+++ b/docker/v2ray/Dockerfile
@@ -3,4 +3,3 @@ FROM alpine:edge
RUN apk add --no-cache v2ray
ENTRYPOINT [ "/usr/bin/v2ray" ]
-
diff --git a/templates/README.md b/templates/README.md
deleted file mode 100644
index 729e596..0000000
--- a/templates/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-This directory contains the template files used to generate the final config files. They should not be used directly usually. Run `../tool/aio.py` to perform any generation and necessary setup.
-
-The template format is quite simple: they are just files containing `$VAR`s or `${VAR}`s. All variable names begin with `CRUPEST_` to avoid name conflicts.
-
-Here are the variables used in templates:
-| Variable | Description |
-| -------- | ----------- |
-| `CRUPEST_DOMAIN` | Domain to deploy. |
-| `CRUPEST_EMAIL` | Email address used in some cases like ssl cert. |
-| `CRUPEST_USER` | Your username. Run `id -un` to get it. |
-| `CRUPEST_GROUP` | Your group. Run `id -gn` to get it. |
-| `CRUPEST_UID` | Your uid. Run `id -u` to get it. |
-| `CRUPEST_GID` | Your gid. Run `id -g` to get it. |
-| `CRUPEST_HALO_DB_PASSWORD` | Used as halo's h2 database password. Better not to change it after first run. |
-| `CRUPEST_IN_CHINA` | Set to `true` if you are in China. |
-
-Note:
-
-1. `CRUPEST_{USER,GROUP,UID,GID}` are used to sync your account to some containers like `code-server` to avoid permission problems. You don't bother to manually set them as the python script will do it for you. However if you change them, you need to manually update it in config and regenerate something. But I don't really think you should change them.
-
-2. `CRUPEST_IN_CHINA` is used to set the mirror for some containers both in themselves or in the process of building them. It is default to `false`. If you are in China, you can set it to `true` to speed up the process.
diff --git a/templates/docker-compose.yaml.template b/templates/docker-compose.yaml.template
index cebdfb3..4ca1f1c 100644
--- a/templates/docker-compose.yaml.template
+++ b/templates/docker-compose.yaml.template
@@ -27,7 +27,7 @@ services:
- "443:443"
- "443:443/udp"
volumes:
- - "./nginx-config:/etc/nginx/conf.d:ro"
+ - "./generated/nginx:/etc/nginx/conf.d:ro"
- "./data/certbot/certs:/etc/letsencrypt:ro"
- "./data/certbot/webroot:/srv/acme:ro"
- "blog-public:/srv/www/blog:ro"
@@ -44,7 +44,7 @@ services:
container_name: v2ray
command: [ "run", "-c", "/etc/v2fly/config.json" ]
volumes:
- - "./v2ray-config.json:/etc/v2fly/config.json:ro"
+ - "./generated/v2ray-config.json:/etc/v2fly/config.json:ro"
restart: on-failure:3
auto-certbot:
@@ -97,7 +97,7 @@ services:
# you can assign this entirely to `hostname` and remove `domainname`.
hostname: mail
domainname: $CRUPEST_DOMAIN
- env_file: mailserver.env
+ env_file: generated/mailserver.env
# More information about the mail-server ports:
# https://docker-mailserver.github.io/docker-mailserver/edge/config/security/understanding-the-ports/
# To avoid conflicts with yaml base-60 float, DO NOT remove the quotation marks.
diff --git a/tools/cru-py/cru/service/_base.py b/tools/cru-py/cru/service/_base.py
index 90e1f85..6f2a61a 100644
--- a/tools/cru-py/cru/service/_base.py
+++ b/tools/cru-py/cru/service/_base.py
@@ -235,8 +235,25 @@ class CommandDispatcher(AppFeatureProvider):
self._parsed_args: argparse.Namespace | None = None
def setup_arg_parser(self) -> None:
+ epilog = """
+==> to start,
+./tools/manage init
+./tools/manage config init
+ln -s generated/docker-compose.yaml .
+# Then edit config file.
+
+==> to update
+git pull
+./tools/manage template generate --no-dry-run
+docker compose up
+ """.strip()
+
self._map: dict[str, AppCommandFeatureProvider] = {}
- arg_parser = argparse.ArgumentParser(description="Service management")
+ arg_parser = argparse.ArgumentParser(
+ description="Service management",
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ epilog=epilog,
+ )
arg_parser.add_argument(
"--project-dir",
help="The path of the project directory.",
@@ -245,7 +262,6 @@ class CommandDispatcher(AppFeatureProvider):
)
subparsers = arg_parser.add_subparsers(
dest="command",
- required=True,
help="The management command to execute.",
metavar="COMMAND",
)
@@ -275,6 +291,9 @@ class CommandDispatcher(AppFeatureProvider):
def run_command(self, args: argparse.Namespace | None = None) -> None:
real_args = args or self.get_program_parsed_args()
+ if real_args.command is None:
+ self.arg_parser.print_help()
+ return
self.map[real_args.command].run_command(real_args)