Search code examples
linuxshellarchlinuxmanjarokonsole

How can I pre-provide sudo access to pacaur in a shell script?


I've got a shell script which is supposed to install some packages from the Arch User Repository. The shell script is as follows:

#!/bin/sh

pacaur -S google-chrome --noconfirm # install google-chrome

The problem is, if I run this script using sudo sh script.sh, it'll just return: "you cannot perform this operation as root". If I run it without sudo, it'll ask for sudo later on when installing.

My question is, how can I avoid it asking me. I'd like this script to take care of installing all my packages just as is, without requiring me to actually give access manually. Would there be a way?


Solution

  • If you run sudo -v before calling the pacaur, this will ask you for your credentials and cache them for the next 15 minutes. You don't need to call sudo with pacaur anymore. As long as pacaur finishes running within the next 15 minutes, it will not have to ask for credentials again.