Your question
I have this script, that works but not the part with the aliases.
how can i make it work with that too?
#!/usr/bin/env bash
set -euo pipefail
CLI=“stalwart-cli”
URL=“https://domain.de”
API_KEY=“API_3ZQ”
echo “== Lade Domains ==”
DOMAINS_OUTPUT=$(
$CLI --url “$URL”
–api-key “$API_KEY”
query Domain
)
echo “”
echo “Verfügbare Domains:”
echo “--------------------”
echo “$DOMAINS_OUTPUT”
echo “”
read -rp "Account Name (name): " NAME
read -rp "Full Name: " FULL_NAME
read -rp "Domain ID: " DOMAIN_ID
read -rp "Aliase (kommagetrennt, leer = keine): " ALIASES_INPUT
ALIASES_JSON=“”
if [[ -n “${ALIASES_INPUT:-}” ]]; then
IFS=‘,’ read -ra ALIASES_ARRAY <<< “$ALIASES_INPUT”
ALIASES_JSON=“[”
first=true
for alias in “${ALIASES_ARRAY[@]}”; do
alias=$(echo “$alias” | xargs)
[[ -z “$alias” ]] && continue
if [[ "$first" == true ]]; then
first=false
else
ALIASES_JSON+=","
fi
ALIASES_JSON+="{\"localPart\":\"$alias\",\"domainId\":\"$DOMAIN_ID\",\"enabled\":true}"
done
ALIASES_JSON+=“]”
fi
echo “== Erstelle Account ==”
$CLI --url “$URL”
–api-key “$API_KEY”
create Account/User
–field “name=$NAME”
–field “description=$FULL_NAME”
–field “domainId=$DOMAIN_ID”
–field ‘credentials={“0”:{“@type”:“Password”,“secret”:“AnfangsPasswort”}}’
–field ‘memberGroupIds={}’
–field ‘roles={“@type”:“User”}’
–field ‘permissions={“@type”:“Inherit”}’
–field ‘locale=de_DE’
–field ‘timeZone=Europe/Berlin’
–field ‘quotas={“maxDiskQuota”:524288000}’
–field “aliases={}”
–field ‘encryptionAtRest={“@type”:“Disabled”}’
$CLI --url “$URL”
–api-key “$API_KEY”
update Account/User
–field “name=$NAME”
–field “aliases=$ALIASES_JSON”
root@netcup-server1:/opt/stalwart#
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on