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
Pipeline #12225 waiting for manual action with stages
......@@ -12,64 +12,43 @@ if [ "$DEBUG_ENTRYPOINT" = true ]; then
fi
home=/var/lib/duniter
config=/etc/duniter
home_default=$home/duniter_default
manual_config="$(boolean "${DUNITER_MANUAL_CONFIG:-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"
ln -fs "$config/conf.json" "$home_default/conf.json"
# Manual config when enabled
if [ "$manual_config" = true ]; then
# Do not start until a configuration file was initialized
while ! [ -f "$config/conf.json.orig" ]; do
echo "Waiting for initial configuration file... Please copy your configuration file to '$config/conf.json.orig'"
while ! [ -f "$home_default/conf.json.orig" ]; do
echo "Waiting for initial configuration file... Please copy your configuration file to '$home_default/conf.json.orig'"
sleep 10
done
echo "Configuration file found. Continuing..."
# 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 [ -f "$config/conf.json" ]; then
echo "Backing up old configuration file to '$config/conf.json.old'..."
mv $config/conf.json $config/conf.json.old
if [ -f "$home_default/conf.json" ]; then
echo "Backing up old configuration file to '$home_default/conf.json.old'..."
mv $home_default/conf.json $home_default/conf.json.old
fi
echo "Installing new configuration file..."
cp "$config/conf.json.orig" "$config/conf.json"
md5sum "$config/conf.json.orig" >"$md5_file"
cp "$home_default/conf.json.orig" "$home_default/conf.json"
md5sum "$home_default/conf.json.orig" >"$md5_file"
fi
# 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 . "$config/conf.json" >"$config/conf.json.sorted"
if [ -f "$config/conf.json.old" ]; then
jq --sort-keys -r . "$config/conf.json.old" >"$config/conf.json.old.sorted"
if ! diff -q "$config/conf.json.old.sorted" "$config/conf.json.orig.sorted"; then
diff -u "$config/conf.json.old.sorted" "$config/conf.json.orig.sorted"
jq --sort-keys -r . "$home_default/conf.json.orig" >"$home_default/conf.json.orig.sorted"
jq --sort-keys -r . "$home_default/conf.json" >"$home_default/conf.json.sorted"
if [ -f "$home_default/conf.json.old" ]; then
jq --sort-keys -r . "$home_default/conf.json.old" >"$home_default/conf.json.old.sorted"
if ! diff -q "$home_default/conf.json.old.sorted" "$home_default/conf.json.orig.sorted"; then
diff -u "$home_default/conf.json.old.sorted" "$home_default/conf.json.orig.sorted"
fi
fi
if ! diff -q "$config/conf.json.orig.sorted" "$config/conf.json.sorted"; then
diff -u "$config/conf.json.orig.sorted" "$config/conf.json.sorted"
if ! diff -q "$home_default/conf.json.orig.sorted" "$home_default/conf.json.sorted"; then
diff -u "$home_default/conf.json.orig.sorted" "$home_default/conf.json.sorted"
fi
fi
......@@ -102,10 +81,6 @@ fi
# Set --home option
set -- --home "$home" "$@"
# Define DUNITER_CONF_HOME
DUNITER_CONF_HOME="/etc/duniter"
export DUNITER_CONF_HOME
# Start duniter
echo Starting duniter with:
echo /usr/bin/duniter "$@"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment