Samba-ad-dc-with-docker/entrypoint.sh

54 lines
971 B
Bash
Raw Normal View History

2022-10-08 14:27:26 +09:00
#!/bin/bash
echo "Start Samba container with parameter : $@"
trap sig_term SIGTERM
sig_term() {
echo "CATCH SIGTERM"
pkill -SIGTERM ^samba$
/usr/sbin/apachectl stop
case $SMB_PURPOSE in
"primary")
pkill -SIGTERM ^rsync$
;;
"secondary")
pkill -SIGTERM ^cron$
;;
esac
if [ $SMB_USEBIND9 = "true" ]; then
/usr/sbin/rndc stop
fi
wait
exit 0
}
# Make configuration
case $SMB_PURPOSE in
"primary") /root/packages/config-primary.sh;;
"secondary") /root/packages/config-secondary.sh;;
"restore") /root/packages/config-restore.sh;;
*) echo "Purporse do not match. : "$SMB_PURPOSE
esac
# Execute paramater.
exec "$@"
# Start services.
/usr/sbin/samba --interactive --no-process-group &
/usr/sbin/apachectl start
case $SMB_PURPOSE in
"primary")
/usr/bin/rsync --daemon --no-detach &
;;
"secondary")
/usr/sbin/cron
;;
esac
if [ $SMB_USEBIND9 = "true" ]; then
/usr/sbin/named -u bind
fi
# Infinity roop.
while : ; do sleep 1 ; done