Skip to content

Instantly share code, notes, and snippets.

@smoser
smoser / rsa2azure
Created June 26, 2012 17:01
rsa2azure: convert ssh key to public key suitable for azure
#!/bin/sh
# vi: ts=4 noexpandtab
# rsa2azure
Usage() {
cat <<EOF
Usage: ${0##*/} [options] [private-key]
convert private-key in ssh private key format to the format
needed by windows azure as described at
http://utlemming.azurewebsites.net/?p=91
@smoser
smoser / debconf-get-selections
Created August 9, 2012 02:20
debconf-get-selections
#!/usr/bin/perl
#
# The goal of this is to read a bunch of variables from debconf
# To implement a "late_command_runparts" like function.
# Ie, you would populate the preseed with content like:
# late-command-d late-command/90-fix-hosts string content-for-fix-hosts
# late-command-d late-command/10-install-my-packages string payload
#
# Then, in the actual late_command, we would suck out all those
# values, and run them by doing something like this:
@smoser
smoser / README.txt
Created August 17, 2012 21:01
boot cloud images with libvirt
$ disk_dist_imgz=/archive/mirrors/uec/releases/precise/release-20120728/ubuntu-12.04-server-cloudimg-amd64-disk1.img
$ disk_dist_img=disk.img.dist
$ disk=disk.img
$ qemu-img convert "${disk_dist_imgz}" "${disk_dist_img}"
$ qemu-img create -f qcow2 -b "${disk_dist_img}" "$disk"
$ cat my-user-data
#cloud-config
password: passw0rd
chpasswd: { expire: False }
ssh_pwauth: True
@smoser
smoser / gist:4756561
Last active November 8, 2023 15:20
boot a cloud image in kvm
## Install a necessary packages
$ sudo apt-get install kvm cloud-utils genisoimage
## URL to most recent cloud image of 12.04
$ img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release"
$ img_url="${img_url}/ubuntu-12.04-server-cloudimg-amd64-disk1.img"
## download the image
$ wget $img_url -O disk.img.dist
## Create a file with some user-data in it
@smoser
smoser / apt-go-fast
Last active February 13, 2017 16:17
user-data for setting up devstack
#!/bin/sh
#
# copied from https://gist.github.com/smoser/5823699
#
set -e
[ -e "/usr/bin/apt-get.distrib" ] ||
sudo dpkg-divert --local --rename --add /usr/bin/apt-get
sudo tee /usr/bin/apt-get >/dev/null <<"EOF"
@smoser
smoser / get-brother-drivers.sh
Created February 26, 2013 17:01
brother printer driver downloader
#!/bin/bash
#
# This scraps the $URL below
# and downloads all the .deb (and .ppd) files
#
# originally plan was to somehow integrate it with brother-cups-wraper-extra
# for now, it downloads ~ 230M of data.
URL="http://welcome.solutions.brother.com/bsc/public_s/id/linux/en/download_prn.html"
TEMP_D=$(mktemp -d "${TMPDIR:-/tmp}/${0##*/}.XXXXXX")
@smoser
smoser / img-convert
Last active April 2, 2020 13:08
Utility for converting a disk image in raw format or some format qcow understands into VHD format.
#!/bin/bash
VERBOSITY=0
TEMP_D=""
FORMATS=(
qcow2
qcow2-compressed
raw
azure
azure-dynamic
azure-fixed
@smoser
smoser / README.md
Last active January 19, 2016 19:02
test 'apt-get update' for a given "mode" release and mirror written to get reasonable information for bug 1177432 (http://padl.lv/1177432)

Summary

These tools are used to show collect information on performance and cost of a 'apt-get update'.

You need to have chdist from devscripts package to use it.

The results shown here are on a cloud with a local mirror, so latency is low and bandwidth high.

Usage

@smoser
smoser / example-results
Last active December 18, 2015 03:59
demonstrate time to clone a ephemeral disk image
=== size=10G LABEL=ephemeral0 FSTYPE=ext3 ===
truncate real: 0m0.053s user: 0m0.000s sys: 0m0.000s
mkfs.ext3 real: 0m8.295s user: 0m0.008s sys: 0m0.584s
cp working o real: 0m0.284s user: 0m0.048s sys: 0m0.216s
cp working q real: 0m0.162s user: 0m0.036s sys: 0m0.120s
rm working real: 0m0.083s user: 0m0.000s sys: 0m0.080s
sync real: 0m1.608s user: 0m0.000s sys: 0m0.000s
flush cache real: 0m0.748s user: 0m0.004s sys: 0m0.032s
[1] cp new real: 0m1.226s user: 0m0.000s sys: 0m0.048s
[1] qcow create real: 0m1.990s user: 0m0.012s sys: 0m0.028s
@smoser
smoser / README.md
Last active February 7, 2018 22:43
simplified "run ubuntu instance on azure" wrapper around azure cmdline tools (azure-ubuntu)

az-ubuntu: easily run Ubuntu on azure using azure-cli

This just makes running az from the azure-cli pypi package possibly more friendly.

Setup

First install azure-cli

Do so with pip: