Skip to content
Snippets Groups Projects
Commit c9062471 authored by Gilles Filippini's avatar Gilles Filippini
Browse files

ref(docker): move back config to /var/lib/duniter

Moving `conf.json` from volume `/var/lib/duniter` to volume `/etc/duniter`
was a mistake. It creates to much many corner cases where one can lose
their configuration file.

This commit partly reverts fd0bbe67 by bringing conf.json back into volume
`/var/lib/duniter`.
parent 3a6f4eaa
No related branches found
No related tags found
1 merge request!1381Docker: move config back to volume /var/lib/duniter and other minor changes
...@@ -12,64 +12,43 @@ if [ "$DEBUG_ENTRYPOINT" = true ]; then ...@@ -12,64 +12,43 @@ if [ "$DEBUG_ENTRYPOINT" = true ]; then
fi fi
home=/var/lib/duniter home=/var/lib/duniter
config=/etc/duniter
home_default=$home/duniter_default home_default=$home/duniter_default
manual_config="$(boolean "${DUNITER_MANUAL_CONFIG:-false}")" manual_config="$(boolean "${DUNITER_MANUAL_CONFIG:-false}")"
auto_sync="$(boolean "${DUNITER_AUTO_SYNC:-false}")" auto_sync="$(boolean "${DUNITER_AUTO_SYNC:-false}")"
# Use new path /etc/duniter/conf.json
if ! [ -f "$config/conf.json" ]; then
if [ "$(readlink "$home_default/conf.json")" = "$config/conf.json" ]; then
# The configuration file was moved already but the link is dangling
# It is likely that '/etc/duniter' is an anonymous volume
echo -e "$big_fat_warning Your configuration file didn't survive the restart!"
echo -e "$big_fat_warning Make sure that '/etc/duniter' is explicitely mounted as a persistent volume or you'll lose it again."
if [ -f "$home_default/conf.json.backup" ]; then
echo -e "$big_fat_warning Found backup file '$home_default/conf.json.backup'; using it..."
mv "$home_default/conf.json.backup" "$home_default/conf.json"
fi
fi
if [ -f "$home_default/conf.json" ]; then
echo "Moving existing configuration file '$home_default/conf.json' to its new location: '$config/conf.json'"
echo "A backup is kept at '$home_default/conf.json.backup'"
cp "$home_default/conf.json" "$home_default/conf.json.backup"
mv "$home_default/conf.json" "$config/conf.json"
fi
fi
mkdir -p "$home/duniter_default" mkdir -p "$home/duniter_default"
ln -fs "$config/conf.json" "$home_default/conf.json"
# Manual config when enabled # Manual config when enabled
if [ "$manual_config" = true ]; then if [ "$manual_config" = true ]; then
# Do not start until a configuration file was initialized # Do not start until a configuration file was initialized
while ! [ -f "$config/conf.json.orig" ]; do while ! [ -f "$home_default/conf.json.orig" ]; do
echo "Waiting for initial configuration file... Please copy your configuration file to '$config/conf.json.orig'" echo "Waiting for initial configuration file... Please copy your configuration file to '$home_default/conf.json.orig'"
sleep 10 sleep 10
done done
echo "Configuration file found. Continuing..." echo "Configuration file found. Continuing..."
# Use new conf.json.orig when changed # Use new conf.json.orig when changed
md5_file="$config/conf.json.orig.md5" md5_file="$home_default/conf.json.orig.md5"
if ! md5sum -c "$md5_file"; then if ! md5sum -c "$md5_file"; then
if [ -f "$config/conf.json" ]; then if [ -f "$home_default/conf.json" ]; then
echo "Backing up old configuration file to '$config/conf.json.old'..." echo "Backing up old configuration file to '$home_default/conf.json.old'..."
mv $config/conf.json $config/conf.json.old mv $home_default/conf.json $home_default/conf.json.old
fi fi
echo "Installing new configuration file..." echo "Installing new configuration file..."
cp "$config/conf.json.orig" "$config/conf.json" cp "$home_default/conf.json.orig" "$home_default/conf.json"
md5sum "$config/conf.json.orig" >"$md5_file" md5sum "$home_default/conf.json.orig" >"$md5_file"
fi fi
# Log differences between initial, old and current conf file # Log differences between initial, old and current conf file
jq --sort-keys -r . "$config/conf.json.orig" >"$config/conf.json.orig.sorted" jq --sort-keys -r . "$home_default/conf.json.orig" >"$home_default/conf.json.orig.sorted"
jq --sort-keys -r . "$config/conf.json" >"$config/conf.json.sorted" jq --sort-keys -r . "$home_default/conf.json" >"$home_default/conf.json.sorted"
if [ -f "$config/conf.json.old" ]; then if [ -f "$home_default/conf.json.old" ]; then
jq --sort-keys -r . "$config/conf.json.old" >"$config/conf.json.old.sorted" jq --sort-keys -r . "$home_default/conf.json.old" >"$home_default/conf.json.old.sorted"
if ! diff -q "$config/conf.json.old.sorted" "$config/conf.json.orig.sorted"; then if ! diff -q "$home_default/conf.json.old.sorted" "$home_default/conf.json.orig.sorted"; then
diff -u "$config/conf.json.old.sorted" "$config/conf.json.orig.sorted" diff -u "$home_default/conf.json.old.sorted" "$home_default/conf.json.orig.sorted"
fi fi
fi fi
if ! diff -q "$config/conf.json.orig.sorted" "$config/conf.json.sorted"; then if ! diff -q "$home_default/conf.json.orig.sorted" "$home_default/conf.json.sorted"; then
diff -u "$config/conf.json.orig.sorted" "$config/conf.json.sorted" diff -u "$home_default/conf.json.orig.sorted" "$home_default/conf.json.sorted"
fi fi
fi fi
...@@ -102,10 +81,6 @@ fi ...@@ -102,10 +81,6 @@ fi
# Set --home option # Set --home option
set -- --home "$home" "$@" set -- --home "$home" "$@"
# Define DUNITER_CONF_HOME
DUNITER_CONF_HOME="/etc/duniter"
export DUNITER_CONF_HOME
# Start duniter # Start duniter
echo Starting duniter with: echo Starting duniter with:
echo /usr/bin/duniter "$@" echo /usr/bin/duniter "$@"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment