Compare commits

..

No commits in common. "e4e6f51bdb9a5a175a04c4fec73aea4db03d1cdc" and "bbec26f4386a3413b7ef3f2e5477f48fe41cb1c6" have entirely different histories.

3 changed files with 28 additions and 51 deletions

View File

@ -1,10 +1,14 @@
# Update # Update
Update script written in Bash for Arch Linux only. Keeps all your official, aur packages and your flatpaks up to date with one simple script. It also backups a list of all your installed packages and flatpaks. Update script written in Bash for Arch Linux only. Keeps all your pacman and aur packages as well as your flatpaks up to date with one simple script. It also backups a list of all your pacman and aur packages and flatpaks.
## Requirements ## Requirements
It requires sudo, but if you use something else, then just create a softlink for this script to work. Here is what is required.
```bash
pacman -S just
```
It also technically requires sudo, but if you use something else, then just create a softlink for this script to work.<br/>
Doing that would look like this. Doing that would look like this.
```bash ```bash
ln -s /usr/bin/your_program /usr/bin/sudo ln -s /usr/bin/your_program /usr/bin/sudo
@ -16,10 +20,10 @@ ln -s /usr/bin/your_program /usr/bin/sudo
git clone https://gitea.hopeless-cloud.xyz/AustrianToast/update.git && cd update git clone https://gitea.hopeless-cloud.xyz/AustrianToast/update.git && cd update
``` ```
Before installing, please edit the config and configure it to your liking. Before installing, please edit the config and configure it to your liking.<br/>
Then install using Then install using
```bash ```bash
make just install
``` ```
## Usage ## Usage
@ -41,4 +45,5 @@ no flag same as -p
``` ```
## Contributing ## Contributing
Contributions are always welcome! Contributions are always welcome!

59
update
View File

@ -1,6 +1,9 @@
#!/usr/bin/bash #!/usr/bin/bash
VERSION="2.1.1" source "$HOME"/.config/update.conf || exit 1
[[ ! -d $BACKUP_LOCATION ]] && mkdir --parents "$BACKUP_LOCATION"
VERSION="2.1.0"
IGREEN="\033[0;92m" # Intense Green IGREEN="\033[0;92m" # Intense Green
IYELLOW="\033[0;93m" # Intense Yellow IYELLOW="\033[0;93m" # Intense Yellow
NO_COLOR="\033[0m" # Text Reset NO_COLOR="\033[0m" # Text Reset
@ -8,30 +11,6 @@ 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
FINAL_COMMAND="true" FINAL_COMMAND="true"
source "$HOME"/.config/update.conf || exit 1
if [ ! -d $BACKUP_LOCATION ]; then
echo -e "${IYELLOW}Backup location 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 "$BACKUP_LOCATION" ;;
[Nn]) exit 0;;
* ) exit 0 ;;
esac
fi
if [ $SECONDARY_BACKUP_LOCATION ]; then
if [ ! -d $SECONDARY_BACKUP_LOCATION ]; then
echo -e "${IYELLOW}Secondary Backup location 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 "$SECONDARY_BACKUP_LOCATION" ;;
[Nn]) exit 0;;
* ) exit 0 ;;
esac
fi
fi
trap interrupt_function INT trap interrupt_function INT
interrupt_function() { interrupt_function() {
@ -43,19 +22,19 @@ interrupt_function() {
} }
help() { help() {
echo "Usage: update [OPTION]" echo "Usage: update [OPTION]"
echo echo
echo "options:" echo "options:"
echo "no option same as -p" echo "no option same as -p"
echo "-f updates using flatpak update only" echo "-f updates using flatpak update only"
echo "-p updates using a pacman-wrapper only" echo "-p updates using a pacman-wrapper only"
echo "-a updates using flatpak update and a pacman-wrapper" echo "-a updates using flatpak update and a pacman-wrapper"
echo "-g shutdowns the computer afterwards" echo "-g shutdowns the computer afterwards"
echo "-r reboots the computer afterwards" echo "-r reboots the computer afterwards"
echo "--help displays this message" echo "--help displays this message"
echo "--preview shows a preview of pkg's and flatpaks which can be updated" echo "--preview shows a preview of pkg's and flatpaks which can be updated"
echo "--version prints out the version number" echo "--version prints out the version number"
echo "--backup just does the before-backup without updating" echo "--backup just does the before-backup without updating"
} }
lock_pacman_db() { lock_pacman_db() {
@ -83,7 +62,6 @@ before_backup() {
tar --create --zstd --file "$TMP"/before-backup_"$DATE".tar.zst.new "$TMP"/before-backup_"$DATE" /var/lib/pacman/local > /dev/null 2>&1 # for some reason it needs the output suppresion tar --create --zstd --file "$TMP"/before-backup_"$DATE".tar.zst.new "$TMP"/before-backup_"$DATE" /var/lib/pacman/local > /dev/null 2>&1 # for some reason it needs the output suppresion
mv "$TMP"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION" mv "$TMP"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$TMP"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"
sudo rm --force /var/lib/pacman/db.lck sudo rm --force /var/lib/pacman/db.lck
} }
@ -94,14 +72,11 @@ after_backup() {
tar --create --zstd --file "$TMP"/after-backup_"$DATE".tar.zst.new "$TMP"/after-backup_"$DATE" > /dev/null 2>&1 tar --create --zstd --file "$TMP"/after-backup_"$DATE".tar.zst.new "$TMP"/after-backup_"$DATE" > /dev/null 2>&1
mv "$TMP"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION" mv "$TMP"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$TMP"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"
delete_oldest_backup after-backup delete_oldest_backup after-backup
mv "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst mv "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/after-backup_"$DATE".tar.zst
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$SECONDARY_BACKUP_LOCATION"/after-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"/after-backup_"$DATE".tar.zst
delete_oldest_backup before-backup delete_oldest_backup before-backup
mv "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst mv "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new "$BACKUP_LOCATION"/before-backup_"$DATE".tar.zst
[[ $SECONDARY_BACKUP_LOCATION ]] && mv "$SECONDARY_BACKUP_LOCATION"/before-backup_"$DATE".tar.zst.new "$SECONDARY_BACKUP_LOCATION"/before-backup_"$DATE".tar.zst
rm --recursive --force "$TMP" rm --recursive --force "$TMP"
} }

View File

@ -1,9 +1,6 @@
# backup to this folder # Backup to this folder
BACKUP_LOCATION=~/ BACKUP_LOCATION=~/
# optional secondary backup loaction
#SECONDARY_BACKUP_LOCATION=~/
# use this pacman-wrapper # use this pacman-wrapper
PACMAN_WRAPPER=yay PACMAN_WRAPPER=yay