Skip to content

Commit

Permalink
supervisord: run sogod.sh as root then step down to sogo user
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol authored May 15, 2024
1 parent df64655 commit 7bababa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
15 changes: 0 additions & 15 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
#!/bin/bash

if [ -z "$LD_PRELOAD" ]; then
LIBSSL_LOCATION=$(find / -type f -name "libssl.so.*" -print -quit 2>/dev/null)
echo "LD_PRELOAD=$LIBSSL_LOCATION" >> /etc/default/sogo
echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:$LD_LIBRARY_PATH" >> /etc/default/sogo
export LD_PRELOAD=$LIBSSL_LOCATION
else
echo "LD_PRELOAD=$LD_PRELOAD" >> /etc/default/sogo
if [ -z "$LD_LIBRARY_PATH" ]; then
echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:/usr/local/lib:/usr/lib" >> /etc/default/sogo
else
echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:/usr/local/lib:$LD_LIBRARY_PATH" >> /etc/default/sogo
fi
export LD_PRELOAD=$LD_PRELOAD
fi

# Set process UID and GID at runtime
if [ -n "$PUID" ] && [ -n "$PGID" ]; then
groupmod -g $PGID sogo
Expand Down
19 changes: 17 additions & 2 deletions sogod.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
#!/bin/bash

if [ -z "$LD_PRELOAD" ]; then
LIBSSL_LOCATION=$(find / -type f -name "libssl.so.*" -print -quit 2>/dev/null)
echo "LD_PRELOAD=$LIBSSL_LOCATION" >> /etc/default/sogo
echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:$LD_LIBRARY_PATH" >> /etc/default/sogo
export LD_PRELOAD=$LIBSSL_LOCATION
else
echo "LD_PRELOAD=$LD_PRELOAD" >> /etc/default/sogo
if [ -z "$LD_LIBRARY_PATH" ]; then
echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:/usr/local/lib:/usr/lib" >> /etc/default/sogo
else
echo "LD_LIBRARY_PATH=/usr/local/lib/sogo:/usr/local/lib:$LD_LIBRARY_PATH" >> /etc/default/sogo
fi
export LD_PRELOAD=$LD_PRELOAD
fi

if [ -f /etc/default/sogo ]; then
. /etc/default/sogo
fi

. /lib/lsb/init-functions
. /usr/share/GNUstep/Makefiles/GNUstep.sh

/usr/local/sbin/sogod -WONoDetach YES -WOLogFile /var/log/sogo/sogo.log
# Run SOGo in foreground
su -s /bin/sh -c '/usr/local/sbin/sogod -WONoDetach YES -WOLogFile /var/log/sogo/sogo.log' sogo
3 changes: 1 addition & 2 deletions supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ logfile_maxbytes=0

[program:sogo]
command=/opt/sogod.sh
environment=LD_PRELOAD="%(ENV_LD_PRELOAD)s"
user=sogo
user=root
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand Down

0 comments on commit 7bababa

Please sign in to comment.