#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/system-base-set-editor - set eisfair configuration editor # # Copyright (c) 2001-2005 The Eisfair Team, c/o Frank Meyer, frank(at)eisfair(dot)org # # Creation: 09.04.2005 fm # Last Update: $Id$ # # 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 . /etc/config.d/setup ask_for_editor () { mecho mecho " 1: joe" mecho " 2: vi" mecho " 3: ece (eisfair configuration editor (NEW!)" mecho " 4: " mecho " ENTER: Return" mecho /var/install/bin/ask "Choose option:" '' '1' '2' '3' '4' '^$' > /tmp/ask.$$ rc=$? e=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi case "$e" in 1) rtc=joe ;; 2) rtc=vi ;; 3) rtc=/var/install/bin/edit-conf.cui ;; 4) echo -e "New Editor: \c" read rtc ;; '') rtc='' ;; *) rtc='' mecho -warn "invalid input." anykey ;; esac } ask_for_fallback_editor () { mecho mecho " 1: joe" mecho " 2: vi" mecho " 3: " mecho " ENTER: Return" mecho /var/install/bin/ask "Choose option:" '' '1' '2' '3' '^$' > /tmp/ask.$$ rc=$? e=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi case "$e" in 1) rtc=joe ;; 2) rtc=vi ;; 3) /var/install/bin/ask "New Editor:" '' '+' > /tmp/ask.$$ rc=$? rtc=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi ;; '') rtc='' ;; *) rtc='' mecho -warn "invalid input." anykey ;; esac } a=dummy while [ $a != "" ] do clrhome mecho -info "Change eisfair configuration editor" mecho mecho mecho mecho mecho "Current eisfair configuration editors:" mecho if [ "$EDITOR" = /var/install/bin/edit-conf.cui ] then editor='ece' else editor="$EDITOR" fi mecho " Editor: $editor" mecho " Fallback editor: $EDITOR_FALLBACK" mecho mecho " 1: Change editor" mecho " 2: Change fallback editor" mecho " ENTER: Return" mecho /var/install/bin/ask "Choose option:" '' '1' '2' '^$' > /tmp/ask.$$ rc=$? a=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi case "$a" in 1) ask_for_editor if [ "$rtc" != "" ] then EDITOR="$rtc" fi ;; 2) ask_for_editor if [ "$rtc" != "" ] then EDITOR_FALLBACK="$rtc" fi ;; "") break ;; *) mecho -warn "invalid input." anykey ;; esac done sed -e "s#EDITOR='[^']*'#EDITOR='$EDITOR'#" \ -e "s#EDITOR_FALLBACK='[^']*'#EDITOR_FALLBACK='$EDITOR_FALLBACK'#" \ /etc/config.d/setup >/tmp/edit-$$ cp /tmp/edit-$$ /etc/config.d/setup rm -f /tmp/edit-$$ anykey exit 0