Skip to content

Instantly share code, notes, and snippets.

View freyes's full-sized avatar
🥑

Felipe Reyes freyes

🥑
View GitHub Profile
#!/bin/bash
# source: https://github.com/juju/charmstore-client/issues/154#issuecomment-375039544
charm=${1#cs:}
shift
owner="$(charm show "cs:$charm" --format=json | jq -r '.owner.User')"
owner_rev="$(charm show "cs:~$owner/$charm" --format=json | jq -r '."id-revision".Revision')"
owner_url="cs:~$owner/$charm-$owner_rev"
#echo "$owner_url"
charm show "$owner_url" "$@"1
#
# Disable ipv6 in tun* interfaces
# File: /etc/udev/rules.d/99-ipv6-openvpn.rules
SUBSYSTEM=="net", ACTION=="add", KERNEL=="tun*", RUN+="/sbin/sysctl -w net.ipv6.conf.$env{INTERFACE}.disable_ipv6=1"
@freyes
freyes / mongodb_collection_sizes.js
Last active July 23, 2020 14:28 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
# for juju on xenial
cat << EOF > /tmp/a.js
db = db.getSiblingDB('juju');
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
EOF
/usr/lib/juju/mongo3.2/bin/mongo --sslAllowInvalidCertificates --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin /tmp/a.js
@freyes
freyes / git-on-lp.md
Created July 18, 2018 16:12
Notes for Git on Launchpad

Andrew's Notes on using Git with Launchpad

This page describes how I'm planning to work with git and lp, others don't have to follow my approach. The mirroring that I describe below may be slightly unusual, so your local git expert might not fully understand it.

Getting Started

Configure the lp: prefix in ~/.gitconfig

[url "git+ssh://[email protected]/"]
    insteadof = lp:
#!/bin/bash -ex
#
# Usage:
# ./upgrade-series.sh ceph-osd/1
#
# Based on https://jujucharms.com/docs/2.3/howto-updateseries
#
APPNAME=$(echo $1 | cut -d'/' -f1)
UNIT=$(echo $1 | cut -d'/' -f2)
@freyes
freyes / openstack-image-delete-all.sh
Created April 11, 2018 19:11
openstack image delete ALL
#!/bin/bash
for IMAGE_ID in `openstack image list -f csv -c ID | tail -n +2 | tr -d '"' `; do
echo -n "Deleting $IMAGE_ID ..."
(openstack image delete $IMAGE_ID && echo "OK") || echo "ERROR"
done
#!/bin/bash -e
#
# Retrieve certificate's fingerprint
# source: https://stackoverflow.com/a/5165073
openssl s_client -connect $1 < /dev/null 2>/dev/null | openssl x509 -fingerprint -noout -in /dev/stdin
@freyes
freyes / reconfigure-mongodb.txt
Created September 27, 2017 12:04
reconfigure mongodb to a single node
> rs.status()
{
"startupStatus" : 1,
"ok" : 0,
"errmsg" : "loading local.system.replset config (LOADINGCONFIG)"
}
> rs.config()
{
"_id" : "juju",
"version" : 109633,
@freyes
freyes / launch-container-with-home.sh
Last active February 6, 2018 21:59
launch a lxd container with your home mounted under /home/ubuntu
#!/bin/bash -ex
#
# Usage:
# $ ./launch-container-with-home.sh ubuntu:16.04 foobar
UID_=$(id -u $USER)
GID_=$(id -g $USER)
grep -q "root:$UID_:1" /etc/subuid || echo "root:$UID_:1" | sudo tee -a /etc/subuid
grep -q "root:$GID_:1" /etc/subgid || echo "root:$GID_:1" | sudo tee -a /etc/subgid