Automaticly move profiles from legacy path to user's home, and notify about it

pull/10/head
Didier BONNEFOI 2018-02-26 14:18:18 +01:00
parent b532476260
commit 3cb29bc968
1 changed files with 17 additions and 9 deletions

View File

@ -311,19 +311,27 @@ initProfile()
if [ -d "${LEGACY_PROFILES_PATH}" ]; then if [ -d "${LEGACY_PROFILES_PATH}" ]; then
# is there any profile in legacy path ? # is there any profile in legacy path ?
legacy_profiles=$(ls -A "${LEGACY_PROFILES_PATH}" 2>/dev/null) legacy_profiles=$(ls -A "${LEGACY_PROFILES_PATH}" 2>/dev/null)
legacy_default_profile=$(ls -A "${BASE_PATH}"/.ovh* 2>/dev/null) legacy_default_profile=$(cd "${BASE_PATH}" && ls .ovh* access.rules 2>/dev/null)
if [ -n "${legacy_profiles}" ] || [ -n "${legacy_default_profile}" ]; then if [ -n "${legacy_profiles}" ] || [ -n "${legacy_default_profile}" ]; then
_echoWarning "Your profiles resides in the legacy path:" # notify about migration to new location:
echo "${legacy_profiles}" _echoWarning "Your profiles were in the legacy path, migrating to ${PROFILES_PATH} :"
echo "${legacy_default_profile}"
_echoWarning "Please move them to this new location like this:" if [ -n "${legacy_default_profile}" ]; then
[ -n "${legacy_profiles}" ] && _echoWarning " mv ${LEGACY_PROFILES_PATH}/* ${PROFILES_PATH}" _echoWarning "> migrating default profile:"
[ -n "${legacy_default_profile}" ] && _echoWarning " mv ${BASE_PATH}/.ovh* access.rules ${PROFILES_PATH}" echo "${legacy_default_profile}"
exit 1 mv ${BASE_PATH}/.ovh* access.rules "${PROFILES_PATH}"
fi
if [ -n "${legacy_profiles}" ]; then
_echoWarning "> migrating custom profiles:"
echo "${legacy_profiles}"
mv ${LEGACY_PROFILES_PATH}/* "${PROFILES_PATH}"
fi
fi fi
fi fi
# if profile is not set, or with value 'default' # if profile is not set, or with value 'default'
if [[ -z "${profile}" ]] || [[ "${profile}" == "default" ]] if [[ -z "${profile}" ]] || [[ "${profile}" == "default" ]]
then then