Improvements
This commit is contained in:
parent
3465d2c3e4
commit
ceb94c21fc
6
makefile
6
makefile
@ -1,10 +1,12 @@
|
|||||||
|
VER = "v1.1"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@echo "==> Installing update v1.0..."
|
@echo "==> Installing update $(VER)..."
|
||||||
@sudo install -Dm755 update /usr/local/bin/update
|
@sudo install -Dm755 update /usr/local/bin/update
|
||||||
@cp update.conf ${HOME}/.config/
|
@cp update.conf ${HOME}/.config/
|
||||||
@echo "==> Finished."
|
@echo "==> Finished."
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo "==> Uninstalling update v1.0..."
|
@echo "==> Uninstalling update $(VER)..."
|
||||||
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
||||||
@echo "==> Finished."
|
@echo "==> Finished."
|
||||||
|
35
update
35
update
@ -1,19 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# updates via an aur-helper and flatpak with flags
|
# updates via an aur-helper and flatpak with flags
|
||||||
# version 1.0
|
# version 1.1
|
||||||
|
|
||||||
IGreen="\033[0;92m" # Green
|
IGreen="\033[0;92m" # Green
|
||||||
NC="\033[0m" # Text Reset
|
NC="\033[0m" # Text Reset
|
||||||
|
|
||||||
dir="$pwd"
|
DIR="$(pwd)"
|
||||||
|
|
||||||
source ~/.config/update.conf
|
source "${HOME}"/.config/update.conf
|
||||||
|
|
||||||
# output if wrong flag is used
|
# output if wrong flag is used
|
||||||
Help() {
|
Help() {
|
||||||
echo "updates via an aur-helper and flatpak with flags"
|
|
||||||
echo
|
|
||||||
echo "Usage: update [OPTION]"
|
echo "Usage: update [OPTION]"
|
||||||
echo
|
echo
|
||||||
echo "options:"
|
echo "options:"
|
||||||
@ -33,21 +31,21 @@ before_backup() {
|
|||||||
zip --quiet --move before-backup.zip.new pacman-pre.txt flatpak-pre.txt
|
zip --quiet --move before-backup.zip.new pacman-pre.txt flatpak-pre.txt
|
||||||
zip --quiet --grow before-backup.zip.new /etc/fstab /etc/makepkg.conf
|
zip --quiet --grow before-backup.zip.new /etc/fstab /etc/makepkg.conf
|
||||||
tar -cJf pacman-database.tar.xz.new /var/lib/pacman/local &> /dev/null
|
tar -cJf pacman-database.tar.xz.new /var/lib/pacman/local &> /dev/null
|
||||||
rsync --remove-source-files before-backup.zip.new pacman-database.tar.xz.new "$backup_location"
|
rsync --remove-source-files before-backup.zip.new pacman-database.tar.xz.new "${backup_location}"
|
||||||
rename before-backup.zip.new before-backup.zip "$backup_location"/before-backup.zip.new
|
rename before-backup.zip.new before-backup.zip "${backup_location}"/before-backup.zip.new
|
||||||
rename pacman-database.tar.xz.new pacman-database.tar.xz "$backup_location"/pacman-database.tar.xz.new
|
rename pacman-database.tar.xz.new pacman-database.tar.xz "${backup_location}"/pacman-database.tar.xz.new
|
||||||
}
|
}
|
||||||
|
|
||||||
# moves the package lists into a zip, it then rsyncs the zip to the backup location
|
# moves the package lists into a zip, it then rsyncs the zip to the backup location
|
||||||
after_backup() {
|
after_backup() {
|
||||||
zip --quiet --move after-backup.zip.new pacman-after.txt flatpak-after.txt
|
zip --quiet --move after-backup.zip.new pacman-after.txt flatpak-after.txt
|
||||||
rsync --remove-source-files after-backup.zip.new "$backup_location"
|
rsync --remove-source-files after-backup.zip.new "${backup_location}"
|
||||||
rename after-backup.zip.new after-backup.zip "$backup_location"/after-backup.zip.new
|
rename after-backup.zip.new after-backup.zip "${backup_location}"/after-backup.zip.new
|
||||||
}
|
}
|
||||||
|
|
||||||
# updates using aur-helper
|
# updates using aur-helper
|
||||||
update_with_aur_helper() {
|
update_with_aur_helper() {
|
||||||
"$aur_helper"
|
"${aur_helper}"
|
||||||
paclog-pkglist > pacman-after.txt
|
paclog-pkglist > pacman-after.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +57,17 @@ update_with_flatpak() {
|
|||||||
|
|
||||||
[[ $1 = --help ]] && Help && exit 0;
|
[[ $1 = --help ]] && Help && exit 0;
|
||||||
|
|
||||||
|
while [ -f /var/lib/pacman/db.lck ]; do {
|
||||||
|
sleep 1s
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
[[ ! -d /tmp/backup ]] && mkdir /tmp/backup;
|
[[ ! -d /tmp/backup ]] && mkdir /tmp/backup;
|
||||||
cd /tmp/backup && before_backup && echo -e "${IGreen} pre-backup complete ${NC}"
|
cd /tmp/backup && before_backup && echo -e "${IGreen} pre-backup complete ${NC}"
|
||||||
|
|
||||||
[[ -z $1 ]] && update_with_aur_helper && update_with_flatpak;
|
[[ -z $1 ]] && update_with_aur_helper && update_with_flatpak;
|
||||||
while getopts 'fyagr' OPTION; do
|
while getopts 'fyagr' OPTIONS; do
|
||||||
case "$OPTION" in
|
case "$OPTIONS" in
|
||||||
f)
|
f)
|
||||||
update_with_flatpak ;;
|
update_with_flatpak ;;
|
||||||
y)
|
y)
|
||||||
@ -73,14 +76,14 @@ while getopts 'fyagr' OPTION; do
|
|||||||
update_with_aur_helper; update_with_flatpak ;;
|
update_with_aur_helper; update_with_flatpak ;;
|
||||||
g)
|
g)
|
||||||
[[ $1 = -g ]] && update_with_aur_helper && update_with_flatpak;
|
[[ $1 = -g ]] && update_with_aur_helper && update_with_flatpak;
|
||||||
after_backup && cd "$dir"; echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && shutdown now ;;
|
after_backup && cd "${DIR}" || return; echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && shutdown now ;;
|
||||||
r)
|
r)
|
||||||
[[ $1 = -r ]] && update_with_aur_helper && update_with_flatpak;
|
[[ $1 = -r ]] && update_with_aur_helper && update_with_flatpak;
|
||||||
after_backup && cd "$dir"; echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && reboot ;;
|
after_backup && cd "${DIR}" || return; echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && reboot ;;
|
||||||
?)
|
?)
|
||||||
Help
|
Help
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
after_backup && cd "$dir"; rm -r /tmp/backup; echo -e "${IGreen} after-backup complete ${NC}"
|
after_backup && cd "${DIR}" || return; rm -r /tmp/backup; echo -e "${IGreen} after-backup complete ${NC}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user