Advertisement
Guest User

snapshot+systemupdate.sh GI-Joe 7.12.2020

a guest
Dec 7th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. cat snapshot+systemupdate.sh
  2.  
  3. #!/bin/bash
  4. #
  5. # Snapshot + System Update
  6. # ---------------------------
  7. # Snapshot - Rollback - Btrfs
  8. # ---------------------------
  9.  
  10. BTRFS=/usr/bin/btrfs
  11. CP=/usr/bin/cp
  12. ECHO=/usr/bin/echo
  13. GREP=/usr/bin/grep
  14. MOUNT=/usr/bin/mount
  15. MV=/usr/bin/mv
  16. #PIKAUR=/usr/bin/pikaur
  17. PACMAN=/usr/bin/pacman
  18. REFLECTOR=/usr/bin/reflector
  19. SED=/usr/bin/sed
  20. SUDO=/usr/bin/sudo
  21. CHECKUPDATES=/usr/bin/checkupdates
  22.  
  23. # ---------------------------
  24. # Snapshot System
  25. # ---------------------------
  26. if $CHECKUPDATES ; then
  27. # if true ; then
  28. bootstate=`$MOUNT | $GREP "on / type btrfs" | $GREP "subvol=/@snapshots/TESTING"`
  29. if [ -z "$bootstate" ]
  30. then
  31. $ECHO ""
  32. $ECHO $bootstate
  33. $ECHO ""
  34. $ECHO "System ist nicht mit TESTING hochgefahren !"
  35. $ECHO "ENDE !"
  36. sleep 2
  37. exit 1
  38. else
  39. # -------- make new OLDSTABLE --------
  40. $SUDO $BTRFS subvolume delete /.snapshots/OLDSTABLE
  41. $SUDO $MV /.snapshots/STABLE /.snapshots/OLDSTABLE
  42. $SUDO $SED -i 's/STABLE/OLDSTABLE/g' /.snapshots/OLDSTABLE/etc/fstab
  43. $SUDO $CP /boot/vmlinuz-linux-stable /boot/vmlinuz-linux-oldstable
  44. $SUDO $CP /boot/initramfs-linux-stable.img /boot/initramfs-linux-oldstable.img
  45. # $SUDO $CP /boot/vmlinuz-linux-lts-stable /boot/vmlinuz-linux-lts-oldstable
  46. # $SUDO $CP /boot/initramfs-linux-lts-stable.img /boot/initramfs-linux-lts-oldstable.img
  47.  
  48. # --------- make new STABLE ----------
  49. $SUDO $BTRFS subvolume snapshot / /.snapshots/STABLE
  50. $SUDO $SED -i 's/TESTING/STABLE/g' /.snapshots/STABLE/etc/fstab
  51. $SUDO $CP /boot/vmlinuz-linux /boot/vmlinuz-linux-stable
  52. $SUDO $CP /boot/initramfs-linux.img /boot/initramfs-linux-stable.img
  53. # $SUDO $CP /boot/vmlinuz-linux-lts /boot/vmlinuz-linux-lts-stable
  54. # $SUDO $CP /boot/initramfs-linux-lts.img /boot/initramfs-linux-lts-stable.img
  55.  
  56. # ---------------------------
  57. # Update System
  58. # ---------------------------
  59. $SUDO $REFLECTOR -l 10 -p https --sort rate # initiate 2 ChannelFastSpeed of MagentaHybrid-Router
  60. $SUDO $REFLECTOR --verbose -l 10 -p https --sort rate --save /etc/pacman.d/mirrorlist
  61. # $SUDO $PACMAN -Syu
  62. #$PIKAUR -Syu # aktualisiert AUR gleich mit :-)
  63.  
  64. # -------------------------------------------------------------------------------------
  65. # disable automatic-search for grub - only 00_header 40_custom 41_custom are needed
  66. # -------------------------------------------------------------------------------------
  67. for file in `ls /etc/grub.d/ | grep -v ^4 | grep -v README | grep -v ^00 | grep -v disabled$` ; do
  68. $SUDO chmod 644 /etc/grub.d/$file
  69. $SUDO mv /etc/grub.d/$file /etc/grub.d/"$file"_disabled
  70. done
  71.  
  72. # --------------------------------------------
  73. # Balance Filesystem
  74. # --------------------------------------------
  75. $SUDO $BTRFS balance start -dusage=5 /btrfs
  76.  
  77. fi
  78. else
  79. echo "Keine Updates vorhanden - ENDE !"
  80. sleep 2
  81. fi
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement