Skip to content

Instantly share code, notes, and snippets.

View riccardomurri's full-sized avatar

Riccardo Murri riccardomurri

View GitHub Profile
@riccardomurri
riccardomurri / TEST.cf
Last active August 29, 2015 13:55
CFEngine module for generating contexts and variables based on the output of `ip addr show`.
# Sample CFEngine usage of the `ips` module.
#
# You should get something like the following:
#
# $ cf-agent -I -f ./TEST.cf -K
# 2014-01-31T16:43:01+0100 info: Executing 'no timeout' ... 'ips'
# 2014-01-31T16:43:01+0100 info: Completed execution of 'ips'
# 2014-01-31T16:43:01+0100 notice: R: Running a test
# 2014-01-31T16:43:01+0100 notice: R: Interface `lo` NOT detected, as it's not UP
# 2014-01-31T16:43:01+0100 notice: R: Interface `wlan0` detected UP
@riccardomurri
riccardomurri / TEST.in
Last active August 29, 2015 14:02
preprocess.cf -- Run external preprocessing commands from CFEngine.
Example processing using the `j2pp` preprocessor;
see: http://github.com/uzh/j2pp
Domain name: {{sys.domain}}
L2 addresses (list):
{% for hwaddr in sys.hardware_addresses -%}
* {{ hwaddr }}
{% endfor %}
#! /usr/bin/env python
import re
from markdown2 import markdown
link_patterns = [
# issueNNN --> /help/issueNNN
(re.compile(r'\b(issue)\s*(\d+)\b'), r'/help/\g<1>\g<2>'),
@riccardomurri
riccardomurri / restart_services.cf
Last active August 29, 2015 14:16
Restart services based on defined class/context names.
body common control
{
inputs => {
"lib/cfengine_stdlib.cf",
};
bundlesequence => { "test" };
}
bundle agent test
(de qq Args
(if (== Args NIL)
# `() -> NIL
NIL
# else, Args is a single-element list, extract body forms
(setq Body (car Args))
(if (not (lst? Body))
# `atom -> atom
Body
# else Body is a list that we must unpack
#! /bin/sh
#
# Install Ansible on a Ubuntu LTS machine.
#
set -ex
export LC_ALL=C
sudo apt-get update
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
diff --git a/components/9990-select-eth-device.sh b/components/9990-select-eth-device.sh
index df00666..6bc67fd 100755
--- a/components/9990-select-eth-device.sh
+++ b/components/9990-select-eth-device.sh
@@ -55,11 +55,22 @@ Select_eth_device ()
case "${ARGUMENT}" in
live-netdev=*)
NETDEV="${ARGUMENT#live-netdev=}"
+ # net device could be specified by MAC address
+ hex="[0-9A-Fa-f][0-9A-Fa-f]"
@riccardomurri
riccardomurri / asciify.py
Last active August 29, 2015 14:27
Two simple functions for rendering a Unicode string using ASCII characters only.
# /usr/bin/env python
# -*- encoding: utf-8 -*-
#
"""
Two simple functions for rendering a Unicode string using ASCII
characters only.
The only sensible applications are on words in a Latin-derived
alphabet (i.e., anything that could be rendered in a ISO-8859-*
character set); anything else will just be replaced by a string of
@riccardomurri
riccardomurri / gist:1157664
Created August 19, 2011 18:51
Emacs commands to wrap a block of text into start/end tags, or insert them. Similar to what AUC-TeX' font commands do, but generic.
(defun wrap-region-in (start-text end-text)
"Insert START-TEXT at the beginning of the currently active
region, and END-TEXT at the end of it."
(let ((start (min (point) (mark)))
(end (max (point) (mark))))
(save-excursion
(goto-char end)
(insert end-text)
(goto-char start)
(insert start-text))))