Should work now #16
21
PKGBUILD
21
PKGBUILD
@ -1,21 +0,0 @@
|
|||||||
# Maintainer: AustrianToast <rene dot fuhry at gmail dot com>
|
|
||||||
pkgname=update-git
|
|
||||||
pkgver=1.4
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc="Update script for Arch linux written in bash"
|
|
||||||
arch=('any')
|
|
||||||
url="https://github.com/AustrianToast/update"
|
|
||||||
license=('GPL3')
|
|
||||||
provides=(update)
|
|
||||||
depends=('bash')
|
|
||||||
makedepends=('git')
|
|
||||||
optdepends=('yay' 'paru' 'pacaur' 'pikaur' 'aura' 'flatpak')
|
|
||||||
home=${HOME}
|
|
||||||
backup=(${home#/}/.config/update.conf)
|
|
||||||
source=("$pkgname::git+https://github.com/AustrianToast/update.git")
|
|
||||||
md5sums=('SKIP')
|
|
||||||
|
|
||||||
package() {
|
|
||||||
cd "$pkgname"
|
|
||||||
make install
|
|
||||||
}
|
|
@ -18,7 +18,6 @@ or
|
|||||||
```bash
|
```bash
|
||||||
just install
|
just install
|
||||||
```
|
```
|
||||||
=======
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -30,10 +29,11 @@ no flag same as -p
|
|||||||
-f updates using flatpak update only
|
-f updates using flatpak update only
|
||||||
-p updates using a pacman-wrapper only
|
-p updates using a pacman-wrapper only
|
||||||
-a updates using flatpak update and a pacman-wrapper
|
-a updates using flatpak update and a pacman-wrapper
|
||||||
-g shutdowns the computer afterwards (needs to be the last or only option to work properly)
|
-g shutdowns the computer afterwards
|
||||||
-r reboots the computer afterwards (needs to be the last or only option to work properly)
|
-r reboots the computer afterwards
|
||||||
--help displays this message
|
--help displays this message
|
||||||
-P, --preview shows a preview of which pkg's will be updates
|
--preview shows a preview of which pkg's will be updates
|
||||||
|
--version prints out the version number
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
6
justfile
6
justfile
@ -1,12 +1,10 @@
|
|||||||
VER := "v1.7"
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@echo "==> Installing update {{VER}} into /usr/local/bin"
|
@echo "==> Installing update into /usr/local/bin"
|
||||||
@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 {{VER}} from /usr/local/bin"
|
@echo "==> Uninstalling update from /usr/local/bin"
|
||||||
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
||||||
@echo "==> Finished."
|
@echo "==> Finished."
|
||||||
|
6
makefile
6
makefile
@ -1,12 +1,10 @@
|
|||||||
VER = "v1.7"
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@echo "==> Installing update $(VER) into /usr/local/bin"
|
@echo "==> Installing update into /usr/local/bin"
|
||||||
@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 $(VER) from /usr/local/bin"
|
@echo "==> Uninstalling update from /usr/local/bin"
|
||||||
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
@sudo rm /usr/local/bin/update ${HOME}/.config/update.conf
|
||||||
@echo "==> Finished."
|
@echo "==> Finished."
|
||||||
|
85
update
85
update
@ -1,10 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
# updates using a pacman-wrapper and flatpak-update with flags
|
# updates using a pacman-wrapper and flatpak-update with flags
|
||||||
# version 1.7
|
|
||||||
|
|
||||||
source "$HOME"/.config/update.conf
|
source "$HOME"/.config/update.conf
|
||||||
|
|
||||||
|
VER="2.0.3"
|
||||||
IGREEN="\033[0;92m" # Intense Green
|
IGREEN="\033[0;92m" # Intense Green
|
||||||
IYELLOW="\033[0;93m" # Intense Red
|
IYELLOW="\033[0;93m" # Intense Red
|
||||||
NC="\033[0m" # Text Reset
|
NC="\033[0m" # Text Reset
|
||||||
@ -12,6 +12,16 @@ TMP="/tmp/update"
|
|||||||
DATE="$(date +"%Y-%m-%d %H:%M:%S")"
|
DATE="$(date +"%Y-%m-%d %H:%M:%S")"
|
||||||
PRE_BACKUP_AMOUNT="$(ls -Ub "$BACKUP_LOCATION"/ | grep -c ^before-backup)"
|
PRE_BACKUP_AMOUNT="$(ls -Ub "$BACKUP_LOCATION"/ | grep -c ^before-backup)"
|
||||||
POST_BACKUP_AMOUNT="$(ls -Ub "$BACKUP_LOCATION"/ | grep -c ^after-backup)"
|
POST_BACKUP_AMOUNT="$(ls -Ub "$BACKUP_LOCATION"/ | grep -c ^after-backup)"
|
||||||
|
FINAL_COMMAND=""
|
||||||
|
|
||||||
|
trap interrupt_function INT
|
||||||
|
|
||||||
|
interrupt_function() {
|
||||||
|
echo "Interrupt has been detected"
|
||||||
|
sudo rm /var/lib/pacman/db.lck &> /dev/null
|
||||||
|
rm -r "$TMP" &> /dev/null
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
Help() {
|
Help() {
|
||||||
echo "Usage: update [OPTION]"
|
echo "Usage: update [OPTION]"
|
||||||
@ -21,17 +31,32 @@ Help() {
|
|||||||
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 (needs to be the last or only option to work properly)"
|
echo "-g shutdowns the computer afterwards"
|
||||||
echo "-r reboots the computer afterwards (needs to be the last or only option to work properly)"
|
echo "-r reboots the computer afterwards"
|
||||||
echo "--help displays this message"
|
echo "--help displays this message"
|
||||||
echo "-P, --preview shows a preview of which pkg's will be updates"
|
echo "--preview shows a preview of which pkg's can be updated"
|
||||||
|
echo "--version prints out the version number"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_for_dblck() {
|
||||||
|
if [ -f /var/lib/pacman/db.lck ]; then {
|
||||||
|
echo -e "${IYELLOW}->${NC} /var/lib/pacman/db.lck exists"
|
||||||
|
echo -e "${IYELLOW}->${NC} there might be another instance of pacman running. exiting..."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_oldest_backup() {
|
||||||
|
if [[ $1 > $BACKUP_AMOUNT ]]; then
|
||||||
|
OLDEST_FILE="$(ls -t "$BACKUP_LOCATION" | grep $2 | tail -1)"
|
||||||
|
rm "$BACKUP_LOCATION"/"$OLDEST_FILE"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
before_backup() {
|
before_backup() {
|
||||||
if [[ $PRE_BACKUP_AMOUNT > $BACKUP_AMOUNT ]]; then
|
check_for_dblck
|
||||||
OLDEST_FILE="$(ls -t "$BACKUP_LOCATION" | grep before-backup | tail -1)"
|
delete_oldest_backup $PRE_BACKUP_AMOUNT before-backup
|
||||||
rm "$BACKUP_LOCATION"/"$OLDEST_FILE"
|
|
||||||
fi
|
|
||||||
rm -r "$TMP" &> /dev/null
|
rm -r "$TMP" &> /dev/null
|
||||||
mkdir "$TMP" && mkdir "$TMP"/before-backup_"$DATE" && mkdir "$TMP"/after-backup_"$DATE"
|
mkdir "$TMP" && mkdir "$TMP"/before-backup_"$DATE" && mkdir "$TMP"/after-backup_"$DATE"
|
||||||
pacman -Q > "$TMP"/before-backup_"$DATE"/pacman-pre.txt
|
pacman -Q > "$TMP"/before-backup_"$DATE"/pacman-pre.txt
|
||||||
@ -44,14 +69,11 @@ before_backup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
after_backup() {
|
after_backup() {
|
||||||
if [[ $POST_BACKUP_AMOUNT > $BACKUP_AMOUNT ]]; then
|
delete_oldest_backup $POST_BACKUP_AMOUNT after-backup
|
||||||
OLDEST_FILE="$(ls -t "$BACKUP_LOCATION" | grep after-backup | tail -1)"
|
|
||||||
rm "$BACKUP_LOCATION"/"$OLDEST_FILE"
|
|
||||||
fi
|
|
||||||
tar -cJf "$TMP"/after-backup_"$DATE".tar.xz.new "$TMP"/after-backup_"$DATE" &> /dev/null
|
tar -cJf "$TMP"/after-backup_"$DATE".tar.xz.new "$TMP"/after-backup_"$DATE" &> /dev/null
|
||||||
cp "$TMP"/after-backup_"$DATE".tar.xz.new "$BACKUP_LOCATION"
|
cp "$TMP"/after-backup_"$DATE".tar.xz.new "$BACKUP_LOCATION"
|
||||||
rename after-backup_"$DATE".tar.xz.new after-backup_"$DATE".tar.xz "$BACKUP_LOCATION"/after-backup_"$DATE".tar.xz.new
|
rename after-backup_"$DATE".tar.xz.new after-backup_"$DATE".tar.xz "$BACKUP_LOCATION"/after-backup_"$DATE".tar.xz.new
|
||||||
rm -r "$TMP"
|
$FINAL_COMMAND
|
||||||
}
|
}
|
||||||
|
|
||||||
update_with_pacman_wrapper() {
|
update_with_pacman_wrapper() {
|
||||||
@ -64,21 +86,25 @@ update_with_flatpak() {
|
|||||||
flatpak list > "$TMP"/after-backup_"$DATE"/flatpak-after.txt
|
flatpak list > "$TMP"/after-backup_"$DATE"/flatpak-after.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ $1 = --help ]] && Help && exit 0
|
if [[ ${1:0:2} = -- ]]; then
|
||||||
[[ $1 = --preview || $1 = -P ]] && sudo pacman -Sy &> /dev/null && sudo pacman -Qu && exit 0
|
case "${1:2}" in
|
||||||
|
help)
|
||||||
while [ -f /var/lib/pacman/db.lck ]; do {
|
Help ;;
|
||||||
echo -e "${IYELLOW}->${NC} /var/lib/pacman/db.lck exists"
|
preview)
|
||||||
echo -e "${IYELLOW}->${NC} there might be another instance of pacman running. exiting..."
|
sudo pacman -Sy &> /dev/null && sudo pacman -Qu ;;
|
||||||
exit 1
|
version)
|
||||||
}
|
echo "$VER" ;;
|
||||||
done
|
?)
|
||||||
|
Help && exit 1;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
|
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
|
||||||
|
|
||||||
[[ -z $1 ]] && update_with_pacman_wrapper;
|
[[ $1 ]] || update_with_pacman_wrapper
|
||||||
while getopts 'fpagr' OPTIONS; do
|
while getopts 'fpagr' OPTIONS; do
|
||||||
case "$OPTIONS" in
|
case $OPTIONS in
|
||||||
f)
|
f)
|
||||||
update_with_flatpak ;;
|
update_with_flatpak ;;
|
||||||
p)
|
p)
|
||||||
@ -87,15 +113,12 @@ while getopts 'fpagr' OPTIONS; do
|
|||||||
update_with_pacman_wrapper; update_with_flatpak ;;
|
update_with_pacman_wrapper; update_with_flatpak ;;
|
||||||
g)
|
g)
|
||||||
[[ $1 = -g ]] && update_with_pacman_wrapper
|
[[ $1 = -g ]] && update_with_pacman_wrapper
|
||||||
after_backup && echo -e "${IGREEN}after-backup complete${NC}" && sleep 3s && shutdown now
|
FINAL_COMMAND="shutdown now" ;;
|
||||||
exit 0;;
|
|
||||||
r)
|
r)
|
||||||
[[ $1 = -r ]] && update_with_pacman_wrapper
|
[[ $1 = -r ]] && update_with_pacman_wrapper
|
||||||
after_backup && echo -e "${IGREEN}after-backup complete${NC}" && sleep 3s && reboot
|
FINAL_COMMAND="reboot" ;;
|
||||||
exit 0;;
|
|
||||||
?)
|
?)
|
||||||
Help
|
Help && exit 1;;
|
||||||
exit 1;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user