Compare commits
3 Commits
259c3ee1e0
...
5b2f3a2f0a
Author | SHA1 | Date | |
---|---|---|---|
5b2f3a2f0a | |||
2df22b10b1 | |||
c19e40b139 |
@ -18,8 +18,7 @@ Create jails
|
||||
------------
|
||||
For now, we can't pass config at creation time. We have to define config after creation:
|
||||
<pre><code>
|
||||
gocage create jail1 -r 13.2-RELEASE
|
||||
gocage set Config.Ip4_addr="vnet0|192.168.1.91/24" Config.Vnet=1 jail1
|
||||
gocage create jail1 -r 13.2-RELEASE -p "Config.Ip4_addr='vnet0|192.168.1.91/24',Config.Ip6=none,Config.Boot=1"
|
||||
</code></pre>
|
||||
|
||||
Create basejail (jail based on a release, system will be nullfs read-only mounted from the release directory):
|
||||
@ -30,7 +29,6 @@ gocage create -b -r 14.0-RELEASE basejail1
|
||||
|
||||
List jails
|
||||
----------
|
||||
Nothing fancy, just use
|
||||
`gocage list`
|
||||
|
||||
### Specify fields to display
|
||||
@ -233,7 +231,7 @@ Fetch
|
||||
Files can be fetched from custom repository, or from local directory with "from" option.
|
||||
For example if you destroyed releases/12.3-RELEASE and still have the downloaded files in /iocage/download/12.3-RELEASE:
|
||||
<pre><code>
|
||||
gocage fetch -r 12.3 -o iocage --from file:/iocage/download
|
||||
gocage fetch -r 12.3 -d iocage -f file:/iocage/download
|
||||
</pre></code>
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ func CreateJail(args []string) {
|
||||
|
||||
var ds *Datastore
|
||||
if len(gCreateArgs.Datastore) > 0 {
|
||||
fmt.Printf("DEBUG: Use %s datastore\n", gCreateArgs.Datastore)
|
||||
log.Debugf("Use %s datastore\n", gCreateArgs.Datastore)
|
||||
ds, err = getDatastoreFromArray(gCreateArgs.Datastore, gDatastores)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR Getting datastore: %s\n", gCreateArgs.Datastore, err.Error())
|
||||
@ -272,7 +272,6 @@ func CreateJail(args []string) {
|
||||
j.Config.Host_hostname = jname
|
||||
j.Config.Host_hostuuid = jname
|
||||
j.Config.Jailtype = "jail"
|
||||
|
||||
j.WriteConfigToDisk(false)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@ -285,5 +284,17 @@ func CreateJail(args []string) {
|
||||
defer fstabHandle.Close()
|
||||
fmt.Printf(" > Jail created!\n")
|
||||
}
|
||||
|
||||
var cmdline []string
|
||||
for _, props := range strings.Split(gCreateArgs.Properties, ",") {
|
||||
cmdline = append(cmdline, props)
|
||||
}
|
||||
|
||||
// Reload jail list so SetJailProperties will see it
|
||||
ListJails(nil, false)
|
||||
|
||||
cmdline = append(cmdline, jname)
|
||||
log.Debugf("cmdline: \"%v\"", cmdline)
|
||||
SetJailProperties(cmdline)
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ type createArgs struct {
|
||||
BaseJail bool
|
||||
Datastore string
|
||||
JailType string
|
||||
Properties string
|
||||
}
|
||||
|
||||
var (
|
||||
@ -379,6 +380,7 @@ func init() {
|
||||
initCmd.Flags().StringVarP(&gZPool, "pool", "p", "", "ZFS pool to create datastore on")
|
||||
initCmd.Flags().StringVarP(&gBridge, "bridge", "b", "", "bridge to create for jails networking")
|
||||
initCmd.Flags().StringVarP(&gInterface, "interface", "i", "", "interface to add as bridge member. This should be your main interface")
|
||||
initCmd.MarkFlagRequired("bridge")
|
||||
initCmd.MarkFlagsRequiredTogether("bridge", "interface")
|
||||
|
||||
// We reuse these flags in "gocage snapshot list myjail" and 'gocage datastore list" commands
|
||||
@ -412,8 +414,8 @@ func init() {
|
||||
migrateCmd.MarkFlagRequired("datastore")
|
||||
|
||||
fetchCmd.Flags().StringVarP(&gFetchRelease, "release", "r", "", "Release to fetch (e.g.: \"13.1-RELEASE\"")
|
||||
fetchCmd.Flags().StringVarP(&gFetchIntoDS, "datastore", "o", "", "Datastore release will be saved to")
|
||||
fetchCmd.Flags().StringVarP(&gFetchFrom, "from", "d", "", "Repository to download from. Should contain XY.Z-RELEASE. File protocol supported")
|
||||
fetchCmd.Flags().StringVarP(&gFetchIntoDS, "datastore", "d", "", "Datastore release will be saved to")
|
||||
fetchCmd.Flags().StringVarP(&gFetchFrom, "from", "f", "", "Repository to download from. Should contain XY.Z-RELEASE. File protocol supported")
|
||||
fetchCmd.MarkFlagRequired("release")
|
||||
fetchCmd.MarkFlagRequired("datastore")
|
||||
|
||||
@ -423,6 +425,7 @@ func init() {
|
||||
createCmd.Flags().StringVarP(&gCreateArgs.Release, "release", "r", "", "Release for the jail (e.g.: \"13.1-RELEASE\"")
|
||||
createCmd.Flags().BoolVarP(&gCreateArgs.BaseJail, "basejail", "b", false, "Basejail. This will create a jail mounted read only from a release, so every up(date|grade) made to this release will immediately propagate to new jail.\n")
|
||||
createCmd.Flags().StringVarP(&gCreateArgs.Datastore, "datastore", "d", "", "Datastore to create the jail on. Defaults to first declared in config.")
|
||||
createCmd.Flags().StringVarP(&gCreateArgs.Properties, "configuration", "p", "", "Configuration properties with format k1=v1,k2=v2 (Ex: \"Config.Ip4_addr='vnet0|192.168.1.2',Config.Ip6=none\")")
|
||||
|
||||
// Now declare commands
|
||||
rootCmd.AddCommand(initCmd)
|
||||
@ -443,7 +446,6 @@ func init() {
|
||||
rootCmd.AddCommand(updateCmd)
|
||||
rootCmd.AddCommand(upgradeCmd)
|
||||
rootCmd.AddCommand(createCmd)
|
||||
rootCmd.AddCommand(apiCmd)
|
||||
rootCmd.AddCommand(testCmd)
|
||||
|
||||
snapshotCmd.AddCommand(snapshotListCmd)
|
||||
|
27
cmd/utils.go
27
cmd/utils.go
@ -228,7 +228,7 @@ CreateBootEnv no
|
||||
"type": "jail",
|
||||
"used": "readonly",
|
||||
"vmemoryuse": "off",
|
||||
"vnet": 0,
|
||||
"vnet": 1,
|
||||
"vnet0_mac": "none",
|
||||
"vnet1_mac": "none",
|
||||
"vnet2_mac": "none",
|
||||
@ -751,6 +751,30 @@ func executeScript(script string) (string, error) {
|
||||
return string(out), err
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Network related operations
|
||||
*
|
||||
*****************************************************************************/
|
||||
func getBridgeMembers(bridge string) ([]string, error) {
|
||||
var members []string
|
||||
cmd := fmt.Sprintf("/sbin/ifconfig %s", bridge)
|
||||
out, err := executeCommand(cmd)
|
||||
if err != nil {
|
||||
return members, errors.New(fmt.Sprintf("%v; command returned \"%s\"", err, out))
|
||||
}
|
||||
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
if strings.HasPrefix(strings.TrimLeft(line, " \t"), "member:") {
|
||||
m := strings.Split(strings.TrimLeft(strings.Split(line, ":")[1], " "), " ")[0]
|
||||
log.Debugf("%s is member of %s\n", m, bridge)
|
||||
members = append(members, m)
|
||||
}
|
||||
}
|
||||
return members, nil
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* ZFS datasets/pools operations
|
||||
@ -1033,6 +1057,7 @@ func addRcKeyValue(rcconfpath string, key string, value string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Parse an fstab file, returning an array of Mount
|
||||
*****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user