Download default mrconfig file if unavailable

This commit is contained in:
gardouille 2022-01-21 12:23:16 +01:00
parent d8c10787fd
commit 5c73d22620
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 16 additions and 18 deletions

34
profile
View File

@ -1,5 +1,7 @@
# Default .profile from gardouille.home_public
# https://git.101010.fr/gardouille-dotfiles/home_public
# Ansible managed
# For any permanent changes you must modify your own authorized_keys file under
# https://git.101010.fr/101010/debops/src/branch/master/ansible/resources/files/by-group/all/home/gardouille/.profile
# Manage dependencies {{{
## Ensure to have git {{{
@ -37,21 +39,18 @@ REPO_PATH="${HOME}/${REPO_DIR}"
[ ! -d "${REPO_PATH}" ] && mkdir -p -- "${REPO_PATH}"
# If .mrconfig file is available and no mr command was already launch (eg: .tmux directory unavailable) {{{
if [ -f "${HOME}"/.mrconfig ] && [ ! -L "${HOME}"/.tmux ]; then
## Get all repositories with mr
mr checkout
## Add a flag file to know the last update time
touch "${HOME}"/.git.update
# If no .mrconfig file is available {{{
if [ ! -f "${HOME}"/.mrconfig ]; then
## Download a basic one
wget --quiet https://git.101010.fr/gardouille-dotfiles/home_public/raw/branch/master/mrconfig -O "${HOME}"/.mrconfig
fi
# }}}
# Update repositories {{{
## If a git.update flag exists
## If a .git.update flag file already exists
if [ -f "${HOME}"/.git.update ]; then
### Get the date of the last update
DATE_MTIME_GIT_FLAG=$(stat --format='%Y' "${HOME}"/.git.update)
DATE_MAX=$(date --date="2 months ago" "+%s")
@ -64,14 +63,13 @@ if [ -f "${HOME}"/.git.update ]; then
touch "${HOME}"/.git.update
fi
else
## Otherwise, just try to update if minimum configuration is available
if [ -f "${HOME}"/.mrconfig ]; then
### Update all repositories with mr
mr update
### No .git.update flag file exists
### Create a flag file to know the last update time
touch "${HOME}"/.git.update
fi
### Update all repositories with mr
mr update
### Create a flag file to know the last update time
touch "${HOME}"/.git.update
fi
## }}}