Score:0

Starting custom process after auto update completes - Apt-Get pauses custom install script

es flag

A little background: I am trying to set up an automated install process in AWS that configures my servers with little intervention. I have it generally working in Ubuntu 18.04. However, in 22.04 (ARM) There are errors.

The problem: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

A solution: https://linuxconfig.org/disable-automatic-updates-on-ubuntu-22-04-jammy-jellyfish-linux#:~:text=Open%20a%20command%20line%20terminal%20and%20then%20edit,the%20file%2C%20replacing%20whatever%20is%20currently%20in%20there%3A

I have implemented the solution above. The issue is that when I run apt list --installed.

I still get: unattended-upgrades/jammy,now 2.8ubuntu1 all [installed,automatic].

In 18.04 the end of that line reads [installed]. Am I able to make the 22.04 version manual so the system sees it as such? I really don't want it to run at all on the first boot. This automated version locks up my ability to continue processing the server until I either reboot it or the process finishes. My automation breaks, where if I do it manually it works.

If I can't have that, I could also use a comment or two on knowing how to know that auto-install has finished on the first boot.

I am noticing that I have to press enter twice during the upgrade process even with the -y flag. Is this part of the issue? Or a different issue?

Thanks All!

UPDATE: My understanding of what is going on in the apt list -installed command is corrected from the comments.

My issues now are:

  1. Is there a way I can start the process without using sleep and an arbitrary number?
  2. How do I deal with apt-get upgrade needing me to press enter to continue my custom installations?
user535733 avatar
cn flag
Let's make a quick correction on the output of `apt list`. The output `[installed,automatic]` does not mean that the software runs automatically. It means that the package is a dependency (it was pulled in automatically by apt).
user535733 avatar
cn flag
An issue with trying to prevent apt from running is that you might be creating a race condition. It depends on your process, and might be subject to bugs...or features. Example: When I was doing something similar using cloud-init a few years ago, I found that apt ran anyway before my customizations were processed. My experience was that waiting until apt completed was the only sure way of getting uniform results. Perhaps your experience will differ.
LeviRCoding avatar
es flag
Your first point is well taken. That is why I couldn't find anything on it. It would account for some reason for the differences between 18 and 22. You have a fair point in your second comment. My main worry is that the software that I install is a third-party app (of course) and it can be a bit... brittle... do any of you have suggestions of how to begin my process only after the auto-update has finished?
muru avatar
us flag
@LeviRCoding https://askubuntu.com/a/373478/158442 is what I use for my EC2 user data scripts. I write a wrapper function for apt using that, and use it everywhere in the script.
Score:0
es flag

Using Muru's link and reading there: How to make a package manager wait if another instance of APT is running?

I went down to Mendhak's comment near the bottom and apparently, since 20.04, the functionality I need has been in apt-get.

His comment led me to: https://blog.sinjakli.co.uk/2021/10/25/waiting-for-apt-locks-without-the-hacky-bash-scripts/. Which is exactly the same application and issue that I am working with.

The short version is: sudo apt-get -o DPkg::Lock::Timeout=60 install packagename

Between the other thread and the external link, I had no shortage of options. Please support the posters there also.

muru avatar
us flag
Just a note that while this handles dpkg locks, you could potentially run into problems with apt's locks as well (IIRC it holds a lock on the cache while downloading packages, or updating package lists - don't remember which one exactly)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.