Enabling unattended-upgrades from a shell scriptI accidentally deleted /etc/apt/apt.conf.d/20auto-upgradesHow can I stop unattended-upgrades from rebooting the machine?Why is unattended-upgrades activated by default?Unattended upgradesProgrammatically check unattended upgrades result
Undesired blank space between some words
Why aren't we seeing carbon taxes in practice?
Is there a word/short phrase for "the most" of something (not necessarily the majority)?
Why is 1>a.txt 2>&1 different from 1>a.txt 2>a.txt ? (Example shown)
How to get a bowl with one liter of water
Who started calling the matrix multiplication "multiplication"?
Why does China have so few nuclear weapons?
How to join many tables side by side?
Is this a valid use of Deflect Missiles according to RAW?
Berlin 1923 & 1925 Address Book Abbreviations "I", "E", "Kgst" and "Mb"
Declining a paper review after accepting it and seeing the manuscript
one list minus another
Is harmlessly appearing to be a school bus driver a crime?
Pass on your radiation
Would a uranium 235 fuel pellet the size of Earth explode?
Could the barycenter orbit of our sun be greatly underestimated?
What's the current status of the Vehicle Routing Problem in the logistics industry?
Is a datagram from an upper network layer converted 1:1 to one of the lower layer?
DIY inkjet transparency film or photopaper
What Lego set has the biggest box?
Short story: Man gains X-ray vision, cheats at cards, sees a clot in his blood
Shp is not valid or recognized data source using QGIS
Which seat 'predicts' the outcomes of UK General Elections the best?
What's the greatest number of hands I can have to annoy my mother-in-law with?
Enabling unattended-upgrades from a shell script
I accidentally deleted /etc/apt/apt.conf.d/20auto-upgradesHow can I stop unattended-upgrades from rebooting the machine?Why is unattended-upgrades activated by default?Unattended upgradesProgrammatically check unattended upgrades result
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I have a shell script to automatically configure new Ubuntu virtual machines for my purposes. I would like this script to install and enable unattended-upgrades
, but I cannot figure out how to do so without user interaction.
The usual way to enable upgrades is dpkg-reconfigure unattended-upgrades
, but of course that is interactive. The noninteractive front end avoids asking any questions at all, and the text front end seems bound and determined to do its I/O with the tty and not with stdin/stdout.
server upgrade scripts dpkg
add a comment
|
I have a shell script to automatically configure new Ubuntu virtual machines for my purposes. I would like this script to install and enable unattended-upgrades
, but I cannot figure out how to do so without user interaction.
The usual way to enable upgrades is dpkg-reconfigure unattended-upgrades
, but of course that is interactive. The noninteractive front end avoids asking any questions at all, and the text front end seems bound and determined to do its I/O with the tty and not with stdin/stdout.
server upgrade scripts dpkg
1
I've not used this tool before, but it looks like enabling it writes a 1 to the two lines in the file /etc/apt/apt.conf.d/20auto-upgrades. If you manually write that file will it work?
– mfisch
Nov 17 '12 at 3:43
add a comment
|
I have a shell script to automatically configure new Ubuntu virtual machines for my purposes. I would like this script to install and enable unattended-upgrades
, but I cannot figure out how to do so without user interaction.
The usual way to enable upgrades is dpkg-reconfigure unattended-upgrades
, but of course that is interactive. The noninteractive front end avoids asking any questions at all, and the text front end seems bound and determined to do its I/O with the tty and not with stdin/stdout.
server upgrade scripts dpkg
I have a shell script to automatically configure new Ubuntu virtual machines for my purposes. I would like this script to install and enable unattended-upgrades
, but I cannot figure out how to do so without user interaction.
The usual way to enable upgrades is dpkg-reconfigure unattended-upgrades
, but of course that is interactive. The noninteractive front end avoids asking any questions at all, and the text front end seems bound and determined to do its I/O with the tty and not with stdin/stdout.
server upgrade scripts dpkg
server upgrade scripts dpkg
asked Oct 20 '12 at 4:24
Grant WatsonGrant Watson
1711 silver badge4 bronze badges
1711 silver badge4 bronze badges
1
I've not used this tool before, but it looks like enabling it writes a 1 to the two lines in the file /etc/apt/apt.conf.d/20auto-upgrades. If you manually write that file will it work?
– mfisch
Nov 17 '12 at 3:43
add a comment
|
1
I've not used this tool before, but it looks like enabling it writes a 1 to the two lines in the file /etc/apt/apt.conf.d/20auto-upgrades. If you manually write that file will it work?
– mfisch
Nov 17 '12 at 3:43
1
1
I've not used this tool before, but it looks like enabling it writes a 1 to the two lines in the file /etc/apt/apt.conf.d/20auto-upgrades. If you manually write that file will it work?
– mfisch
Nov 17 '12 at 3:43
I've not used this tool before, but it looks like enabling it writes a 1 to the two lines in the file /etc/apt/apt.conf.d/20auto-upgrades. If you manually write that file will it work?
– mfisch
Nov 17 '12 at 3:43
add a comment
|
5 Answers
5
active
oldest
votes
Just make a copy of /etc/apt/apt.conf.d/20auto-upgrades after configuring it the way you like, and drop that into place on your target machine. You could embed it in your script, or you could rsync or wget it in from a server, or whatever.
So basically your script might do something like this:
apt-get install unattended-upgrades
wget -O /etc/apt/apt.conf.d/20auto-upgrades http://myserver.mytld/confs/20auto-upgrades
/etc/init.d/unattended-upgrades restart
There's really no reason to monkey with the dpkg-reconfigure script at all.
If you don't want to fetch the conf file from a remote server, it's VERY very short and simple - the default version, which fetches and installs security updates only, looks like this:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
So you can just echo those lines into the config file directly with the following:
echo -e "APT::Periodic::Update-Package-Lists "1";nAPT::Periodic::Unattended-Upgrade "1";n" > /etc/apt/apt.conf.d/20auto-upgrades
add a comment
|
If you want to use dpkg-reconfigure, you can set the value with "debconf-set-selections", and then reconfigure it in a noninteractive way.
echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | debconf-set-selections; dpkg-reconfigure -f noninteractive unattended-upgrades
add a comment
|
You have to use sudo to echo into /etc/apt/apt.conf.d/20auto-upgrades
if [[ ! -f /etc/apt/apt.conf.d/20auto-upgrades.bak ]]; then
sudo cp /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades.bak
sudo rm /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "30";
APT::Periodic::Unattended-Upgrade "1";" | sudo tee --append /etc/apt/apt.conf.d/20auto-upgrades
fi
add a comment
|
dpkg-reconfigure -f noninteractive unattended-upgrades
add a comment
|
I would suggest to insert configuration parameters to configure unattended-upgrades.
sudo touch /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1"" >> /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Unattended-Upgrade "1" " >> /etc/apt/apt.conf.d/20auto-upgrades
Same way you can configure/add parameters according to your requirement in conf file /etc/apt/apt.conf.d/50unattended-upgrades
.
Don't forget to restart service to apply changes.
/etc/init.d/unattended-upgrades restart
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f203337%2fenabling-unattended-upgrades-from-a-shell-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just make a copy of /etc/apt/apt.conf.d/20auto-upgrades after configuring it the way you like, and drop that into place on your target machine. You could embed it in your script, or you could rsync or wget it in from a server, or whatever.
So basically your script might do something like this:
apt-get install unattended-upgrades
wget -O /etc/apt/apt.conf.d/20auto-upgrades http://myserver.mytld/confs/20auto-upgrades
/etc/init.d/unattended-upgrades restart
There's really no reason to monkey with the dpkg-reconfigure script at all.
If you don't want to fetch the conf file from a remote server, it's VERY very short and simple - the default version, which fetches and installs security updates only, looks like this:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
So you can just echo those lines into the config file directly with the following:
echo -e "APT::Periodic::Update-Package-Lists "1";nAPT::Periodic::Unattended-Upgrade "1";n" > /etc/apt/apt.conf.d/20auto-upgrades
add a comment
|
Just make a copy of /etc/apt/apt.conf.d/20auto-upgrades after configuring it the way you like, and drop that into place on your target machine. You could embed it in your script, or you could rsync or wget it in from a server, or whatever.
So basically your script might do something like this:
apt-get install unattended-upgrades
wget -O /etc/apt/apt.conf.d/20auto-upgrades http://myserver.mytld/confs/20auto-upgrades
/etc/init.d/unattended-upgrades restart
There's really no reason to monkey with the dpkg-reconfigure script at all.
If you don't want to fetch the conf file from a remote server, it's VERY very short and simple - the default version, which fetches and installs security updates only, looks like this:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
So you can just echo those lines into the config file directly with the following:
echo -e "APT::Periodic::Update-Package-Lists "1";nAPT::Periodic::Unattended-Upgrade "1";n" > /etc/apt/apt.conf.d/20auto-upgrades
add a comment
|
Just make a copy of /etc/apt/apt.conf.d/20auto-upgrades after configuring it the way you like, and drop that into place on your target machine. You could embed it in your script, or you could rsync or wget it in from a server, or whatever.
So basically your script might do something like this:
apt-get install unattended-upgrades
wget -O /etc/apt/apt.conf.d/20auto-upgrades http://myserver.mytld/confs/20auto-upgrades
/etc/init.d/unattended-upgrades restart
There's really no reason to monkey with the dpkg-reconfigure script at all.
If you don't want to fetch the conf file from a remote server, it's VERY very short and simple - the default version, which fetches and installs security updates only, looks like this:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
So you can just echo those lines into the config file directly with the following:
echo -e "APT::Periodic::Update-Package-Lists "1";nAPT::Periodic::Unattended-Upgrade "1";n" > /etc/apt/apt.conf.d/20auto-upgrades
Just make a copy of /etc/apt/apt.conf.d/20auto-upgrades after configuring it the way you like, and drop that into place on your target machine. You could embed it in your script, or you could rsync or wget it in from a server, or whatever.
So basically your script might do something like this:
apt-get install unattended-upgrades
wget -O /etc/apt/apt.conf.d/20auto-upgrades http://myserver.mytld/confs/20auto-upgrades
/etc/init.d/unattended-upgrades restart
There's really no reason to monkey with the dpkg-reconfigure script at all.
If you don't want to fetch the conf file from a remote server, it's VERY very short and simple - the default version, which fetches and installs security updates only, looks like this:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
So you can just echo those lines into the config file directly with the following:
echo -e "APT::Periodic::Update-Package-Lists "1";nAPT::Periodic::Unattended-Upgrade "1";n" > /etc/apt/apt.conf.d/20auto-upgrades
edited Feb 23 '15 at 21:32
Matthew Cordaro
4915 silver badges9 bronze badges
4915 silver badges9 bronze badges
answered Nov 18 '12 at 21:37
Jim SalterJim Salter
4,0151 gold badge12 silver badges33 bronze badges
4,0151 gold badge12 silver badges33 bronze badges
add a comment
|
add a comment
|
If you want to use dpkg-reconfigure, you can set the value with "debconf-set-selections", and then reconfigure it in a noninteractive way.
echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | debconf-set-selections; dpkg-reconfigure -f noninteractive unattended-upgrades
add a comment
|
If you want to use dpkg-reconfigure, you can set the value with "debconf-set-selections", and then reconfigure it in a noninteractive way.
echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | debconf-set-selections; dpkg-reconfigure -f noninteractive unattended-upgrades
add a comment
|
If you want to use dpkg-reconfigure, you can set the value with "debconf-set-selections", and then reconfigure it in a noninteractive way.
echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | debconf-set-selections; dpkg-reconfigure -f noninteractive unattended-upgrades
If you want to use dpkg-reconfigure, you can set the value with "debconf-set-selections", and then reconfigure it in a noninteractive way.
echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | debconf-set-selections; dpkg-reconfigure -f noninteractive unattended-upgrades
answered Jan 25 '16 at 12:25
user497484user497484
112 bronze badges
112 bronze badges
add a comment
|
add a comment
|
You have to use sudo to echo into /etc/apt/apt.conf.d/20auto-upgrades
if [[ ! -f /etc/apt/apt.conf.d/20auto-upgrades.bak ]]; then
sudo cp /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades.bak
sudo rm /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "30";
APT::Periodic::Unattended-Upgrade "1";" | sudo tee --append /etc/apt/apt.conf.d/20auto-upgrades
fi
add a comment
|
You have to use sudo to echo into /etc/apt/apt.conf.d/20auto-upgrades
if [[ ! -f /etc/apt/apt.conf.d/20auto-upgrades.bak ]]; then
sudo cp /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades.bak
sudo rm /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "30";
APT::Periodic::Unattended-Upgrade "1";" | sudo tee --append /etc/apt/apt.conf.d/20auto-upgrades
fi
add a comment
|
You have to use sudo to echo into /etc/apt/apt.conf.d/20auto-upgrades
if [[ ! -f /etc/apt/apt.conf.d/20auto-upgrades.bak ]]; then
sudo cp /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades.bak
sudo rm /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "30";
APT::Periodic::Unattended-Upgrade "1";" | sudo tee --append /etc/apt/apt.conf.d/20auto-upgrades
fi
You have to use sudo to echo into /etc/apt/apt.conf.d/20auto-upgrades
if [[ ! -f /etc/apt/apt.conf.d/20auto-upgrades.bak ]]; then
sudo cp /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/20auto-upgrades.bak
sudo rm /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "30";
APT::Periodic::Unattended-Upgrade "1";" | sudo tee --append /etc/apt/apt.conf.d/20auto-upgrades
fi
answered Apr 12 '17 at 8:14
ArturoArturo
2892 silver badges13 bronze badges
2892 silver badges13 bronze badges
add a comment
|
add a comment
|
dpkg-reconfigure -f noninteractive unattended-upgrades
add a comment
|
dpkg-reconfigure -f noninteractive unattended-upgrades
add a comment
|
dpkg-reconfigure -f noninteractive unattended-upgrades
dpkg-reconfigure -f noninteractive unattended-upgrades
answered Oct 1 at 9:03
aexlaexl
1031 silver badge4 bronze badges
1031 silver badge4 bronze badges
add a comment
|
add a comment
|
I would suggest to insert configuration parameters to configure unattended-upgrades.
sudo touch /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1"" >> /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Unattended-Upgrade "1" " >> /etc/apt/apt.conf.d/20auto-upgrades
Same way you can configure/add parameters according to your requirement in conf file /etc/apt/apt.conf.d/50unattended-upgrades
.
Don't forget to restart service to apply changes.
/etc/init.d/unattended-upgrades restart
add a comment
|
I would suggest to insert configuration parameters to configure unattended-upgrades.
sudo touch /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1"" >> /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Unattended-Upgrade "1" " >> /etc/apt/apt.conf.d/20auto-upgrades
Same way you can configure/add parameters according to your requirement in conf file /etc/apt/apt.conf.d/50unattended-upgrades
.
Don't forget to restart service to apply changes.
/etc/init.d/unattended-upgrades restart
add a comment
|
I would suggest to insert configuration parameters to configure unattended-upgrades.
sudo touch /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1"" >> /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Unattended-Upgrade "1" " >> /etc/apt/apt.conf.d/20auto-upgrades
Same way you can configure/add parameters according to your requirement in conf file /etc/apt/apt.conf.d/50unattended-upgrades
.
Don't forget to restart service to apply changes.
/etc/init.d/unattended-upgrades restart
I would suggest to insert configuration parameters to configure unattended-upgrades.
sudo touch /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Update-Package-Lists "1"" >> /etc/apt/apt.conf.d/20auto-upgrades
echo "APT::Periodic::Unattended-Upgrade "1" " >> /etc/apt/apt.conf.d/20auto-upgrades
Same way you can configure/add parameters according to your requirement in conf file /etc/apt/apt.conf.d/50unattended-upgrades
.
Don't forget to restart service to apply changes.
/etc/init.d/unattended-upgrades restart
edited Oct 1 at 10:58
answered Nov 17 '12 at 4:19
Ketan PatelKetan Patel
12.8k9 gold badges48 silver badges67 bronze badges
12.8k9 gold badges48 silver badges67 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f203337%2fenabling-unattended-upgrades-from-a-shell-script%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I've not used this tool before, but it looks like enabling it writes a 1 to the two lines in the file /etc/apt/apt.conf.d/20auto-upgrades. If you manually write that file will it work?
– mfisch
Nov 17 '12 at 3:43