Archive for August, 2009

Cloning a Fedora rawhide virtual machine

Saturday, August 8th, 2009

Setting up a clone of a Fedora rawhide virtual machine is so simple…

  • Create a new virtual machine instance
  • Stop and then copy the disk image file for the previous VM
  • Boot the new VM in single user mode
  • Edit the /etc/sysconfig/network file to change the hostname
  • Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file to change the networking
  • Do exactly the same thing in /etc/udev/rules.d/70-persistent-net.rules
  • grep through the filesystem to see where else network data is duplicated.

Notice how more and more abstraction of network configuration does not a simpler system make. At least I don’t care about sound on my virtual machines, so to avoid that fun I simply delete the sound device whenever I create a new VM. I never use NetworkManager on boxes with fixed IPs – somehow I don’t think cloning would get any easier (unless I used DHCP, which does work here but I prefer being certain the box has a fixed configuration when used for testing) with that turned on.

Jon.

Posted in Fedora | No Comments »

Fencing your entire apartment with X10

Monday, August 3rd, 2009

So I’ve begun using X10 for some non-essential systems at home (AC, lights, etc.). I am using a firecracker and the following script, which I will put a nice little iPhone-compatible interface around:

#!/bin/sh
#
# The X10 devices are controlled via a "firecracker" on ttyS1
#
# Copyright (C) 2009 Jon Masters 
#
# Distributed under GNU General Public License version 2.
#
X10_FC_PORT="/dev/ttyS1"
X10_BR_COMMAND="/usr/bin/br --port $X10_FC_PORT"
# e.g. TARGETS=("device1" "device2"...)
TARGETS=("device1")
# e.g. MODULES=("A1" "A2"...)
MODULES=("A1")
TARGET="1ドル"
COMMAND="2ドル"
x10_set_module_state() {
 module=1ドル
 state=2ドル
 if [ "xon" == "x$state" ]
 then
 $X10_BR_COMMAND $module on
 else
 if [ "xoff" == "x$state" ]
 then
 $X10_BR_COMMAND $module off
 fi
 fi
}
x10_set_module_state_all() {
 state=1ドル
 for ((i=0;i< $((${#TARGETS[@]}));i++)); do echo "setting module ${TARGETS[${i}]} to $state" x10_set_module_state ${MODULES[${i}]} $state echo "waiting for module ${TARGETS[${i}]} to settle" usleep 500000 done } in_array() { haystack=( "$@" ) haystack_size=( "${#haystack[@]}" ) needle=${haystack[$((${haystack_size}-1))]} for ((i=0;i<$(($haystack_size-1));i++)); do h=${haystack[${i}]}; [ "x$h" == "x$needle" ] && return $i done return 255 } if [ "x$TARGET" == "x" ] || [ "x$COMMAND" == "x" ]; then echo "Usage: ippower  |  "
 echo ""
 echo "TARGETS: ${TARGETS[@]}"
 echo "COMMANDS: on off"
 echo ""
 exit 1
fi
if [ "xall" == "x$TARGET" ]
then
 if [ "xon" == "x$COMMAND" ]
 then
 echo "turning on all modules"
 x10_set_module_state_all on
 elif [ "xoff" == "x$COMMAND" ]
 then
 echo "turning off all modules"
 x10_set_module_state_all off
 fi
else
 in_array "${TARGETS[@]}" "$TARGET"; item=$?
 if [ 255 -ne $item ]
 then
 MODULE="${MODULES[$item]}"
 #echo "TARGET: $TARGET"
 #echo "MODULE: $MODULE"
 if [ "xon" == "x$COMMAND" ]
 then
 x10_set_module_state $MODULE on
 echo "requested module $TARGET on"
 elif [ "xoff" == "x$COMMAND" ]
 then
 x10_set_module_state $MODULE off
 echo "requested module $TARGET off"
 fi
 else
 echo "Unknown target: $TARGET"
 fi
fi

Jon.

Posted in General | No Comments »