pkg unattended install

Remington

Well-Known Member

Reaction score: 149
Messages: 499

How can I get this to install without asking a prompt or at least accept something like this at the commandline echo 'y' | pkg?
Code:
# pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]:
 
OP
OP
Remington

Remington

Well-Known Member

Reaction score: 149
Messages: 499

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

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,409
Messages: 29,985

From pkg.conf(5):
Code:
     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

Beastie's Twin

Reaction score: 1,805
Messages: 6,318

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

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,409
Messages: 29,985

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.

Code:
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.
 
OP
OP
Remington

Remington

Well-Known Member

Reaction score: 149
Messages: 499

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.
 

dave

Well-Known Member

Reaction score: 24
Messages: 421

Re: [SOLVED] pkg unattended install

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