|
| 1 | + <h1><span>Wirking with packages and pkg(7) in jail via CBSD </span></h1> |
| 2 | + |
| 3 | + <h2><a name="pkd_cmd">Command: pkg</a></h2> |
| 4 | + <div class="block"> |
| 5 | + <pre class="brush:bash;ruler:true;"> |
| 6 | + % cbsd pkg |
| 7 | + </pre> |
| 8 | + <p><strong>Description</strong>:</p> |
| 9 | + <p><strong>cbsd pkg</strong> - is wrapper around standart FreeBSD <a href="http://man.freebsd.org/pkg/7" target="_blank">pkg(7)</a> tools to use <strong>jname</strong> argument for more comfort work with the jail from the master host</p> |
| 10 | + <p>Via <strong>mode=</strong> argument indicating a needet action. Values can be:</p> |
| 11 | + <ul> |
| 12 | + <li><strong>add, install</strong> - to install packages</li> |
| 13 | + <li><strong>remove</strong> - to remove packages</li> |
| 14 | + <li><strong>bootstrap</strong> - init pkg (normally done in the jail one times on creating)</li> |
| 15 | + <li><strong>info, query</strong> - execute queries <em>info</em> or <em>query</em> with the same syntax pkg</li> |
| 16 | + <li><strong>update</strong> - execute pkg update</li> |
| 17 | + <li><strong>upgrade</strong> - execute upgrade</li> |
| 18 | + <li><strong>clean</strong> - execute clean to purge pkg cache</li> |
| 19 | + </ul> |
| 20 | + <p>For some commands (clean, update, upgrade) it is permissible jname= to specify as mask for performing the operation simultaneously in several jails</p> |
| 21 | + <p>Keep in mind that must first be specified parameters <strong>mode</strong> and <strong>jname</strong>. All that comes after - not analyzed and treated <a href="http://man.freebsd.org/pkg/7" target="_blank">pkg(7)</a> as is.</p> |
| 22 | + <p>In addition, please note that all operations are performed with the set environment variables <strong>ASSUME_ALWAYS_YES=yes</strong> and <strong>IGNORE_OSVERSION=yes</strong> to suppress the interactivity that basically, you need to work in automated scripts. If for some reason this does not work for you, use <a href="/<!--#echo var="lang" -->/<!--#echo var="version" -->/wf_jexec_ssi.html">cbsd rexe</a> to work with pkg directly.</p> |
| 23 | + <p><strong>Example1:</strong> Update pkg index files inside ALL containers:</p> |
| 24 | + <pre class="brush:bash;ruler:true;"> |
| 25 | + % cbsd pkg mode=update jname='*' |
| 26 | + </pre> |
| 27 | + <p><strong>Example2:</strong> Update ALL packages inside containers, whose name starts with redis*:</p> |
| 28 | + <pre class="brush:bash;ruler:true;"> |
| 29 | + % cbsd pkg mode=upgrade jname='redis*' |
| 30 | + </pre> |
| 31 | + <p><strong>Example3:</strong> Clear pkg cache in ALL containers:</p> |
| 32 | + <pre class="brush:bash;ruler:true;"> |
| 33 | + % cbsd pkg mode=clean jname='*' |
| 34 | + </pre> |
| 35 | + <p><strong>Example4:</strong> Get installed packages for box1 and for all jails with jname mask 'jail*' (in <strong>CBSD 11.2.1+</strong>):</p> |
| 36 | + <pre class="brush:bash;ruler:true;"> |
| 37 | + % cbsd pkg mode=query jname=box1 %o |
| 38 | + % cbsd pkg mode=query jname='jail*' %o |
| 39 | + </pre> |
| 40 | + <p><strong>Example5:</strong> Install <strong>bash, mc, wget</strong> in mytest1 jail and <strong>nginx-devel,mysql57-server,postgresql96-server,mc</strong> for all jails with jname mask 'jail*' (in <strong>CBSD 11.2.1+</strong>:</p> |
| 41 | + <pre class="brush:bash;ruler:true;"> |
| 42 | + % cbsd pkg mode=install jname=mytest1 bash mc wget |
| 43 | + % cbsd pkg jname='jail*' mode=install nginx-devel mysql57-server postgresql96-server mc |
| 44 | + </pre> |
| 45 | + <p>or that much better (in order to avoid the same name in different categories) indicate origin package, not the name:</p> |
| 46 | + <pre class="brush:bash;ruler:true;"> |
| 47 | + % cbsd pkg mode=install jname=mytest1 shells/bash ftp/wget misc/mc |
| 48 | + </pre> |
| 49 | + <p><strong>Example6:</strong> Upgrade mc package in jail1:</p> |
| 50 | + <pre class="brush:bash;ruler:true;"> |
| 51 | + % cbsd pkg mode=upgrade jname=jail1 mc |
| 52 | + </pre> |
| 53 | + <p><strong>Example7:</strong> Remove wget and lsof packages in box1 and mc from all jails with jname mask 'jail*' (in <strong>CBSD 11.2.1+</strong>:</p> |
| 54 | + <pre class="brush:bash;ruler:true;"> |
| 55 | + % cbsd pkg mode=remove jname=box1 wget lsof |
| 56 | + % cbsd pkg jname='jail*' mode=remove mc |
| 57 | + </pre> |
| 58 | + </div> |
0 commit comments