Switchtool

From Rsewiki

An easy way to make the smrs use another branch of mobotware is to run 'switchtool'. Current braches are found in the /opt/smr.* folders on nyquist and jensen.

To shift branch: Login as root on the smr and run:

root@smr3:~# switchtool <name>

For example if your would like to use the versions in /opt/smr.2011c run:

root@smr3:~# switchtool 2011c

Remember that the original setup is restored on reboot. This means /misc/opt/smr is linked to /usr/local/smr.

To use local files

The switchtoo knows a local option, this moves the /usr/local/smr to the local flash:

root@smr3:~# switchtool local

The local flash is updated using a script in /root. To update the local version to a specific configuration run first the switchtool for that configuration, then the update_smr, and then switch to local

root@smr3:~# switchtool 2011c
root@smr3:~# ./update_smr
root@smr3:~# switchtool local

The switchtool script

The switchtool uses the /etc/rc.smr/rc.smr script to restart configure and restart (rhd)

The switchtool is listed below and is residing in the /usr/sbin folder on the smrs.

#!/bin/bash

dir_name="/misc/opt/smr.${1}"

if [ ! -d /usr/local/smr.net/bin ]; then
	echo "Switching impossible. Kalman /opt not found."
	exit 1
fi

if [ ! -z ${1} ]; then
	if [ ! -d $dir_name/bin ]; then
		echo "Switching impossible. Path: ${dir_name} not found."
		exit 2
	fi
fi

if [ ! -x /etc/rc.smr/rc.smr_shutdown ]; then
	echo "Warning: Smr startup scripts not found. Is this a robot ?"
else
	/etc/rc.smr/rc.smr_shutdown
fi

if [ -z ${1} ]; then
	echo "Switching to production mode"
	rm -f /usr/local/smr
	ln -sf /usr/local/smr.net /usr/local/smr
else
	echo "Switching to ${1} mode"
	rm -f /usr/local/smr
	ln -sf $dir_name /usr/local/smr
fi

if [ -x /etc/rc.smr/rc.smr ]; then
	/etc/rc.smr/rc.smr
fi

sleep 2
echo "done"

exit 0