Last active
          May 8, 2025 08:07 
        
      - 
      
 - 
        
Save slowpeek/b808a4c5ccf2b29803e51d652d512203 to your computer and use it in GitHub Desktop.  
    Clean up netplan stuff after dropbear-initramfs
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/sh | |
| : <<'README' | |
| This is a fix for a well-known problem [1] with dropbear-initramfs+netplan | |
| combo. | |
| When dropbear starts, it enables networking [2]. This results in netplan configs | |
| for available ifaces created under /run/netplan. After unlocking, the configs | |
| are still there preventing networkmanager from picking ifaces up: by default, | |
| ifaces matched by the IFDOWN variable are only put down. So to make it clean, we | |
| have to explicitly drop the netplan stuff. | |
| Put this script under /etc/initramfs-tools/scripts/init-bottom/ and update | |
| initramfs. | |
| [1] https://bugs.launchpad.net/ubuntu/+source/dropbear/+bug/1813394 | |
| [2] configure_networking() from /usr/share/initramfs-tools/scripts/functions | |
| README | |
| PREREQ="dropbear" | |
| prereqs() { | |
| echo "$PREREQ" | |
| } | |
| case "$1" in | |
| prereqs) | |
| prereqs | |
| exit 0 ;; | |
| esac | |
| IFDOWN="*" | |
| CONF=/etc/dropbear/dropbear.conf | |
| [ ! -e "$CONF" ] || . "$CONF" | |
| if [ "$BOOT" != nfs ] && [ "$IFDOWN" != none ]; then | |
| for IFACE in /sys/class/net/$IFDOWN; do | |
| [ -e "$IFACE" ] || continue | |
| PLAN="/run/netplan/${IFACE##*/}.yaml" | |
| [ ! -e "$PLAN" ] || rm "$PLAN" | |
| done | |
| fi | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Awesome, works flawlessly.