Add files via upload
This commit is contained in:
parent
a4ca632c58
commit
13db9ed5bc
4
makefile
4
makefile
@ -1,10 +1,10 @@
|
|||||||
install:
|
install:
|
||||||
@echo "==> Installing update v0.4..."
|
@echo "==> Installing update v1.0..."
|
||||||
@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 v0.4..."
|
@echo "==> Uninstalling update v1.0..."
|
||||||
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
||||||
@echo "==> Finished."
|
@echo "==> Finished."
|
||||||
|
45
update
45
update
@ -1,16 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# shellcheck source=/dev/null
|
|
||||||
|
|
||||||
# updates via an aur-helper and flatpak with flags
|
# updates via an aur-helper and flatpak with flags
|
||||||
# version 0.8
|
# version 1.0
|
||||||
|
|
||||||
# add options to change aur-helper in the config
|
|
||||||
# maybe make a first time setup, which asks for backup_location and aur_helper, maybe even if you wanna opt-in to non-interactive flatpak-update (maybe a flag?)
|
|
||||||
|
|
||||||
|
|
||||||
IGreen="\033[0;92m" # Green
|
IGreen="\033[0;92m" # Green
|
||||||
NC="\033[0m" # Text Reset
|
NC="\033[0m" # Text Reset
|
||||||
|
|
||||||
|
dir="$pwd"
|
||||||
|
|
||||||
source ~/.config/update.conf
|
source ~/.config/update.conf
|
||||||
|
|
||||||
# output if wrong flag is used
|
# output if wrong flag is used
|
||||||
@ -26,44 +23,44 @@ Help() {
|
|||||||
echo "-a updates using flatpak update and an aur-helper"
|
echo "-a updates using flatpak update and an aur-helper"
|
||||||
echo "-g shutdowns the computer afterwards (needs to be the last or only option to work properly)"
|
echo "-g shutdowns the computer afterwards (needs to be the last or only option to work properly)"
|
||||||
echo "-r reboots the computer afterwards (needs to be the last or only option to work properly)"
|
echo "-r reboots the computer afterwards (needs to be the last or only option to work properly)"
|
||||||
echo "--help shows usage"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# creates package lists, moves them into a zip, adds some other files to the zip and backups the pacman database in the form of a tar
|
# creates package lists, moves them into a zip, adds some other files to the zip and backups the pacman database in the form of a tar
|
||||||
# it then rsyncs the zip and the tar to the backup location
|
# it then rsyncs the zip and the tar to the backup location
|
||||||
before_backup() {
|
before_backup() {
|
||||||
paclog-pkglist > ~/pacman-pre.txt
|
paclog-pkglist > pacman-pre.txt
|
||||||
flatpak list > ~/flatpak-pre.txt
|
flatpak list > flatpak-pre.txt
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
# updates using flatpak update
|
# updates using flatpak update
|
||||||
update_with_flatpak() {
|
update_with_flatpak() {
|
||||||
flatpak update -u --noninteractive
|
flatpak update -u --noninteractive
|
||||||
flatpak list > ~/flatpak-after.txt
|
flatpak list > flatpak-after.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ $1 = --help ]] && Help && exit 0;
|
[[ $1 = --help ]] && Help && exit 0;
|
||||||
|
|
||||||
before_backup && echo -e "${IGreen} pre-backup complete ${NC}"
|
[[ ! -d /tmp/backup ]] && mkdir /tmp/backup;
|
||||||
|
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' OPTION; do
|
||||||
@ -76,14 +73,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 && echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && shutdown now ;;
|
after_backup && cd "$dir"; 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 && echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && reboot ;;
|
after_backup && cd "$dir"; echo -e "${IGreen} after-backup complete ${NC}" && sleep 3s && reboot ;;
|
||||||
?)
|
?)
|
||||||
Help
|
Help
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
after_backup && echo -e "${IGreen} after-backup complete ${NC}"
|
after_backup && cd "$dir"; rm -r /tmp/backup; echo -e "${IGreen} after-backup complete ${NC}"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Backup to this folder
|
# Backup to this folder
|
||||||
backup_location=~/balls
|
backup_location=~/
|
||||||
|
|
||||||
# use this aur-helper
|
# use this aur-helper
|
||||||
aur_helper=paru
|
aur_helper=paru
|
||||||
|
Loading…
x
Reference in New Issue
Block a user