#!/bin/sh # $Id: visamba,v 1.1 2002/09/24 14:28:22 nturner Exp $ # # Opens a file for editing and then reloads a service if the file # is changed after editing. The edit and reload commands run as root # (using sudo). file="/etc/samba/smb.conf" reloadCmd="sudo /etc/init.d/samba reload" if test "$EDITOR"; then editor="$EDITOR" elif test "$VISUAL"; then editor="$VISUAL" else editor="sensible-editor" fi hashBefore=`md5sum $file` sudo "$editor" "$file" || exit 1 if test "`md5sum $file`" != "$hashBefore"; then $reloadCmd else echo "File contents unchanged." fi