Then sudo nano /etc/apt//50unattended-upgrades to modify the config file with at least the following lines to uncomment. I have to install unattended-upgrades with sudo apt install unattended-upgrades Unattended-Upgrade::Remove-Unused-Dependency "true"Īs a note, this is the way I have set up unattended-upgrades. # You might want to set this in that other file to avoid # This may be set in /etc/apt//50unattended-upgrades # This effectively does the 'apt upgrade' # (requires package 'unattended-upgrade') # This is similar to `apt upgrade` depending on your configuration Something like this might work (these values are all 0-disabled by default): # /etc/apt//10periodic For example, if the autoclean would uninstall libc6 or linux-* this script will avoid that. I think this solution is even better than making your own services because edge cases and stability which could break your system have already been addressed by the authors of apt itself. etc/apt//50unattended-upgrades and /usr/lib/apt/ for instructions on how to configure it to do what you want. Then use sudo systemctl enable -now rvice to run it and arm it for the next boots.Īpt (at least in Debian's distribution) already has something similar to the service solution: rvice and rvice which are triggered once per day and do some updating for you. A simple solution might be: #/etc/systemd/system/rvice However, the best answer (especially if you prefer non-interactivity) is to run this as a service. This will run apt update/upgrade and then autoremove. For example, this could work in /usr/share/polkit-1/actions/: You'll need to lookup polkit rules for that. There are also ways to allow a user to do something without the interactive prompt. It will dim your gnome session and prompt for a password instead of using a terminal. pkexec is part of polkit and is the GUI-version of sudo. The next easiest solution could be to replace sudo with pkexec to work with your script for use with the desktop entry. However, I'd recommend against this because scripts depending on a NOPASSWD option are not the best. That's actually good because it stops someone from making their own malicious program called apt and putting it in a directory in $PATH. This will work because you allowed the user to run /usr/bin/apt but not apt. The most basic thing you can do is prefix /usr/bin to your script: #!/bin/bash Why the Gnome Tweak method prompt me for a password and how to solve this issue ?.Why the crontab method does not work ? (I already have started crontab service to be sure). Then I don't understand why this happens (is Gnome Tweaks running under another user, etc.). This is where my second problem comes in: the script starts at startup, but asks me for a password. Then, with Gnome Tweaks, I add the file sktop as an application at startup 2nd try to run the script at startup with Gnome Tweaks and a desktop file :Īs an alternative I try to make an sktop file in /usr/share/applications in which a double-click starts the script: Īfter testing, double-clicking on this file runs the script without asking for a password To run the script at each startup, I modify crontab -u user -e (I also tested directly with crontab -e): sh '/home/user/Documents/update.sh'īut on each reboot: no script starts. 1st try to run the script at startup with crontab : Then I gave the user user the rights with visudo so as not to ask for the password user ALL=(ALL:ALL) NOPASSWD:/home/user/Documents/update.sh, /usr/bin/apt update, /usr/bin/apt upgrade, /usr/bin/apt autoclean, /usr/bin/apt autoremoveĪfter testing by running the command on the terminal sh '/home/user/Documents/update.sh', the script works without asking me for a password. I then make the script executable: chmod a+x /home/user/Documents/update.sh So I wrote a simple script /home/user/Documents/update.sh like this: #!/bin/bash It's a low-end computer intended for users with little computer experience and I want to keep it up to date with a script that do not prompt users for a password.įollowing the advice of several topics (like here):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |