This is not so much a problem as a solution to a particular deployment configuration.
We have a js/react backend server which calls Realm ( our realm functions are part of our infrastructure to integrate Atlas Search (good stuff). Our backend is on ubuntu and managed with a CI (cleavr.io). When we git push Cleavr replaces the old distribution and creates a new one. I noticed that one of our deployment hooks was failing because a folder mongodb_realm is crreated and given root ownership. This makes sense, but also creates a problem. The Cleavr process doesn’t have root privileges so it can’t remove mongodb_realm. I found a solution by creating a zsh script to remove the old releases. Very simple and go around the problem of root ownership by adding the script to /etc/sudoers for the cleavr user.
cleavr ALL=(ALL:ALL) NOPASSWD: /home/ubuntu/clean
the clean script takes care of our med-dev BE server
!/usr/bin/zsh
SITE='/home/cleavr/med-dev.anydish.me/releases'
l=$(ls $SITE | wc -l)
m=$(($l-1))
if [ $l -gt 1 ];
then
for i in $(ls -rt $SITE | tail -n $m)
do
echo $i
rm -rf $i
done
echo 'DONE'
else
echo 'OK'
fi;
Since this took me more than a trivial amount of time I wanted to share the solution.
Hope this helps someone at sometime.