Skip to content

Instantly share code, notes, and snippets.

@varqox
Forked from ephemient/⁄etc⁄pacman.d⁄hooks⁄linux-modules-post.hook
Last active February 16, 2023 16:15
Show Gist options
  • Select an option

  • Save varqox/a4e5abd490059844e0e521db531a9d8f to your computer and use it in GitHub Desktop.

Select an option

Save varqox/a4e5abd490059844e0e521db531a9d8f to your computer and use it in GitHub Desktop.

Revisions

  1. varqox revised this gist Jul 11, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions INSTALL.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #/bin/sh
    # Run: curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/e69686e6b63791ef82fc3e182689986ffe838a53/INSTALL.sh' | sudo sh
    curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/85e25433f2f67576ea82b38a7cd461d424376901/%25E2%2581%2584usr%25E2%2581%2584share%25E2%2581%2584libalpm%25E2%2581%2584hooks%25E2%2581%258430-linux-modules-pre.hook' | sudo tee /usr/share/libalpm/hooks/30-linux-modules-pre.hook
    curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/85e25433f2f67576ea82b38a7cd461d424376901/%25E2%2581%2584usr%25E2%2581%2584share%25E2%2581%2584libalpm%25E2%2581%2584hooks%25E2%2581%258490-linux-modules-post.hook' | sudo tee /usr/share/libalpm/hooks/90-linux-modules-post.hook
    curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/85e25433f2f67576ea82b38a7cd461d424376901/%25E2%2581%2584etc%25E2%2581%2584tmpfiles.d%25E2%2581%2584linux-modules-cleanup.conf' | sudo tee /etc/tmpfiles.d/linux-modules-cleanup.conf
  2. varqox revised this gist Jul 11, 2018. 3 changed files with 13 additions and 7 deletions.
    6 changes: 6 additions & 0 deletions INSTALL.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #/bin/sh
    curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/85e25433f2f67576ea82b38a7cd461d424376901/%25E2%2581%2584usr%25E2%2581%2584share%25E2%2581%2584libalpm%25E2%2581%2584hooks%25E2%2581%258430-linux-modules-pre.hook' | sudo tee /usr/share/libalpm/hooks/30-linux-modules-pre.hook
    curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/85e25433f2f67576ea82b38a7cd461d424376901/%25E2%2581%2584usr%25E2%2581%2584share%25E2%2581%2584libalpm%25E2%2581%2584hooks%25E2%2581%258490-linux-modules-post.hook' | sudo tee /usr/share/libalpm/hooks/90-linux-modules-post.hook
    curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/85e25433f2f67576ea82b38a7cd461d424376901/%25E2%2581%2584etc%25E2%2581%2584tmpfiles.d%25E2%2581%2584linux-modules-cleanup.conf' | sudo tee /etc/tmpfiles.d/linux-modules-cleanup.conf
    curl 'https://gist.github.com/varqox/a4e5abd490059844e0e521db531a9d8f/raw/85e25433f2f67576ea82b38a7cd461d424376901/%25E2%2581%2584etc%25E2%2581%2584systemd%25E2%2581%2584system%25E2%2581%2584linux-modules-cleanup.service' | sudo tee /etc/systemd/system/linux-modules-cleanup.service
    systemctl enable linux-modules-cleanup.service
    7 changes: 4 additions & 3 deletions ⁄usr⁄share⁄libalpm⁄hooks⁄30-linux-modules-pre.hook
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,8 @@ Type = Package
    Target = linux

    [Action]
    Description = Save Linux kernel modules
    When = PreTransaction
    Description = Restore Linux kernel modules
    When = PostTransaction
    Depends = coreutils
    Depends = rsync
    Exec = /bin/sh -c 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/lib/modules/${KVER}" /lib/modules/backup/; fi'
    Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/backup/${KVER}"; then rsync -AHXal --ignore-existing "/lib/modules/backup/${KVER}" /lib/modules/; fi; rm -rf /lib/modules/backup'
    7 changes: 3 additions & 4 deletions ⁄usr⁄share⁄libalpm⁄hooks⁄90-linux-modules-post.hook
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,7 @@ Type = Package
    Target = linux

    [Action]
    Description = Restore Linux kernel modules
    When = PostTransaction
    Depends = coreutils
    Description = Save Linux kernel modules
    When = PreTransaction
    Depends = rsync
    Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/backup/${KVER}"; then rsync -AHXal --ignore-existing "/lib/modules/backup/${KVER}" /lib/modules/; fi; rm -rf /lib/modules/backup'
    Exec = /bin/sh -c 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/lib/modules/${KVER}" /lib/modules/backup/; fi'
  3. varqox revised this gist Jul 11, 2018. 2 changed files with 7 additions and 7 deletions.
    7 changes: 3 additions & 4 deletions ⁄usr⁄share⁄libalpm⁄hooks⁄30-linux-modules-pre.hook
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,7 @@ Type = Package
    Target = linux

    [Action]
    Description = Restore Linux kernel modules
    When = PostTransaction
    Depends = coreutils
    Description = Save Linux kernel modules
    When = PreTransaction
    Depends = rsync
    Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/backup/${KVER}"; then rsync -AHXal --ignore-existing "/lib/modules/backup/${KVER}" /lib/modules/; fi; rm -rf /lib/modules/backup'
    Exec = /bin/sh -c 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/lib/modules/${KVER}" /lib/modules/backup/; fi'
    7 changes: 4 additions & 3 deletions ⁄usr⁄share⁄libalpm⁄hooks⁄90-linux-modules-post.hook
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,8 @@ Type = Package
    Target = linux

    [Action]
    Description = Save Linux kernel modules
    When = PreTransaction
    Description = Restore Linux kernel modules
    When = PostTransaction
    Depends = coreutils
    Depends = rsync
    Exec = /bin/sh -c 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/lib/modules/${KVER}" /lib/modules/backup/; fi'
    Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/backup/${KVER}"; then rsync -AHXal --ignore-existing "/lib/modules/backup/${KVER}" /lib/modules/; fi; rm -rf /lib/modules/backup'
  4. varqox revised this gist Jul 11, 2018. 2 changed files with 0 additions and 0 deletions.
  5. varqox revised this gist Jul 11, 2018. 2 changed files with 0 additions and 0 deletions.
  6. varqox renamed this gist Apr 29, 2018. 1 changed file with 0 additions and 0 deletions.
  7. varqox revised this gist Apr 29, 2018. 2 changed files with 0 additions and 0 deletions.
  8. @ephemient ephemient created this gist Nov 4, 2016.
    11 changes: 11 additions & 0 deletions ⁄etc⁄pacman.d⁄hooks⁄linux-modules-post.hook
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    [Trigger]
    Operation = Upgrade
    Type = Package
    Target = linux

    [Action]
    Description = Restore Linux kernel modules
    When = PostTransaction
    Depends = coreutils
    Depends = rsync
    Exec = /bin/sh -xc 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/backup/${KVER}"; then rsync -AHXal --ignore-existing "/lib/modules/backup/${KVER}" /lib/modules/; fi; rm -rf /lib/modules/backup'
    10 changes: 10 additions & 0 deletions ⁄etc⁄pacman.d⁄hooks⁄linux-modules-pre.hook
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    [Trigger]
    Operation = Upgrade
    Type = Package
    Target = linux

    [Action]
    Description = Save Linux kernel modules
    When = PreTransaction
    Depends = rsync
    Exec = /bin/sh -c 'KVER="${KVER:-$(uname -r)}"; if test -e "/lib/modules/${KVER}"; then rsync -AHXal --delete-after "/lib/modules/${KVER}" /lib/modules/backup/; fi'
    9 changes: 9 additions & 0 deletions ⁄etc⁄systemd⁄system⁄linux-modules-cleanup.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    [Unit]
    Description=Clean up modules from old kernels

    [Service]
    Type=oneshot
    ExecStart=/bin/bash -exc 'for i in /usr/lib/modules/[0-9]*; do if [[ $${i##*/} = \'%v\' ]] || pacman -Qo "$${i}"; then continue; fi; rsync -AHXal "$${i}" /usr/lib/modules/.old/; rm -rf "$${i}"; done'

    [Install]
    WantedBy=basic.target
    1 change: 1 addition & 0 deletions ⁄etc⁄tmpfiles.d⁄linux-modules-cleanup.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    R! /usr/lib/modules/.old/* - - - 4w