[Lunar-commits] CVS: lunar-iso/lunar-install/sbin lunar-sysconf, NONE, 1.1

Auke Kok sofar at lunar-linux.org
Tue Nov 30 12:24:15 UTC 2004


Update of /var/cvs/lunar/lunar-iso/lunar-install/sbin
In directory espresso.foo-projects.org:/tmp/cvs-serv1544

Added Files:
	lunar-sysconf 
Log Message:
Adding lunar-sysconf


--- NEW FILE: lunar-sysconf ---
#!/bin/bash
#############################################################
# portions Copyright 2001 by Kyle Sallee                    #
# portions Copyright 2002 by Kagan Kongar                   #
# portions Copyright 2002 by rodzilla                       #
# portions Copyright 2003, 2004 by tchan, kc8apf            #
# portions Copyright 2004 Auke Kok                          #
#                                                           #
# This file in released under the GPL                       #
#############################################################

inputbox()
{
    $DIALOG --nocancel --inputbox "$1" 0 0 "$2"
}


confirm()
{
    if [ "$CONFIRM" == "off" ]; then
        if [ -n "$2" ]; then
            false
        else
            true
        fi
    else
        $DIALOG $2 --yesno "$1" 8 50
    fi
}


show_keymaps()
{
    KEYDIR="/usr/share/keymaps/i386"

    azerty="$(ls $KEYDIR/azerty)"
    dvorak="$(ls $KEYDIR/dvorak)"
    fgGIod="$(ls $KEYDIR/fgGIod)"
    qwerty="$(ls $KEYDIR/qwerty)"
    qwertz="$(ls $KEYDIR/qwertz)"

    MAP_FILES=$(echo -e "$azerty\n$dvorak\n$fgGIod\n$qwerty\n$qwertz" | sort | sed "s/\.kmap\.gz//")

    for MAP in $MAP_FILES; do
        echo $MAP
        echo keymap                        
    done
}


keymap_menu()
{
    TITLE="Keymap Selection Menu"
    HELP="Please select your preferred keymapping."
    KEYMAPS=$(show_keymaps)
    KEYMAP=`$DIALOG --title "$TITLE" --menu "$HELP" 0 0 0 $KEYMAPS`
}


configure_proxy()
{
    HTTP_PROMPT="Please enter the HTTP proxy server\nExample: http://192.168.1.1:8080/"
    FTP_PROMPT="Please enter the FTP proxy server\nExample: http://192.168.1.1:8080/"
    NO_PROMPT="Please enter all domains/ip addresses (comma-seperated) proxy should NOT be used for:\nExample: .mit.edu,mysite.com"
    HPROXY=`inputbox "$HTTP_PROMPT"`           &&
    FPROXY=`inputbox "$FTP_PROMPT" "$HPROXY"`  &&
    NPROXY=`inputbox "$NO_PROMPT"` 
}


confirm_proxy_settings()
{
    FINISHED=NO
    while [ "$FINISHED" != "YES" ]; do
	PROMPT="Are these settings correct?"
	PROMPT="$PROMPT\nHTTP Proxy:  $HPROXY"
	PROMPT="$PROMPT\n FTP Proxy:  $FPROXY"
	PROMPT="$PROMPT\n  No Proxy:  $NPROXY"

	if confirm "$PROMPT" "--cr-wrap"; then
	    FINISHED=YES
	else
	    configure_proxy
	    FINISHED=NO
	fi
    done
}


proxy_exit_message()
{
    $DIALOG --cr-wrap --title "Lunar Proxy Settings Complete" --msgbox \
        "Your proxy configuration has been saved. 

Please note that these proxy settings will only be used
by Lunar (wget) and possibly some other command-line utilities.

You will still have to configure proxy settings in your favorite
web browser, etc..." 12 65

}


toggle()
{
    if [ `eval echo \\$$1` == "on" ]; then
        eval $1=off
    else
        eval $1=on
    fi
}


show_consolefonts()
{
    FONTDIR="/usr/share/consolefonts"
    cd $FONTDIR
    FONTS=`ls *.gz | sed "s/\.psf\.gz//"`

    for FONT in $FONTS; do
        echo $FONT
        echo font
    done
}


font_menu()
{
    TITLE="Console Font Selection Menu"
    HELP="Please select your preferred console fonts."
    FONTS=`show_consolefonts`
    CONSOLEFONT=`$DIALOG --title "$TITLE" --menu "$HELP" 0 0 0 $FONTS`
}


cut_charmaps()
{
    while [ -n "$1" ]; do
        echo "$1" | cut -d/ -f1
        echo "$2"
        shift 2
    done
}


show_languages()
{
    if [ -d $MOONBASE ]; then
        SECTION=`find_section glibc`
        cut_charmaps `cat $MOONBASE/$SECTION/glibc/locales`
    else
        cut_charmaps `cat /etc/lunar/local/locales`
    fi
}


select_lang()
{
    $DIALOG --title "Language Selection Menu" --menu "$HELP" 0 0 0 `show_languages`
}


