I am trying to update the packages on a Pi Zero which is located an awful long way from where I am so I would prefer that this didn’t fail!
These are the 2 packages
libglib2.0-0/oldstable 2.66.8-1+deb11u4 armhf [upgradable from: 2.66.8-1+deb11u3]
wpasupplicant/oldstable 2:2.9.0-21+deb11u1 armhf [upgradable from: 2:2.9.0-21]
As I am connected to Wi-Fi I can understand if this cannot be completed, is there a way to download the packages manually and then install them in a script when the box reboots?
Any advice is welcome.
Thanks
Jason
TLDR;
- download the packages without installing them
- verify that the packages are correctly downloaded
- write a script which installs the packages
- config crontab to run the script on boot
- reboot
(assuming you do this as root
user)
1. download the packages
apt-get update
apt-get install --download-only libglib2.0-0 wpasupplicant
2. Verify
ls /var/cache/apt/archives/libglib2.0-0* /var/cache/apt/archives/wpasupplicant*
You should see an output for both files.
3. create the script:
nano ~/update_script.sh
Creates the script in home directory of root
.
Content of the script:
#!/bin/bash
# Install the downloaded packages
dpkg -i /var/cache/apt/archives/libglib2.0-0*.deb
dpkg -i /var/cache/apt/archages/wpasupplicant*.deb
# Remove the script from the crontab
(crontab -l | grep -v 'update_script.sh') | crontab -
# Delete the script
rm -- "$0"
Save and close nano.
4. Make it executable
chmod +x ~/update_script.sh
5. Add it to crontab
crontab -e
Add the line:
@reboot /root/update_script.sh
6. reboot
reboot
To test the part with the script, crontab and reboot, you could just create a dummy script which creates a file somewhere or something similiar you can verify.
I make no guarantee that it will work
1 Like
Thank you very much!
I will give it a go later and provide feedback.
I made a couple of tweeks
- I copied the 2 .deb files from /var/cache/apt/archives to /root
- I put logging in the script because it failed the first time because no PATH was defined and I did not know why. The logging pointed that out.
- I removed the last 5 lines which removes update_script.sh from crontab (I did it manually after the script had run successfully)
So my script looks like this
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Install the downloaded packages
dpkg -i /root/libglib2.0-0*.deb >> /root/update_script.log 2>&1
dpkg -i /root/wpasupplicant*.deb >> /root/update_script.log 2>&1
Thanks very much once again.
1 Like
Another option might be using screen
tool. This should keep alive the session even if disconnected Debian -- Details of package screen in bookworm
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.