#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/edit - ask user for edit # # Copyright (c) 2003-2004 Frank Meyer # # Creation: 19.07.2003 fm # Last Update: $Id$ # # usage: edit file # # return values: # 0 editor started # 1 editor not started # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib # include function library . /var/install/bin/config_shlib configfile=$1 baseconfigfile=`basename $configfile` editor=$EDITOR if [ "$editor" = "" ] then editor=joe fi basename=`basename $editor` mecho mecho mecho "Since there is no EIS/FAIR configuration tool, you must edit" mecho "the EIS/FAIR configuration file $configfile with" mecho "the editor $editor." mecho param="" if [ "$basename" = "joe" ] then mecho "You can get help by joe if you press 'Ctrl-K H'." mecho param="-nobackups" elif [ "$basename" = "vi" -o "$basename" = "vim" ] then mecho "You can get help by vi/vim if you enter ':help'." mecho fi exitval=0 if /var/install/bin/ask "Continue" then umask 077 # do not allow anybody to read anything # config or logfile may contain secret passwords cp -p $configfile /tmp/edit-$$ while [ 1 ] do $editor $param $configfile if [ -f /usr/local/bin/eischk -a -f /etc/check.d/$baseconfigfile ] then mecho -info "Checking configuration file ..." mecho if ! /usr/local/bin/eischk -c /etc/config.d \ -x /etc/check.d \ -l /tmp/$baseconfigfile.log \ -p $baseconfigfile then if ! /var/install/bin/ask "Edit configuration again" then exitval=1 break fi else break fi else break fi done if ! diff /tmp/edit-$$ $configfile >/dev/null then # mv /tmp/edit-$$ $configfile.backup backup_config $baseconfigfile /tmp/edit-$$ rm -f /tmp/edit-$$ else rm -f /tmp/edit-$$ fi rm -f /tmp/$baseconfigfile.log exit $exitval fi exit 1