#!/bin/sh
# Written by Didier Spaier 2016
# Public domain
TMP=$(mktemp -d) || exit 1
export TEXTDOMAIN=slint
. gettext.sh
dialog --title "`gettext "Select the default startup mode"`" --menu \
    "`gettext 'Please choose the default startup mode: Console or Graphical.

In Console mode, you log in and type your first command in a console.
In this mode you can type "startx" to start the default desktop or windows manager, \
that you can also change typing "xwmconfig".

In Graphical mode, you choose the desktop or windows manager, \
that will be started as soon as you are identified.
'`" 0 0 0 \
"Console" "`gettext "Start Linux in Console mode"`" \
"Graphical" "`gettext "Start Linux in Graphical mode"`" \
2>$TMP/reply
REPLY="$(cat $TMP/reply)"
cp /etc/inittab /etc/inittab.save
if [ "$REPLY" = "Console" ]; then
  sed "/:initdefault:/s/.*/id:3:initdefault:/" /etc/inittab.save > /etc/inittab
fi
if [ "$REPLY" = "Graphical" ]; then
  sed "/:initdefault:/s/.*/id:4:initdefault:/" /etc/inittab.save > /etc/inittab
fi
rm -f /etc/inittab.save
rm -rf $TMP
