X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fprivate%2Fftp_sync.sh;fp=modules%2Fprivate%2Fftp_sync.sh;h=0000000000000000000000000000000000000000;hb=1a64deeb894dc95e2645a75771732c6cc53a79ad;hp=8b0d9c5f2736f69d10f45b3d177f37983fc246fb;hpb=fa25ffd4583cc362075cd5e1b4130f33306103f0;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/ftp_sync.sh b/modules/private/ftp_sync.sh deleted file mode 100755 index 8b0d9c5..0000000 --- a/modules/private/ftp_sync.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -LDAPSEARCH=ldapsearch - -LDAP_BIND="cn=ssh,ou=services,dc=immae,dc=eu" -LDAP_PASS=$(cat /etc/ssh/ldap_password) -LDAP_HOST="ldap.immae.eu" -LDAP_BASE="dc=immae,dc=eu" -LDAP_FILTER="(memberOf=cn=users,cn=ftp,ou=services,dc=immae,dc=eu)" - -handle_keys() { - uids="$1" - keys="$2" - if [ -n "$uids" ]; then - for uid in $uids; do - echo "$keys" | while read key; do - if [ -n "$key" ]; then - ssh-keygen -e -f <(echo "$key") - fi - done > /var/lib/proftpd/authorized_keys/$uid - done - fi -} - -mkdir -p /var/lib/proftpd/authorized_keys - -while read i; do - if [[ "$i" =~ ^dn: ]]; then - handle_keys "$uids" "$keys" - uids="" - keys="" - fi; - if [[ "$i" =~ ^uid: ]]; then - uids="$uids ${i#uid: }" - fi - if [[ "$i" =~ ^immaeSshKey: ]]; then - key="${i#immaeSshKey: }" - if [[ "$key" =~ ^ssh- ]]; then - keys="$keys -$key" - elif echo "$key" | cut -d" " -f1 | grep -q "\bftp\b"; then - keys="$keys -$(echo "$key" | cut -d" " -f2-)" - fi - fi -done < <(ldapsearch -h "$LDAP_HOST" -ZZ -LLL -D "$LDAP_BIND" -w "$LDAP_PASS" -b "$LDAP_BASE" -x -o ldif-wrap=no "$LDAP_FILTER" uid immaeSshKey) -handle_keys "$uids" "$keys"