Add scripts, add gitea CI
All checks were successful
Build Docker images / docker (1) (push) Successful in 1m21s
All checks were successful
Build Docker images / docker (1) (push) Successful in 1m21s
This commit is contained in:
parent
fcee0594d4
commit
9cef6de7af
36
.gitea/workflows/build.yml
Normal file
36
.gitea/workflows/build.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
name: Build Docker images
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- "1"
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
-
|
||||||
|
name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
-
|
||||||
|
name: Build and push image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: eumau/dovecot:${{ matrix.version }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
11
confd/conf.d/add_ldap_group.toml
Normal file
11
confd/conf.d/add_ldap_group.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[template]
|
||||||
|
src = "add_ldap_group.tmpl"
|
||||||
|
prefix = "/ldap"
|
||||||
|
dest = "/usr/local/bin/add_ldap_group"
|
||||||
|
mode = "0755"
|
||||||
|
keys = [
|
||||||
|
"/admin/cn",
|
||||||
|
"/admin/password",
|
||||||
|
"/domain",
|
||||||
|
"/domain/dn",
|
||||||
|
]
|
100
confd/templates/add_ldap_group.tmpl
Normal file
100
confd/templates/add_ldap_group.tmpl
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
assert(){ [[ $? -eq 0 ]] || { [[ -n ${1} ]] && echo ${@} ; exit 1 ; } }
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
usage: docker exec [...] add_ldap_group [-c COMMON_NAME] [-u UID] [-p PASSWORD] [-e EMAIL]
|
||||||
|
Unset options will be prompted interactively.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
COMMON_NAME=
|
||||||
|
USER_UID=
|
||||||
|
USER_EMAIL=
|
||||||
|
USER_PASS=
|
||||||
|
SURNAME=
|
||||||
|
while getopts "c: u: e: p:" OPCION
|
||||||
|
do
|
||||||
|
case ${OPCION} in
|
||||||
|
"c")
|
||||||
|
COMMON_NAME=${OPTARG}
|
||||||
|
;;
|
||||||
|
"s")
|
||||||
|
SURNAME=${OPTARG}
|
||||||
|
;;
|
||||||
|
"u")
|
||||||
|
USER_UID=${OPTARG}
|
||||||
|
;;
|
||||||
|
"e")
|
||||||
|
USER_EMAIL=${OPTARG}
|
||||||
|
;;
|
||||||
|
"p")
|
||||||
|
USER_PASS=${OPTARG}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
LDAP_ADMIN_CN="{{ getv "/admin/cn" }}"
|
||||||
|
LDAP_ADMIN_PASSWORD="{{ getv "/admin/password" }}"
|
||||||
|
LDAP_DOMAIN="{{ getv "/domain" }}"
|
||||||
|
LDAP_DOMAIN_DN="{{ getv "/domain/dn" }}"
|
||||||
|
|
||||||
|
DN0="dc=${LDAP_DOMAIN//./,dc=}"
|
||||||
|
LDAP_DOMAIN_DN=${LDAP_DOMAIN_DN:=${DN0}}
|
||||||
|
|
||||||
|
[[ -n ${USER_UID} ]] || {
|
||||||
|
echo -n "Enter user UID (e.g. jdoe) > "
|
||||||
|
read USER_UID
|
||||||
|
}
|
||||||
|
|
||||||
|
# echo "Check if uid=${USER_UID},ou=People,${LDAP_DOMAIN_DN} exists"
|
||||||
|
RES_DN=$(ldapsearch -LLL -H ldap:/// -D cn=${LDAP_ADMIN_CN},${LDAP_DOMAIN_DN} \
|
||||||
|
-w "${LDAP_ADMIN_PASSWORD}" -s base \
|
||||||
|
-b "uid=${USER_UID},ou=People,${LDAP_DOMAIN_DN}" \
|
||||||
|
"(objectClass=*)" 2>/dev/null \
|
||||||
|
| egrep '^dn: ' | sed -e 's/^dn: //g' )
|
||||||
|
[[ -z ${RES_DN} ]]
|
||||||
|
assert "User already present. Please choose a different UID."
|
||||||
|
|
||||||
|
[[ -n ${COMMON_NAME} ]] || {
|
||||||
|
echo -n "Enter user CN (e.g. John Doe) > "
|
||||||
|
read COMMON_NAME
|
||||||
|
}
|
||||||
|
[[ -n ${SURNAME} ]] || {
|
||||||
|
echo -n "Enter user SN (e.g. Doe) > "
|
||||||
|
read SURNAME
|
||||||
|
}
|
||||||
|
[[ -n ${USER_PASS} ]] || {
|
||||||
|
echo -n "Enter user password (will not be echoed) > "
|
||||||
|
read -s USER_PASS
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
[[ -n ${USER_EMAIL} ]] || {
|
||||||
|
echo -n "Enter user email (leave blank for ${USER_UID}@${LDAP_DOMAIN}) > "
|
||||||
|
read USER_EMAIL
|
||||||
|
}
|
||||||
|
USER_EMAIL="${USER_EMAIL:=${USER_UID}@${LDAP_DOMAIN}}"
|
||||||
|
|
||||||
|
|
||||||
|
PWHASH=$(slappasswd -h "{SSHA}" -s "${USER_PASS}")
|
||||||
|
|
||||||
|
echo "Creating user uid=${USER_UID},ou=People,${LDAP_DOMAIN_DN}"
|
||||||
|
ldapadd -H ldap:/// -D cn=${LDAP_ADMIN_CN},${LDAP_DOMAIN_DN} \
|
||||||
|
-w "${LDAP_ADMIN_PASSWORD}" <<-EOF
|
||||||
|
dn: uid=${USER_UID},ou=People,${LDAP_DOMAIN_DN}
|
||||||
|
objectClass: inetOrgPerson
|
||||||
|
objectClass: organizationalPerson
|
||||||
|
objectClass: person
|
||||||
|
objectClass: top
|
||||||
|
cn: ${COMMON_NAME}
|
||||||
|
sn: ${SURNAME}
|
||||||
|
uid: ${USER_UID}
|
||||||
|
userPassword: ${PWHASH}
|
||||||
|
mail: ${USER_EMAIL}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
assert "Error adding user!"
|
@ -70,6 +70,7 @@ assert "User already present. Please choose a different UID."
|
|||||||
[[ -n ${USER_PASS} ]] || {
|
[[ -n ${USER_PASS} ]] || {
|
||||||
echo -n "Enter user password (will not be echoed) > "
|
echo -n "Enter user password (will not be echoed) > "
|
||||||
read -s USER_PASS
|
read -s USER_PASS
|
||||||
|
echo ""
|
||||||
}
|
}
|
||||||
[[ -n ${USER_EMAIL} ]] || {
|
[[ -n ${USER_EMAIL} ]] || {
|
||||||
echo -n "Enter user email (leave blank for ${USER_UID}@${LDAP_DOMAIN}) > "
|
echo -n "Enter user email (leave blank for ${USER_UID}@${LDAP_DOMAIN}) > "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user