mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
chasquid-util: Use server for aliases-resolve and domaininfo-remove
This patch makes chasquid-util's aliases-resolve and domaininfo-remove commands talk to the chasquid server (via the new localrpc server). For aliases-resolve, currently has fairly hacky logic which reimplements a bunch of the servers', and is also incomplete because it does not support hooks. In this patch we fix that by having it talk to the server, where we get authoritative responses and have no issues with aliases hooks. This resolves https://github.com/albertito/chasquid/issues/18. For domaininfo-remove, currently its implementation is also very hacky since it manipulates files behind the servers' back and without even using the internal library. In this patch we fix that by doing the operation through the server, avoiding the need for those hacks, and also remove the need to manually reload the server afterwards.
This commit is contained in:
@@ -43,6 +43,17 @@ function chasquid() {
|
||||
"${TBASE}/../../chasquid" "$@"
|
||||
}
|
||||
|
||||
function chasquid-util() {
|
||||
# Run chasquid-util from inside the config dir, since in our tests
|
||||
# data_dir is relative to the config.
|
||||
CONFDIR="${CONFDIR:-config}"
|
||||
( cd "$CONFDIR" && \
|
||||
go run "${TBASE}/../../cmd/chasquid-util/chasquid-util.go" \
|
||||
-C=. \
|
||||
"$@" \
|
||||
)
|
||||
}
|
||||
|
||||
# Add a user with chasquid-util. Because this is somewhat cryptographically
|
||||
# intensive, it can slow down the tests significantly, so most of the time we
|
||||
# use the simpler add_user (below) for testing purposes.
|
||||
@@ -50,8 +61,7 @@ function chasquid-util-user-add() {
|
||||
CONFDIR="${CONFDIR:-config}"
|
||||
DOMAIN=$(echo "$1" | cut -d @ -f 2)
|
||||
mkdir -p "${CONFDIR}/domains/$DOMAIN/"
|
||||
go run "${TBASE}/../../cmd/chasquid-util/chasquid-util.go" \
|
||||
-C="${CONFDIR}" \
|
||||
chasquid-util \
|
||||
user-add "$1" \
|
||||
--password="$2" \
|
||||
>> .add_user_logs
|
||||
|
||||
Reference in New Issue
Block a user