From 3e235215b37decebebe99f97f70379a5f7a951ba Mon Sep 17 00:00:00 2001 From: heronhaye Date: Thu, 19 Mar 2020 20:40:37 -0400 Subject: [PATCH] Vagrant disk size (#23164) --- packaging/linux/tuxbot/Vagrantfile | 6 ++++++ packaging/linux/tuxbot/bot/tuxbot/tuxbot.go | 14 ++++++++++---- packaging/linux/tuxbot/cleanup | 7 +++++++ packaging/linux/tuxbot/provision_tuxbot_disk | 12 ++++++++++++ packaging/linux/tuxbot/provision_tuxbot_user | 1 + 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100755 packaging/linux/tuxbot/cleanup create mode 100755 packaging/linux/tuxbot/provision_tuxbot_disk diff --git a/packaging/linux/tuxbot/Vagrantfile b/packaging/linux/tuxbot/Vagrantfile index 179de3b26539..d3eb52479e68 100644 --- a/packaging/linux/tuxbot/Vagrantfile +++ b/packaging/linux/tuxbot/Vagrantfile @@ -1,10 +1,16 @@ Vagrant.configure("2") do |config| config.vm.box = "debian/buster64" + config.disksize.size = '50GB' config.vm.provider "virtualbox" do |vb| vb.memory = "24576" end + config.vm.provision "shell", path: "provision_tuxbot_disk", privileged: true config.vm.provision "shell", path: "provision_tuxbot_root", privileged: true config.vm.provision "shell", path: "provision_tuxbot_user", privileged: false + config.vm.provision "file", + source: "#{ENV['GOPATH']}/src/github.com/keybase/client/packaging/linux/tuxbot/cleanup", + destination: "~/cleanup", + run: "always" config.vm.provision "file", source: "#{ENV['GOPATH']}/src/github.com/keybase/client/packaging/linux/tuxbot/ssh_config", destination: "~/.ssh/config", diff --git a/packaging/linux/tuxbot/bot/tuxbot/tuxbot.go b/packaging/linux/tuxbot/bot/tuxbot/tuxbot.go index 12d184454191..c6457a3ec314 100644 --- a/packaging/linux/tuxbot/bot/tuxbot/tuxbot.go +++ b/packaging/linux/tuxbot/bot/tuxbot/tuxbot.go @@ -409,12 +409,18 @@ func (c Tuxbot) Dispatch(msg chat1.MsgSummary, args []string) (err error) { } return nil case "tuxjournal": - ret, _ := exec.Command("sudo", "journalctl", "--user-unit", "tuxbot", "-n", "50").CombinedOutput() - c.Debug("```%s```", ret) + ret, err := exec.Command("journalctl", "--user-unit", "tuxbot", "-n", "100").CombinedOutput() + c.Debug("RET: ```%s```, ERR: %s", ret, err) return nil case "journal": - ret, _ := exec.Command("sudo", "journalctl", "-n", "100").CombinedOutput() - c.Debug("```%s```", ret) + ret, err := exec.Command("journalctl", "-n", "100").CombinedOutput() + c.Debug("RET: ```%s```, ERR: %s", ret, err) + return nil + case "cleanup": + cleanupCmd := exec.Command("./cleanup") + cleanupCmd.Dir = filepath.Join(currentUser.HomeDir) + ret, err := cleanupCmd.CombinedOutput() + c.Debug("RET: ```%s```, ERR: %s", ret, err) return nil default: return fmt.Errorf("invalid command %s", command) diff --git a/packaging/linux/tuxbot/cleanup b/packaging/linux/tuxbot/cleanup new file mode 100755 index 000000000000..e62399d2d9bd --- /dev/null +++ b/packaging/linux/tuxbot/cleanup @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# builds +sudo rm -r /var/tmp/keybase* + +# docker +sudo docker system prune -af diff --git a/packaging/linux/tuxbot/provision_tuxbot_disk b/packaging/linux/tuxbot/provision_tuxbot_disk new file mode 100755 index 000000000000..85abcc3b125e --- /dev/null +++ b/packaging/linux/tuxbot/provision_tuxbot_disk @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euox pipefail + +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt install -yq parted + +swapoff -a +parted --script /dev/sda rm 2 +# https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203 +echo -e "yes\n100%" | sudo parted /dev/sda ---pretend-input-tty resizepart 1 +resize2fs /dev/sda1 diff --git a/packaging/linux/tuxbot/provision_tuxbot_user b/packaging/linux/tuxbot/provision_tuxbot_user index e3c712e5cb0e..ce808359fdcb 100755 --- a/packaging/linux/tuxbot/provision_tuxbot_user +++ b/packaging/linux/tuxbot/provision_tuxbot_user @@ -10,6 +10,7 @@ git clone https://github.com/keybase/client.git "$HOME/go/src/github.com/keybase ( # install deps cd "$TUXBOTD/bot" + git checkout master go mod tidy ) systemctl --user link "$TUXBOTD/tuxbot.service"