# pkg unattended install



## Remington (Dec 6, 2012)

How can I get this to install without asking a prompt or at least accept something like this at the commandline *echo 'y' | pkg*?

```
# pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]:
```


----------



## kpa (Dec 6, 2012)

Install the ports-mgmt/pkg port, it shouldn't ask any questions since there are no options for it.


----------



## Remington (Dec 6, 2012)

FreeBSD 9.1 already has pkg available ready to install without the ports.  Just need to find a way to bypass the confirmation question.


----------



## SirDice (Dec 7, 2012)

From pkg.conf(5):

```
ASSUME_ALWAYS_YES: boolean  When this option is enabled pkg(1) will auto-
                                 matically assume "yes" to all questions which
                                 require user confirmation before doing any-
                                 thing, as if it the -y flag was specified.
                                 By default this option is disabled.
```

Reading that -y should also work on the command line. Why this isn't mentioned in the pkg(8) man page is beyond me.

NB. The FreeBSD man server seems to have a problem with it. The man pages should exist on your local system though.


----------



## kpa (Dec 7, 2012)

Does that work? The pkg in question is the wrapper used for bootstrapping ports-mgmt/pkg and I'm not sure if that reads pkg.conf yet or accepts the -y flag.


----------



## SirDice (Dec 7, 2012)

Not sure if that would work for the bootstrap. But I think you can just install the port, that certainly doesn't ask for an acknowledgement. 

You could also try the same procedure for < 9.1 systems to install pkg.


```
fetch http://yoururl/90amd64-default/Latest/pkg.txz
tar xf ./pkg.txz -s ",/.*/,,g" "*/pkg-static"
./pkg-static add ./pkg.txz
```

I'm almost certain pkg-static will accept the -y flag.


----------



## Remington (Dec 7, 2012)

I tried the `pkg -y` but it doesn't work.  It still asked for confirmation.  I guess I'll do it from the ports in my automatic script.


----------



## lasizoillo (Jan 6, 2014)

*[SOLVED] pkg unattended install*

I've see the keyn in this post http://dan.langille.org/2013/12/06/...freebsd-unattended-and-without-answering-yes/


```
env ASSUME_ALWAYS_YES=YES pkg bootstrap
```


----------



## dave (Jan 31, 2014)

*Re: [SOLVED] pkg unattended install*

Is there a way to test if pkg has been bootstrapped yet?  Without running pkg?


----------



## SirDice (Jan 31, 2014)

Look at the -N option in pkg(8).


----------



## dave (Jan 31, 2014)

SirDice said:
			
		

> Look at the -N option in pkg(8).



Yes, yes of course, thanks!


----------



## tux2bsd (Apr 2, 2021)

lasizoillo said:


> ```
> env ASSUME_ALWAYS_YES=YES pkg bootstrap
> ```


This sort of thing should be easier to find.  Thanks.


----------

