2023-12-13 19:32:24 +01:00
|
|
|
#!/bin/bash
|
2024-06-02 17:15:38 +02:00
|
|
|
cd "${HOME}/.dotfiles" || (
|
|
|
|
echo ":: Error: Can't cd into ${HOME}/.dotfiles"
|
|
|
|
exit 1
|
|
|
|
)
|
|
|
|
|
|
|
|
# Colors
|
|
|
|
COLOR="31"
|
|
|
|
COLOR_REGULAR="\e[0;${COLOR}m"
|
|
|
|
COLOR_BOLD="\e[1;${COLOR}m"
|
|
|
|
COLOR_RESET="\e[0m"
|
|
|
|
|
|
|
|
# Latest commit
|
|
|
|
if curl -qsI https://git.staropensource.de|head -1|grep " 200" &> /dev/null; then
|
|
|
|
COMMIT=$(env PAGER= git log -n 1 --pretty=format:\"%H\")
|
|
|
|
LATEST_COMMIT=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.id')
|
|
|
|
LATEST_COMMIT_MESSAGE=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.message'|sed 's/\\n//g')
|
|
|
|
else
|
|
|
|
[[ -z "${SCRIPTED}" ]] && echo -e "${COLOR_BOLD}https://git.staropensource.de is not reachable"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-12-13 19:32:24 +01:00
|
|
|
|
2023-12-13 20:25:31 +01:00
|
|
|
if [ "$COMMIT" == "$LATEST_COMMIT" ] || [ -z "$LATEST_COMMIT" ]; then
|
2024-06-02 17:15:38 +02:00
|
|
|
UPDATE=false
|
2023-12-13 20:03:46 +01:00
|
|
|
else
|
2024-06-02 17:15:38 +02:00
|
|
|
UPDATE=true
|
2023-12-13 20:03:46 +01:00
|
|
|
fi
|
|
|
|
|
2024-06-02 17:15:38 +02:00
|
|
|
if [ -z "${SCRIPTED}" ]; then
|
|
|
|
if [ -n "${UPDATE}" ]; then
|
2023-12-13 20:11:04 +01:00
|
|
|
echo -e "${COLOR_BOLD}An update for jstm's punktdateien is available."
|
2023-12-13 20:06:49 +01:00
|
|
|
echo -e "${COLOR_REGULAR}Latest commit: ${LATEST_COMMIT}"
|
|
|
|
echo " -> Message: ${LATEST_COMMIT_MESSAGE}"
|
|
|
|
echo ""
|
|
|
|
echo -e "${COLOR_BOLD}Update by executing \"dotfiles-updater\""
|
2023-12-13 20:03:46 +01:00
|
|
|
echo -en "${COLOR_RESET}"
|
2024-06-02 17:15:38 +02:00
|
|
|
exit 0
|
|
|
|
elif [ -z "${BASHRC}" ]; then
|
2023-12-13 20:03:46 +01:00
|
|
|
echo -e "${COLOR_BOLD}No update available"
|
2024-06-02 17:15:38 +02:00
|
|
|
exit 1
|
2023-12-13 20:03:46 +01:00
|
|
|
fi
|
2024-06-02 17:15:38 +02:00
|
|
|
else
|
|
|
|
if [ -n "${UPDATE}" ]; then
|
2023-12-13 20:03:46 +01:00
|
|
|
echo "$LATEST_COMMIT_MESSAGE"
|
|
|
|
fi
|
2023-12-13 19:32:24 +01:00
|
|
|
fi
|