move stuff around

This commit is contained in:
AustrianToast 2024-07-13 01:23:58 +02:00
parent 92777bbbf8
commit b13189e7de
Signed by: AustrianToast
GPG Key ID: 378A29F999424B1C

76
update
View File

@ -8,28 +8,6 @@ NO_COLOR="\033[0m" # Text Reset
TMP="/tmp/update" TMP="/tmp/update"
DATE="$(date +"%Y-%m-%dT%H:%M:%S%:z")" # RFC 3339 date-time https://datatracker.ietf.org/doc/html/rfc3339#section-5.6 DATE="$(date +"%Y-%m-%dT%H:%M:%S%:z")" # RFC 3339 date-time https://datatracker.ietf.org/doc/html/rfc3339#section-5.6
source "$HOME"/.config/update.conf || echo -e "${IRED}No config found${NO_COLOR}" || exit 1
check_for_valid_backup_location() {
if [ ! -d $1 ]; then
echo -e "${IYELLOW}$1 doesn't exist${NO_COLOR}"
read -p "Do you want to create the path and continue? [y/N]" input
case $input in
[Yy]) mkdir --parents "$1" ;;
[Nn]) exit 0;;
* ) exit 0 ;;
esac
fi
}
if [ $BACKUP_LOCATION ]; then
check_for_valid_backup_location "$BACKUP_LOCATION"
else
echo -e "${IRED}No BACKUP_LOCATION in $HOME/.config/update.conf specified${NO_COLOR}"
exit 1
fi
[[ $SECONDARY_BACKUP_LOCATION ]] && check_for_valid_backup_location "$SECONDARY_BACKUP_LOCATION"
trap interrupt_function INT trap interrupt_function INT
interrupt_function() { interrupt_function() {
@ -52,6 +30,44 @@ help() {
echo "--version prints out the version number" echo "--version prints out the version number"
} }
source "$HOME"/.config/update.conf || echo -e "${IRED}No config found${NO_COLOR}" || exit 1
if [[ ${1:0:2} == \-\- ]]; then
case "${1:2}" in
help)
help ;;
preview)
"$PACMAN_WRAPPER" -Syy
"$PACMAN_WRAPPER" --query --upgrades
[[ -x /usr/bin/flatpak ]] && flatpak remote-ls --updates ;;
version)
echo "$VERSION" ;;
?)
help; exit 1;;
esac
exit 0
fi
check_for_valid_backup_location() {
if [ ! -d $1 ]; then
echo -e "${IYELLOW}$1 doesn't exist${NO_COLOR}"
read -p "Do you want to create the path and continue? [y/N]" input
case $input in
[Yy]) mkdir --parents "$1" ;;
[Nn]) exit 0;;
* ) exit 0 ;;
esac
fi
}
if [ $BACKUP_LOCATION ]; then
check_for_valid_backup_location "$BACKUP_LOCATION"
else
echo -e "${IRED}No BACKUP_LOCATION in $HOME/.config/update.conf specified${NO_COLOR}"
exit 1
fi
[[ $SECONDARY_BACKUP_LOCATION ]] && check_for_valid_backup_location "$SECONDARY_BACKUP_LOCATION"
lock_pacman_db() { lock_pacman_db() {
if [ -f /var/lib/pacman/db.lck ]; then if [ -f /var/lib/pacman/db.lck ]; then
echo -e "${IYELLOW}->${NO_COLOR} /var/lib/pacman/db.lck exists" echo -e "${IYELLOW}->${NO_COLOR} /var/lib/pacman/db.lck exists"
@ -119,22 +135,6 @@ update() {
fi fi
} }
if [[ ${1:0:2} == \-\- ]]; then
case "${1:2}" in
help)
help ;;
preview)
"$PACMAN_WRAPPER" -Syy
"$PACMAN_WRAPPER" --query --upgrades
[[ -x /usr/bin/flatpak ]] && flatpak remote-ls --updates ;;
version)
echo "$VERSION" ;;
?)
help; exit 1;;
esac
exit 0
fi
before_backup && echo -e "${IGREEN}before-backup complete${NO_COLOR}" before_backup && echo -e "${IGREEN}before-backup complete${NO_COLOR}"
update update
after_backup && echo -e "${IGREEN}after-backup complete${NO_COLOR}" after_backup && echo -e "${IGREEN}after-backup complete${NO_COLOR}"