Improve template config copying (#3535)
* Do not overwrite config-default.conf Previously, when config-example.conf was missing, it would be created and config-default.conf would be made a symlink to it. However, this would overwrite any existing config-default.conf, potentially throwing away a user's data. This occurs when you clean up and throw away the (cluttering) config-example.conf (and depending on whether you use a symlink to another named config, or put data in config-default.conf, this would either just replace the symlink, or throw away your actual config data). This commit splits the update checks, so no files are ever overwritten, except a broken config-default.conf symlink. * Do not recreate example.conf if you remove it Previously, whenever config-example.conf (and some others) was missing, it start copying any missing example configs. This means that if you would remove config-example.conf to clean up your userpatches directory, it would be recreated everytime. Now, this is triggered by a missing config-default.conf (which is also created by the same block of code). The creating of config-example.conf is still there, so if you have no config-default.conf (or one of the others listed), then config-example.conf is created anyway, with config-default.conf being a link to it, just like before (so the first-run behavior is unmodified).
This commit is contained in:
parent
f3f12248e1
commit
c715c11cf2
@ -209,7 +209,7 @@ mkdir -p "${SRC}"/userpatches
|
|||||||
|
|
||||||
|
|
||||||
# Create example configs if none found in userpatches
|
# Create example configs if none found in userpatches
|
||||||
if ! ls "${SRC}"/userpatches/{config-example.conf,config-docker.conf,config-vagrant.conf} 1> /dev/null 2>&1; then
|
if ! ls "${SRC}"/userpatches/{config-default.conf,config-docker.conf,config-vagrant.conf} 1> /dev/null 2>&1; then
|
||||||
|
|
||||||
# Migrate old configs
|
# Migrate old configs
|
||||||
if ls "${SRC}"/*.conf 1> /dev/null 2>&1; then
|
if ls "${SRC}"/*.conf 1> /dev/null 2>&1; then
|
||||||
@ -224,6 +224,10 @@ if ! ls "${SRC}"/userpatches/{config-example.conf,config-docker.conf,config-vagr
|
|||||||
# Create example config
|
# Create example config
|
||||||
if [[ ! -f "${SRC}"/userpatches/config-example.conf ]]; then
|
if [[ ! -f "${SRC}"/userpatches/config-example.conf ]]; then
|
||||||
cp "${SRC}"/config/templates/config-example.conf "${SRC}"/userpatches/config-example.conf || exit 1
|
cp "${SRC}"/config/templates/config-example.conf "${SRC}"/userpatches/config-example.conf || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Link default config to example config
|
||||||
|
if [[ ! -f "${SRC}"/userpatches/config-default.conf ]]; then
|
||||||
ln -fs config-example.conf "${SRC}"/userpatches/config-default.conf || exit 1
|
ln -fs config-example.conf "${SRC}"/userpatches/config-default.conf || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user