v0.36a: Add upgrade command

This commit is contained in:
yo
2023-07-23 15:13:16 +02:00
parent 881965e257
commit 310564b4af
4 changed files with 257 additions and 111 deletions

View File

@ -15,7 +15,7 @@ import (
)
const (
gVersion = "0.35"
gVersion = "0.36a"
// TODO : Get from $jail_zpool/defaults.json
MIN_DYN_DEVFS_RULESET = 1000
@ -55,6 +55,7 @@ var (
gFetchRelease string
gFetchIntoDS string
gFetchFrom string
gUpgradeRelease string
gMdevfs sync.Mutex
@ -139,9 +140,7 @@ ex: gocage list srv-db srv-web`,
WriteConfigToDisk("", false, false)
},
}
restartCmd = &cobra.Command{
Use: "restart",
Short: "restart jail",
@ -153,7 +152,7 @@ ex: gocage list srv-db srv-web`,
WriteConfigToDisk("", false, false)
},
}
shellCmd = &cobra.Command {
Use: "console",
Short: "Execute shell on jail",
@ -163,7 +162,7 @@ ex: gocage list srv-db srv-web`,
ShellJail(args)
},
}
setCmd = &cobra.Command{
Use: "set",
Short: "Set a jail property",
@ -291,7 +290,7 @@ You can specify multiple datastores.`,
ListDatastores(args, true)
},
}
fetchCmd = &cobra.Command{
Use: "fetch",
Short: "Fetch FreeBSD release to local datastore",
@ -302,18 +301,27 @@ You can specify multiple datastores.`,
} else {
extractRelease(gFetchRelease, gFetchIntoDS)
}
},
},
}
UpdateCmd = &cobra.Command{
updateCmd = &cobra.Command{
Use: "update",
Short: "Update FreeBSD release",
Run: func(cmd *cobra.Command, args []string) {
ListJails(args, false)
UpdateJail(args)
},
Short: "Update FreeBSD release",
Run: func(cmd *cobra.Command, args []string) {
ListJails(args, false)
UpdateJail(args)
},
}
upgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "Upgrade FreeBSD release",
Run: func(cmd *cobra.Command, args []string) {
ListJails(args, false)
UpgradeJail(args)
},
}
testCmd = &cobra.Command{
Use: "test",
Short: "temporary command to test some code snippet",
@ -373,6 +381,8 @@ func init() {
fetchCmd.MarkFlagRequired("release")
fetchCmd.MarkFlagRequired("datastore")
upgradeCmd.Flags().StringVarP(&gUpgradeRelease, "release", "r", "", "Release to upgrade to (e.g.: \"13.1-RELEASE\"")
upgradeCmd.MarkFlagRequired("release")
// Now declare commands
rootCmd.AddCommand(versionCmd)
@ -389,7 +399,8 @@ func init() {
rootCmd.AddCommand(migrateCmd)
rootCmd.AddCommand(datastoreCmd)
rootCmd.AddCommand(fetchCmd)
rootCmd.AddCommand(UpdateCmd)
rootCmd.AddCommand(updateCmd)
rootCmd.AddCommand(upgradeCmd)
rootCmd.AddCommand(testCmd)
@ -522,6 +533,8 @@ func WriteConfigToDisk(jailName string, changeauto bool, forceWrite bool) {
//fmt.Printf("DEBUG: Will write config to disk, with content:\n")
//fmt.Printf(string(marshaled))
fmt.Printf("DEBUG: Will write config to disk, Config.Release=%s\n", jc.Release)
fmt.Printf("DEBUG: Will write config to disk, Config.Last_started=%s\n", jc.Last_started)
if os.WriteFile(j.ConfigPath, []byte(marshaled), 0644); err != nil {
fmt.Printf("Error writing config file %s: %v\n", j.ConfigPath, err)