If you have a Tailscale server running remotely and wanna upgrade the tailscale via apt update && apt upgrade, you are likely to have an issue that the SSH connection dropped when dpkg is configuring the tailscale daemon.
And you will get stuck there with an error
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
But you cannot run and finish it before the connection dropped.
AI agent or someone suggests to use tmux, nohup or screen, but from my experience, neither of them will work.
My solution is to add a service in systemd by the following steps:
- Create a new service file
You'll create a new service file in the /etc/systemd/system/ directory.
The standard convention is to name it something descriptive, ending with .service.
sudo vim /etc/systemd/system/fix-tailscale.service
with the following content:
[Unit]
Description=Fix dpkg script
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash -c 'dpkg --configure -a'
User=root
[Install]
WantedBy=multi-user.target
- Reload the service config
sudo systemctl daemon-reload
- Enable and run the service
sudo systemctl enable fix-tailscale.service
sudo systemctl start fix-tailscale.service
Now, your SSH connection will drop one-more time, but it will fix the issue and complete the upgrade this time. Cheers :)
Thank you 🙏