Perl Nopaste Service

Download: Here New: Here

Nopaste from: Fri Nov 29 17:07:27 2019

Expires on: never

From: Anonymous (91.58.152.151)

Code language: Plain

Description: The user has not left a description.

Code:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
sudo cat  snapshot+systemupdate.sh
#!/bin/bash
# Snapshot + System Update
# ---------------------------
# Snapshot - Rollback - Btrfs
# ---------------------------
 
BTRFS=/usr/bin/btrfs
CP=/usr/bin/cp
ECHO=/usr/bin/echo
GREP=/usr/bin/grep
MOUNT=/usr/bin/mount
MV=/usr/bin/mv
# PIKAUR=/usr/bin/pikaur
PACMAN=/usr/bin/pacman
# REFLECTOR=/usr/bin/reflector
SED=/usr/bin/sed
SUDO=/usr/bin/sudo
CHECKUPDATES=/usr/bin/checkupdates
 
# ---------------------------
#      Snapshot System
# ---------------------------
if $CHECKUPDATES >/dev/nul 2>/dev/null ; then
bootstate=`$MOUNT | $GREP "on / type btrfs" | $GREP "subvol=/@snapshots/TESTING"`
if [ -z $"{bootstate}" ]
    then
        $ECHO ""
        $ECHO $bootstate
        $ECHO ""
        $ECHO "System ist nicht mit TESTING hochgefahren !"
        $ECHO "ENDE !"
        exit
    else
        # -------- make new OLDSTABLE --------
        $SUDO $BTRFS subvolume delete /.snapshots/OLDSTABLE
        $SUDO $MV /.snapshots/STABLE /.snapshots/OLDSTABLE
        $SUDO $SED -i 's/STABLE/OLDSTABLE/g' /.snapshots/OLDSTABLE/etc/fstab
        $SUDO $CP /boot/vmlinuz-linux-stable /boot/vmlinuz-linux-oldstable
        $SUDO $CP /boot/initramfs-linux-stable.img /boot/initramfs-linux-oldstable.img
       
        # --------- make new STABLE ----------
        $SUDO $BTRFS subvolume snapshot / /.snapshots/STABLE
        $SUDO $SED -i 's/TESTING/STABLE/g' /.snapshots/STABLE/etc/fstab
        $SUDO $CP /boot/vmlinuz-linux /boot/vmlinuz-linux-stable
        $SUDO $CP /boot/initramfs-linux.img /boot/initramfs-linux-stable.img
       
        # ---------------------------
        #      Update System
        # ---------------------------
        $SUDO $REFLECTOR --verbose -l 10 -p https --sort rate --save /etc/pacman.d/mirrorlist
        $SUDO $PACMAN -Syu
        # $PIKAUR -Syu # aktualisiert AUR gleich mit :-)
       
        # ---------------------------
        #    Balance Filesystem
        # --------------------------
        $SUDO $BTRFS balance start -dusage=5 /btrfs
fi
else
    echo "Keine Updates vorhanden - ENDE !"
    sleep 2
fi