Skip to content

Instantly share code, notes, and snippets.

Avatar

Scott Moser smoser

  • Cisco
  • US
View GitHub Profile
@smoser
smoser / README.md
Last active Oct 12, 2020
swtpm / libtpms notes
View README.md

swtpm notes

Info on how to build/use swtpm and libtpms. Pretty good doc at swtpm wiki.

Debian/Ubuntu

libtpms and swtpm seem to be working their way into debian/ubuntu.

@smoser
smoser / README.md
Created Sep 23, 2020
git branch cleanup tool, for deleting local and remote branches
View README.md

git-branch-cleanup

git-branch-cleanup basically just allows me to do housekeeping more easily on my many branches.

@smoser
smoser / README.md
Created Aug 27, 2020
golang (go) cmd.ExtraFiles example
View README.md

This is an example of using cmd.ExtraFiles in golang with a os.Pipe()

There are 2 things that might be a bit tricky:

  • the order of closing the read and write side of the pipe. I got this right by reading the implementation of cmd.StderrPipe.
  • the number of the file descriptor for the child. I'm not sure of a good way to cleanly determine what that is. Golang cmd processes do not inherit all open filehandles, so you can't just use pipeWrite.Fd().

Ultimately, we did this because we were working with tssnvread which is possibly the worst user interface I've ever seen. We wanted to read the contents without writing to a file on the filesystem. To do so, we were able to tell it to write to /proc/self/fd/.

@smoser
smoser / README.md
Last active Jul 23, 2020
proxy setup using tiny proxy
View README.md

proxy setup using tiny proxy and proxy command

set up tinyproxy and /etc/environment for system wide proxy.

By default, this only reports how you can set this up. No changes to the system will be made unless the first argument is 'update' or UPDATE=1 is found in the environment.

No root access is required for dry-run.

The values configured at the top of the script are for an internal

@smoser
smoser / README.md
Last active Jul 9, 2020
bootstrap (bs) run (vcs-run)
View README.md

Docker ubuntu containers are pretty useless by themselves. The expectation is that the user will create a DockerFile and build their own image and push that image somewhere and maintain it.

In 2013 I authored vcs-run as part of cloud-utils. It is installed by default in ubuntu server images, but not in the docker images. :-(. The idea of vcs-run is that you can just invoke something like:

vcs-run https://your.git.server/repo.git bootstrap your-args-here

vcs-run would handle:

  • installing git
  • cloning repo
  • change dir to repo
@smoser
smoser / README.md
Last active Jul 22, 2020
codimd-index create an index for codimd
View README.md

codimd-index: maintain a global index for codimd pages.

We have a team codimd and it is wonderful. We have CMD_ALLOW_FREEURL=true so that users can create alias'd (named) pages.

Users can't see each others pages though, unless they know to look for them (codimd/#975).

This is just a "manually updated" script to generate a simple index page. It'd be wonderful if codimd/#103 was fixed, then we could generate a table and let user sort.

To run it, you need pyscopg2 (apt install python3-psycopg2).

Then:

@smoser
smoser / README.md
Created Jun 12, 2020
demo of yaml anchors and yaml-dump script.
View README.md

yaml anchors demo

yaml anchors are:

  • useful
  • confusing
  • hard to google for

yaml can be quite hard to read and see if it is valid.

I use 'yaml-dump' script here to just load a file and dump it as json to more easily see what it loads as.

@smoser
smoser / README.md
Last active Jul 17, 2020
build-upstream-pkg build a package from upstream source
View README.md

build-upstream-pkg

Usage: build-upstream-pkg [ options ] <<ARGUMENTS>>

   build-upstream-pkg <upstream-commitish> <packaging-commitish>

   options:
      --version  VERSION    make the upstream version VERSION
                            default is to use git-describe
      --output   DIR        put created files in DIR
@smoser
smoser / README.md
Last active Jun 3, 2020
bash version of lxc-usernsexec
View README.md

bash version of lxc-usernsexec

I was in need of something like lxc-usernsexec but ran into some issues lxc/#3420 using it (possibly user error). I put together a test case testing what I thought were valid invocations of lxc-usernsexec. That is here as test-usernsexec.

I looked at the implementation and came up with the bash version here ias 'usernsexec'. My version passes the test case.

My version doesn't get tty's for the executed command.

@smoser
smoser / README.md
Created May 18, 2020
ubuntu email setup through dreamhost relay with msmtp
View README.md

usage of msmtp for email relay through dreamhost

I just needed the sendmail cli interface to work for things like bts or the occasional sending of an email.

msmtp seems like a good solution.

Heres what I did to get it functional

  • install mtsmtp-mta
You can’t perform that action at this time.