Compare commits
3 Commits
12e9698024
...
8cdba1906f
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cdba1906f | |||
| 2984ef9193 | |||
| bb5855fec9 |
50
arch_update
50
arch_update
@@ -1,45 +1,31 @@
|
|||||||
#! /bin/sh -
|
#!/bin/sh
|
||||||
#Full Arch Linux Update Script
|
# Full Arch Linux Update Script
|
||||||
|
|
||||||
SNAPSHOT_DIR=/.snapshots
|
set -e
|
||||||
DAYS_TO_KEEP=30
|
|
||||||
|
|
||||||
# Backup system
|
BACKUP_LIMIT=3
|
||||||
if which btrfs >/dev/null; then
|
|
||||||
echo -e '\nCreating backup...' >&2
|
|
||||||
|
|
||||||
cur_time=$(date -Is)
|
|
||||||
cur_time_s=$(date -d $cur_time +%s)
|
|
||||||
|
|
||||||
for file in $(ls "$SNAPSHOT_DIR"); do
|
|
||||||
old_time_s=$(date -d $(echo "$file" | sed 's/[[:alpha:]]\+-//') +%s)
|
|
||||||
if [ $(((cur_time_s - old_time_s) / 86400)) -gt $DAYS_TO_KEEP ]; then
|
|
||||||
sudo btrfs subvolume delete "$SNAPSHOT_DIR"/"$file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
sudo btrfs subvolume snapshot / "$SNAPSHOT_DIR"/root-$cur_time
|
|
||||||
sudo btrfs subvolume snapshot /home "$SNAPSHOT_DIR"/home-$cur_time
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
echo -e '\nInstalling dependencies ...' >&2
|
echo -e '\nInstalling dependencies ...' >&2
|
||||||
! which curl >/dev/null 2>&1 && sudo pacman -Syu curl
|
|
||||||
! which git >/dev/null 2>&1 && sudo pacman -Syu git
|
|
||||||
if ! which vim >/dev/null 2>&1; then
|
|
||||||
sudo pacman -Syu neovim
|
|
||||||
sudo ln -s /usr/bin/nvim /usr/local/bin/vim
|
|
||||||
fi
|
|
||||||
! which rankmirrors >/dev/null 2>&1 && sudo pacman -Syu pacman-contrib
|
|
||||||
if ! which yay >/dev/null 2>&1; then
|
if ! which yay >/dev/null 2>&1; then
|
||||||
sudo pacman -Syu
|
|
||||||
git clone https://aur.archlinux.org/yay.git
|
git clone https://aur.archlinux.org/yay.git
|
||||||
cd yay
|
cd yay
|
||||||
makepkg -cirs
|
makepkg -cirs
|
||||||
cd ..
|
cd ..
|
||||||
rm -fr yay
|
rm -fr yay
|
||||||
fi
|
fi
|
||||||
! which yaycache >/dev/null 2>&1 && yay -Syu yaycache
|
yay -Syu --needed --noconfirm curl git neovim pacman-contrib yaycache
|
||||||
|
[ ! -e /usr/local/bin/vim ] && sudo ln -s /usr/bin/nvim /usr/local/bin/vim
|
||||||
|
|
||||||
|
# Backup system
|
||||||
|
if which btrfs >/dev/null; then
|
||||||
|
yay -Syu --needed --noconfirm snapper
|
||||||
|
[ ! -f /etc/snapper/configs/root ] && sudo snapper -c root create-config /
|
||||||
|
[ ! $(sudo awk -F '"' '/NUMBER_LIMIT=/ {print $2}' /etc/snapper/configs/root) -eq $BACKUP_LIMIT ] && sudo sed -i.bak "s/\(NUMBER_LIMIT=\"\).*\"/\1$BACKUP_LIMIT\"/" /etc/snapper/configs/root
|
||||||
|
|
||||||
|
echo -e '\nCreating backup...' >&2
|
||||||
|
sudo snapper -c root create -c number
|
||||||
|
fi
|
||||||
|
|
||||||
# Update mirrors
|
# Update mirrors
|
||||||
echo -e '\nUpdating mirrors ...' >&2
|
echo -e '\nUpdating mirrors ...' >&2
|
||||||
@@ -47,12 +33,12 @@ curl -s 'https://archlinux.org/mirrorlist/?country=DE&protocol=https&use_mirror_
|
|||||||
|
|
||||||
# Update system
|
# Update system
|
||||||
echo -e '\nUpdating system ...' >&2
|
echo -e '\nUpdating system ...' >&2
|
||||||
yay -Syu
|
yay -Syu --noconfirm
|
||||||
|
|
||||||
# Remove orphans
|
# Remove orphans
|
||||||
echo -e '\nRemoving orphans ...' >&2
|
echo -e '\nRemoving orphans ...' >&2
|
||||||
orphans=$(yay -Qtdq)
|
orphans=$(yay -Qtdq)
|
||||||
[ ! "X$orphans" = 'X' ] && yay -Rns $orphans
|
[ ! "X$orphans" = 'X' ] && yay -Rns --noconfirm $orphans
|
||||||
|
|
||||||
# Clean cache
|
# Clean cache
|
||||||
echo -e '\nCleaning cache ...' >&2
|
echo -e '\nCleaning cache ...' >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user