Kristian's web log

February 17, 2010

Wikish – Mediawiki-editing on command line

Filed under: /dev/random — Tags: , , , , — kristian @ 00:09

wiki.sh (or wikish) is a shell-script I wrote to work with our internal mediawiki-wikis. It’s functional for both the new varnish-software wiki and the old redpill-linpro wiki I use.

Basically it lets you edit wiki-content with vi, vim, gvim or even nvi. Very simple, and a result of mvs, wikipediafs and mediawiki-fuse being seemingly horrible messes. It also makes it possible for me to easily script copy/pasting from one wiki to an other without much hassel. All in all it’s a little over 200 lines of sh-code using lwp-request/curl and awk. It works.

Get it from: http://github.com/KristianLyng/wikish

Currently doesn’t support “normal” mediawiki-login, but rpl and varnish-software use basic auth over ssl and work fine. I’ll gladly add normal login if someone gives me an account on a wiki they own and operate where I can test it (not wikipedia please, unless you are wikimedia).

Usage example: wikiedit “Main Page”. (that simple, yes)

PS: Sorry for hijacking the name.

February 18, 2009

Easy reloading of varnish’ VCL

Filed under: Varnish — Tags: , , — kristian @ 15:43

One thing I do regularly is reload the default VCL that Varnish use, and to avoid using telnet or varnishadm manually, I’ve written a tiny script that loads and uses default.vcl (or any other file, for that matter).

#!/bin/bash
# Reload a varnish config
# Author: Kristian Lyngstol

FILE="/etc/varnish/default.vcl"

# Hostname and management port
# (defined in /etc/default/varnish or on startup)
HOSTPORT="localhost:6082"
NOW=`date +%s`

error()
{
    echo 1>&2 "Failed to reload $FILE."
    exit 1
}

varnishadm -T $HOSTPORT vcl.load reload$NOW $FILE || error
varnishadm -T $HOSTPORT vcl.use reload$NOW || error
echo Current configs:
varnishadm -T $HOSTPORT vcl.list

Powered by WordPress