Compare commits

..

No commits in common. "823c7b098c3a13773736274e5227f7e468ddb675" and "cee70f7ed871d14f2ebfdc7653e78aa143d17a3c" have entirely different histories.

5 changed files with 9 additions and 58 deletions

View File

@ -1,6 +1,6 @@
# #
## openldap environment variables ## openldap environment variables
# version 3.2 # version 3.0
# #
### Usage ### Usage

View File

@ -2,7 +2,7 @@
# #
### start openldap container using params file variables ### start openldap container using params file variables
# version 3.2 # version 3.1
# #
@ -45,13 +45,11 @@ cyan=$(tput setaf 6)
err=$(tput bold)$(tput setaf 1) err=$(tput bold)$(tput setaf 1)
magenta=$(tput setaf 5) magenta=$(tput setaf 5)
norm=$(tput sgr0) norm=$(tput sgr0)
red=$(tput setaf 1)
yellow=$(tput setaf 3) yellow=$(tput setaf 3)
width=$(tput cols) width=$(tput cols)
### parameter defaults ### parameter defaults
scriptName="$( basename "$0" )" scriptName="$( basename "$0" )"
clean=false
restore=false restore=false
container_name="ab-openldap" container_name="ab-openldap"
volume_data="ab-openldap_data" volume_data="ab-openldap_data"
@ -93,9 +91,6 @@ scriptHelp () {
textblock "${cyan}-s|--shell${norm}" textblock "${cyan}-s|--shell${norm}"
textblock "Switch parameter. Enter the container using an interactive POSIX shell. This happens after startup operations but *before* openLDAP (slapd) is started. This is a great way to test out configuration changes or run custom queries. You can combine this with '--rm' for easy configuration checks or LDIF imports." textblock "Switch parameter. Enter the container using an interactive POSIX shell. This happens after startup operations but *before* openLDAP (slapd) is started. This is a great way to test out configuration changes or run custom queries. You can combine this with '--rm' for easy configuration checks or LDIF imports."
printf "\n" printf "\n"
textblock "${cyan}--clean${norm}"
textblock "Switch parameter. This option will stop and remove ALL running openLDAP containers *AND DESTROY ALL VOLUMES*. This is meant to give you a 'clean start' if you've made configuration changes, etc."
printf "\n"
textblock "${cyan}--restore${norm}" textblock "${cyan}--restore${norm}"
textblock "Switch parameter. Restore a 'slapcat' backup to the data and ldif volumes in preparation for mounting them in a normal container. It is strongly recommended you review your '-t' '--data' and '--ldif' settings before proceeding with this option." textblock "Switch parameter. Restore a 'slapcat' backup to the data and ldif volumes in preparation for mounting them in a normal container. It is strongly recommended you review your '-t' '--data' and '--ldif' settings before proceeding with this option."
printf "\n" printf "\n"
@ -141,10 +136,6 @@ while [ $# -gt 0 ]; do
# start shell instead of default CMD # start shell instead of default CMD
shell=true shell=true
;; ;;
--clean)
# stop if necessary, delete volumes
clean=true
;;
--restore) --restore)
# restore backup # restore backup
restore=true restore=true
@ -200,48 +191,8 @@ done
### process main operations ### process main operations
if [ $clean = true ]; then
# cleanup containers and volumes
# display warning and confirm user's intentions
printf "\nThis will stop and remove all ab-openldap containers %sAND REMOVE ALL PERSISTENT DATA VOLUMES%s. Please ensure you have a backup and understand how to restore your data.\n" \
"$red" "$norm"
printf "%sThis action CANNOT be undone!%s\n\n" \
"$red" "$norm"
prompt_yn
# get all ab-openldap containers if [ $restore = true ]; then
containers=$(docker ps -a --no-trunc --filter "label=org.label-schema.name=ab-openldap" --format "{{ .Names }}")
# check for null value -- no containers to remove
if [ -z "$containers" ]; then
consoleError '0' 'No openldap containers to remove.'
fi
# iterate containers, stop them and remove straggling volumes
set -- dummy $containers
shift
for container; do
printf "\n%sFound %s -- processing:%s\n" \
"$cyan" "$container" "$norm"
# stop container
printf "\t%sStopping container...%s\n" "$red" "$norm"
docker stop ${container} > /dev/null 2>&1
# find volumes
volumes=$(docker inspect --format '{{ range .Mounts }}{{ println .Name }}{{ end }}' ${container})
# remove container
printf "\t%sRemoving container...%s\n" "$red" "$norm"
docker rm -f ${container} > /dev/null 2>&1
# pause to allow write flushing
sleep 3
# iterate volumes
set -- dummy2 $volumes
shift
for volume; do
printf "\t%sRemoving volume '%s'...%s\n" "$red" "$volume" "$norm"
docker volume rm -f ${volume} > /dev/null 2>&1
done
printf "%s...done%s\n" "$cyan" "$norm"
done
elif [ $restore = true ]; then
# automatically restore backups using a temp container to create volumes # automatically restore backups using a temp container to create volumes
printf "%s\n*** Restoring Backup ***\n\n%s" "$magenta" "$norm" printf "%s\n*** Restoring Backup ***\n\n%s" "$magenta" "$norm"
printf "To avoid errors due to existing files, this script will delete any volumes that have the following names (based on --data and --ldif):\n" printf "To avoid errors due to existing files, this script will delete any volumes that have the following names (based on --data and --ldif):\n"

View File

@ -1,6 +1,6 @@
####### #######
### openLDAP backup script parameters file ### openLDAP backup script parameters file
### version 3.2 ### version 3.0
####### #######

View File

@ -2,7 +2,7 @@
# #
### backup openLDAP configuration and frontend database(s) ### backup openLDAP configuration and frontend database(s)
# version 3.2 # version 3.1
# #

View File

@ -1,5 +1,5 @@
3a6178a07571c14e3036aeede7bfb5fa7982faf682b7b919d2f05dbf07e080da ab-openldap.sh 1ee82b7c5f03b88b8c5d085e7dc66a60d5ed1c0134c31bdec703b74a705904a5 ab-openldap.sh
7e49710a156a2722b7f2dbf92b4f3e4b51bcfbf97403b4698ad4ef0216eadef6 backup.sh 52a06b492645eec6d3df31168060618a4f464e9d0d2e303d6c379b7b9173353c backup.sh
5f228bddbe83bbaa495ad4095a50778c865d3288179148829820b55d00511ca5 update.sh 5f228bddbe83bbaa495ad4095a50778c865d3288179148829820b55d00511ca5 update.sh
1be75b2ac18dbc7e7f9eeaedffac688d055435b170b00fadb5d5cb3b55398472 ab-openldap.params.template e0a20b8eef4e12c1770595c750ee58c0bedb55d0b735756b3637cd17b761e4d8 ab-openldap.params.template
407e732d110cd0dea8e257e22953931fc51237d7583a69722da3b1d7843f0738 backup.params.template 42d8a45d203bb729d5dadb9fa9a4b597d6f834468f65676a9f0f3cef92831c4c backup.params.template