lang_menu()
{
    TITLE="Language Selection Menu"
    HELP="While lunar is entirely in English 
it is possible to change the languages of many other programs.
Please select your preferred langauge.

This process will ONLY set the LANG environment variable. Do
not expect any changes till you finish and reboot."

    LANG=`select_lang`
    export LANG
    [ ! -e "/etc" ] || echo -e "# you can add declarations for LC_ALL etc in here\n\nexport LANG=\"$LANG\"\n" > /etc/LOCALE
}


editor_menu()
{
    VI_HELP="good old vi"
    NANO_HELP="nano is an enchanced free pico clone"
    JOE_HELP="joe is a WS compatible editor"

    HELP="Actually all are same, we are using e3, only keys differ."
    TITLE="Editor Selection Menu"

    EDITOR=`$DIALOG --title "Editor Selection Menu" --item-help --menu "$HELP" 0 0 0 \
                   "vi"     ""  "$VI_HELP"     \
                   "joe"    ""  "$JOE_HELP"    \
                   "nano"   ""  "$NANO_HELP"`

    export EDITOR
    [ ! -e "/etc" ] || echo "export EDITOR=\"$EDITOR\"" > /etc/profile.d/editor.rc
}


show_timezones()
{
    for ITEM in `ls $LOCALTIME/$1`; do
        if [ -n "$1" ]; then
	    echo "$1/$ITEM"
        else
	    echo "$ITEM"
	fi
        if [ -d $LOCALTIME/$1/$ITEM ]; then
	    echo "Directory"
	else
	    echo "Timezone"
	fi
    done
}


timezone()
{
    LOCALTIME=/usr/share/zoneinfo
    TITLE="Time Zone Selection Menu"
    HELP="Select timezone or directory"
    ZONE=""

    while
      TIMEZONES=`show_timezones $ZONE`  &&
      ZONE=`$DIALOG  --title  "$TITLE"  \
                     --menu             \
                     "$HELP"            \
                     0 0 0              \
                     $TIMEZONES`        &&
      [ -d $LOCALTIME/$ZONE ]
      do
        true
    done

    if [ -f "$LOCALTIME/$ZONE" ]; then
        ln -sf $LOCALTIME/$ZONE /etc/localtime

        TITLE="GMT or Local"
        HELP="Does the hardware clock store time in GMT or local?"

        CLOCK=`$DIALOG --title "$TITLE"   \
                       --menu "$HELP"     \
                       0 0 0              \
                       "GMT"    ""        \
                       "Local"  ""`       &&
        case $CLOCK in
            GMT) true ;;
            Local) HWCLOCK="/sbin/hwclock --hctosys --localtime"
                echo "#!/bin/sh" > /etc/init.d/localtime
                echo "$HWCLOCK" >> /etc/init.d/localtime
                chmod a+x /etc/init.d/localtime
                ln -s ../init.d/localtime /etc/rcS.d/S15localtime
                ;;
        esac
    fi
}


make_server_keys()  {
  make -C /etc/ssh server-keys
  echo -e "\nSSH server keys were created\nPress ENTER to continue."
  read
}


main()
{
    while true; do
        R_LABEL="Set root password"
        R_HELP="Set the default root password needed to access this system (the default password is empty)"
        H_LABEL="Setup hostname and networking"
        H_HELP="Configure your network devices and hostname settings"
        U_LABEL="Administrate users"
        U_HELP="Edit and create user accounts, groups"
        V_LABEL="Administrate services"
        V_HELP="Configure services to start automatically at boot time"
        G_LABEL="Create SSH server keys"
        G_HELP="Generate the SSH server keys"
        A_LABEL="Select a timezone"
        A_HELP="Select a timezone"
        C_LABEL="Select a keyboard map"
        C_HELP="Select keyboard map"
        D_LABEL="Select a console font"
        D_HELP="Select a console font"
        E_LABEL="Set global language"
        E_HELP="Set global language"
        J_LABEL="Select a default editor"
        J_HELP="Select a default editor"

        choices()
        {
          (
            unset IFS
            for CHOICE in R H U V G A C D E J; do
    	        echo $CHOICE
    	        eval echo \$${CHOICE}_LABEL
    	        eval echo \$${CHOICE}_HELP
            done
          )
        }
   
        COMMAND=`$DIALOG --title "$TITLE" --cancel-label "Exit" --default-item "$DEFAULT" --item-help --menu "" 0 0 0 $(choices $CHOICES)` 
        if [ $? != 0 ]; then
            return
        fi
        
	DEFAULT=$COMMAND

        case $COMMAND in
          R)  passwd                 ;;
          H)  lnet                   ;;
          U)  luser                  ;;
          V)  lservices              ;;
          G)  make_server_keys       ;;
          A)  timezone               ;;
          C)  keymap_menu            ;;
          D)  font_menu              ;;
          E)  lang_menu              ;;
          J)  editor_menu            ;;
        esac
    done
}


. /etc/lunar/config

export  IFS="	
"
DIALOG="dialog
--backtitle
Lunar Linux System Configuration  %VERSION% - %CODENAME%
--stdout"
ARCH=`arch`

trap ":" INT QUIT

export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin"
# setting this var is supposed to prevent the enviro_check code now!
export LUNAR_INSTALL=1

main



More information about the Lunar-commits mailing list