Skip to content

Commit

Permalink
add photo from url
Browse files Browse the repository at this point in the history
  • Loading branch information
Fmstrat committed May 12, 2023
1 parent 1967056 commit fda13ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN \
inetutils-ping \
ldb-tools \
vim \
curl \
ntp &&\
apt-get clean autoclean &&\
apt-get autoremove --yes &&\
Expand Down
23 changes: 21 additions & 2 deletions domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Usage:
domain change-password <user>
domain edit <user or group>
domain set-user-ssh-key <user> <pubkey>
domain set-user-photo <user> <"$(base64 -w0 /path/to/img)>">
domain set-user-photo-from-file <user> <"$(base64 -w0 /path/to/img)>">
domain set-user-photo-from-url <user> <url>
domain add-user-to-group <user> <group>
domain remove-user-from-group <user> <group>
domain update-ip <domain> <controller> <oldip> <newip>
Expand Down Expand Up @@ -143,7 +144,7 @@ sshPublicKey: ${3}"
echo "${MOD}" | ldbmodify -H /var/lib/samba/private/sam.ldb
fi
;;
set-user-photo)
set-user-photo-from-file)
DN=$(ldbedit -H /var/lib/samba/private/sam.ldb -e cat "samaccountname=${2}" | grep ^dn: |sed 's/^dn: //g')
CURPHOTO=$(ldbedit -H /var/lib/samba/private/sam.ldb -e cat "samaccountname=${2}" | { grep ^jpegPhoto: || true; })
if [ -z "${CURPHOTO}" ]; then
Expand All @@ -160,6 +161,24 @@ jpegPhoto: ${3}"
echo "${MOD}" | ldbmodify -H /var/lib/samba/private/sam.ldb
fi
;;
set-user-photo-from-url)
DN=$(ldbedit -H /var/lib/samba/private/sam.ldb -e cat "samaccountname=${2}" | grep ^dn: |sed 's/^dn: //g')
CURPHOTO=$(ldbedit -H /var/lib/samba/private/sam.ldb -e cat "samaccountname=${2}" | { grep ^jpegPhoto: || true; })
B64=$(curl -s "${3}" |base64 -w0)
if [ -z "${CURPHOTO}" ]; then
MOD="dn: ${DN}
changetype: modify
add: jpegPhoto
jpegPhoto: ${B64}"
echo "${MOD}" | ldbmodify -H /var/lib/samba/private/sam.ldb
else
MOD="dn: ${DN}
changetype: modify
replace: jpegPhoto
jpegPhoto: ${B64}"
echo "${MOD}" | ldbmodify -H /var/lib/samba/private/sam.ldb
fi
;;
*)
usage;
esac

0 comments on commit fda13ac

Please sign in to comment.