From 4ddb0aa7564ac3886d73118aa5a9b54956cda6be Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 15 Oct 2025 18:41:01 -0500 Subject: start a 'droplet' subcommand --- argv.go | 16 ++++++++++++---- doDroplet.go | 19 +++++++++++++++++++ main.go | 4 ++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 doDroplet.go diff --git a/argv.go b/argv.go index e9d44f4..7cfe049 100644 --- a/argv.go +++ b/argv.go @@ -24,10 +24,11 @@ type args struct { Git *GitCmd `arg:"subcommand:git" help:"git stuff"` Build *BuildCmd `arg:"subcommand:build" help:"build and install things"` ListPkgs *EmptyCmd `arg:"subcommand:list" help:"list all the packages on mirrors.wit.com"` - Clone *CloneCmd `arg:"subcommand:clone" help:"go-clone from a gowebd repomap"` + Clone *CloneCmd `arg:"subcommand:go-clone" help:"go-clone from a gowebd repomap"` Linux *LinuxCmd `arg:"subcommand:linux" help:"helpful linux things"` Zoo *EmptyCmd `arg:"subcommand:zoo" help:"WIT Private Cloud info"` - PB *ProtoCmd `arg:"subcommand:pb" help:"WIT Private Cloud info"` + PB *ProtoCmd `arg:"subcommand:pb" help:"example .pb files"` + Droplet *DropletCmd `arg:"subcommand:drooplet" help:"do things on virtual machines"` Upgrade *UpgradeCmd `arg:"subcommand:upgrade" help:"apt upgrade packages installed from mirrors.wit.com"` Publish *PublishCmd `arg:"subcommand:publish" help:"publish packages"` RepoMap string `arg:"--repomap" help:"location of the repomap"` @@ -51,6 +52,10 @@ type ProtoCmd struct { Identify string `arg:"--identify" help:"identify a .pb file"` } +type DropletCmd struct { + Trim *EmptyCmd `arg:"subcommand:trim" help:"clean out stuff and power off vm"` +} + type LinuxCmd struct { Rdate *EmptyCmd `arg:"subcommand:rdate" help:"rdate: check the time from the network"` } @@ -144,7 +149,10 @@ func (args) ArgvGui() error { } func (a args) DoAutoComplete(pb *prep.Auto) { - base := []string{"--version", "build", "upgrade", "git", "publish", "--force", "--all", "pb", "linux"} + base := []string{"build", "upgrade", "git", "publish", "pb", "linux", "droplet"} + base = append(base, "--version", "--force", "--all") + + // add these only if installed if _, err := fhelp.CheckCmd("zood"); err == nil { base = append(base, "zoo") } @@ -152,7 +160,7 @@ func (a args) DoAutoComplete(pb *prep.Auto) { base = append(base, "forge") } if _, err := fhelp.CheckCmd("go-clone"); err == nil { - base = append(base, "clone") + base = append(base, "go-clone") } if areSuperuser() { base = append(base, "upgrade") diff --git a/doDroplet.go b/doDroplet.go new file mode 100644 index 0000000..eaa0fcc --- /dev/null +++ b/doDroplet.go @@ -0,0 +1,19 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "go.wit.com/log" +) + +func doDroplet() (string, error) { + log.Info("apt clean") + log.Info("rm -rf /var/lib/apt/lists/*") + log.Info("rm -rf /var/log/journal/*") + log.Info("fstrim -a -v") + log.Info("poweroff") + log.Info("qemu-img convert -p -O qcow2 sid8gb.lab.wit.org.qcow2 new.qcow2") + + return "todo: make this", nil +} diff --git a/main.go b/main.go index 6266cc9..fcec3a3 100644 --- a/main.go +++ b/main.go @@ -100,6 +100,10 @@ func main() { doUpgrade() } + if argv.Droplet != nil { + s, err = doDroplet() + } + if argv.Publish != nil { if err := doPublish(); err != nil { me.sh.BadExit("doPublish failed", err) -- cgit v1.2.3