code:
clear

##########
#idk, should i alias all the basic installer commands to unify across all base-distros, like a rosetta stone?

function deskfigselector {
  echo "deskfigselector is temporarily out of order while fixing main install"
  echo
  echo "welcome to the witchcraft\'s deskfig selector.  here you can install what really gives your os character, it\'s desktop environment omponents and configuration."

  #decomment when bringing deskfigselection back into comission.  ~ may also wanna change from stupid "select" style question, to a regular read, like tried n tested above.
  $WITCH/color.sh GREEN "
    1) rowan    ~~~    minimal fully-functional desktop
    2) willow   ~~~    like rowan, but a bit more flexibility when balancing minimalism to comfort ~vaporware
    3) jamella  ~~~    a tiling window manager showcase distro ~vaporware
    4) zelda    ~~~    idkwtf, it is all still just vapourware this far down the list
    5) add your own configuration script here

  enter number preference of preference:"

  read SPINTOP
  case $SPINTOP in
    1)
      echo "Choice was $SPINTOP, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the rowan bit"
      $WITCH/deskfig.d/installrowan.sh
    ;;
    2)
      echo "Choice was $SPINTOP, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the willow bit"
      $WITCH/deskfig.d/installwillow.sh
    ;;
    3)
      echo "Choice was $SPINTOP, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the jamella bit"
      $WITCH/deskfig.d/installjamella.sh
    ;;
    4)
      echo "Choice was $SPINTOP, sorry, this part of the script is incomplete"
      echo "this would be where you get taken to the zelda bit"
      $WITCH/deskfig.d/installzelda.sh
    ;;
    5)
      echo "Choice was $SPINTOP, sorry, this part of the script is incomplete"
      echo "this would be where you get taken to the Gentoo/Hurd bit"
      $WITCH/deskfig.d/getdeskfig.sh
    ;;
    *)
      echo "Non-valid choice. try again"
      deskfigselector
      exit 1
    ;;
  esac
}

deskfigselector #From the start


code:
##################
##################
##################
### distroselect

distroselect() {
  clear

  #distroselect first question
  $WITCH/color.sh QUESTION "what meta-distro do you want your witch based on?"
  $WITCH/color.sh GREEN "
    1)  Gentoo     (pick me!)
    2)  Bedrock
    3)  Funtoo
    4)  Exherbo
    5)  Gentoo/BSD
    6)  Gentoo/Hurd
    7)  FreeBSD
    8)  Debian
    9)  tinycore
   10)  killx
   11)  sourcemagethingy
   42)  the answer to life, the universe and everything
   88)  combo
   99)  other

  enter preferred number preference of preference:"

  read BASEDISTRO
  case $BASEDISTRO in
    1)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the gentoo bit"
      sleep 3
      $WITCH/cauldren.d/installgentoo.sh
    ;;
    2)
      $WITCH/color.sh QUESTION "who's bedrock installer do you want to use?"
      $WITCH/color.sh GREEN "
        d) Digit's bedrock installer script (incomplete! dangerous)
        p) Paradigm's official bedrock installer (recommended)
     enter the letter corresponding to your choice:"
      read BEDROCKINSTALLER
      case $BEDROCKINSTALLER in
        d)
           echo "Choice was $BASEDISTRO, and $BEDROCKINSTALLER. sorry, this part of the script is incomplete"
           echo "this is where you get taken to the bedrock bit"
           sleep 3
           $WITCH/cauldren.d/installbedrock.sh
        ;;
        p)
           echo "Choice was $BASEDISTRO, and $BEDROCKINSTALLER. this takes you direct to third party, bedrock's offical installer direct from github."
           sleep 3
           $WITCH/cauldren.d/installbedrockofficial.sh
        ;;
      esac
    ;;
    3)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the funtoo bit"
      sleep 3
      $WITCH/cauldren.d/installfuntoo.sh
    ;;
    4)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the exherbo bit"
      sleep 3
      $WITCH/cauldren.d/installexherbo.sh
    ;;
    5)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this would be where you get taken to the Gentoo/BSD bit"
      sleep 3
      $WITCH/cauldren.sh
    ;;
    6)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this would be where you get taken to the Gentoo/Hurd bit"
      sleep 3
      $WITCH/cauldren.sh
    ;;
    7)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this would be where you get taken to the FreeBSD bit"
      sleep 3
      $WITCH/cauldren.sh
    ;;
    8)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the debian bit"
      sleep 3
      $WITCH/cauldren.d/installdebian.sh
    ;;
    9)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the tinycore bit"
      sleep 3
      $WITCH/cauldren.d/installtinycore.sh
    ;;
    10)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this is where you get taken to the killx bit"
      sleep 3
      $WITCH/cauldren.d/installkillx.sh
    ;;
    42)
      echo "deep thought"
      $WITCH/cauldren.d/installmix.sh
    ;;
    88)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "this would be where you get taken to the bit that lets you custom pick each bit seperately (stage3, kernel, package manager, spintop, etc)... er, i think.   second thoughts, this might already have been an option by the time you\'re selecting which basedistro... oh well, there\'s no real harm in having it in here again, right?"
      sleep 3
      $WITCH/cauldren.sh
    ;;
    99)
      echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
      echo "idkwtf goes here...  something, surely."
      sleep 3
      $WITCH/cauldren.sh
    ;;
    *)
      echo "Non-valid choice. try again"
      sleep 3
      distroselect
    ;;
  esac
}

distroselect

repo_name: orbea/witch

license: mit


code:
############
#############
# driveprep
# GLOBAL needs no change.

#MIX ... this is where the addaption from gentoo to poly-distro develops

echo "======================"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
echo "Distro name: $DISTRONAME"
INTERVENE=$(sed -n '4p' $WITCH/config.txt)
echo "Intervene? $INTERVENE"
echo "======================"

#this is the partition preparation function.  calls of it  aught imediately preceed the stageinstall function

show_disk() {
  sleep 1
  echo
  $WITCH/color.sh GREEN "here's a nice little list of your drives."
  fdisk -l
  echo
}

create_mnt() {
  if [ ! -d /mnt/$a ]
  then
    mkdir /mnt
  fi

  echo "your new OS installation / distro name is $DISTRONAME (this will make a directory of that name in /mnt/___.):"
  if [ ! -d /mnt/$DISTRONAME/$a ]
  then
    mkdir /mnt/$DISTRONAME
  fi

  cd /mnt/$DISTRONAME
}

partition() {
  echo "do you need to partition? creating your partition for your own little witch. (y/n) :"
  read REPLY
  if [ "$REPLY" == "y" ]
  then
    $WITCH/procedure.d/partmanselector.sh #calls the partition manager selection function "partmanselector"
  elif [ "$REPLY" == "n" ]
  then
    echo "ok, ready to go so..."
  fi
}

error() { # first parameter is error message, second is fuction to execute
  $WITCH/color.sh ERROR "$1"
  "$2"
}

rootdir() {
  echo "where ya putting your root dir? (e.g. sda3) - (NOT /root, we mean /):"
  read -r ROOTDEV
  echo $ROOTDEV >> $WITCH/config.base.txt # a late 5th line :P

  if [ $INTERVENE == "y" ]
  then
    echo "we're going to mount /dev/$ROOTDEV to /mnt/$DISTRONAME. want a different location? [y/n]"
    read REPLY
    if [ $REPLY == "y" ]
    then
      echo "okay, type in your wanted location."
      read LOCATION
      mount /dev/$ROOTDEV $LOCATION || error "something went wrong. try again" rootdir
    else
      echo "okay."
      sleep 1
      mount /dev/$ROOTDEV /mnt/$DISTRONAME || error "something went wrong. try again" rootdir
    fi
  else
    mount /dev/$ROOTDEV /mnt/$DISTRONAME || error "something went wrong. try again" rootdir
  fi
}

boot() {
  echo "you want a separate boot right? [y/n]:"
  read
  if [ "$REPLY" == "y" ]
  then
    if [ ! -d /mnt/$DISTRONAME/boot/$a ]
    then
      mkdir /mnt/$DISTRONAME/boot
    fi

    echo "where ya putting your boot dir? (e.g. sda1):"
    read -r BOOTDEV
    mount /dev/$BOOTDEV /mnt/$DISTRONAME/boot || error "something went wrong. try again" boot

  fi
  # i wonder, if you can do "if $REPLY=y then else fi" or something like that.
}

home() {
  echo "you want a separate home too? (y):"
  read

  if [ "$REPLY" == "n" ]
  then
    echo "ok your home partition will just be lumped in with root, like the stupid people use."
  elif [ "$REPLY" == "y" ]
  then
    if [ ! -d /mnt/$DISTRONAME/home/$a ]
    then
      mkdir /mnt/$DISTRONAME/home
    fi

    echo "where ya putting your home dir? (e.g. sda1):"
    read -r HOMEDEV
    mount /dev/$HOMEDEV /mnt/$DISTRONAME/home || error "something went wrong. try again" home
  else
    home
  fi
}

dimg_script() {
  mkdir $WITCH/sys
  mkdir $WITCH/sys/$DISTRONAME
}

# start of execution of methods
if [ "$DIMG_RUN" == "true" ]; then
  dimg_script
else
  show_disk
  create_mnt
  partition
  rootdir
  boot
  home
fi

sleep 1


code:
############
############
# initialmakeconf
# Gentoo's make.conf is in /etc/portage/ and not in /etc/

#MIX ... this is where the addaption from gentoo to poly-distro develops
#obviously, not all distros will need a make.conf like this

echo "======================"
EDITOR=$(sed -n '1p' $WITCH/config.txt)
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
echo "Editor: $EDITOR"
echo "(base) Distro name: $DISTRONAME"
METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
echo "METADISTRO: $METADISTRO"
echo "======================"

###### ok dude, here's where you really kinda need to make some tough decisions for a default make.conf, and also make options, and manual make.conf editing.  ... n seriously, some sembelence of a default for rowan witch, would make sense.

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=$/mnt/$DISTRONAME
fi

## here goes. the variable selection based on different distros
LOCATION="$SYSPATH/etc/make.conf"
case "$METADISTRO" in
  "GENTOO") LOCATION="$SYSPATH/etc/portage/make.conf" ;; # look at http://www.gossamer-threads.com/lists/gentoo/dev/259544
esac

# being a nice guy, i'll create a symbolic link for them.
if [ "$LOCATION" != "$SYSPATH/etc/make.conf" ]
then
  echo "since your make.conf is in $LOCATION and not $SYSPATH/etc/make.conf we'll create a symbolic link for you."
  ln -s $LOCATION $SYSPATH/etc/make.conf
fi

#backup the original one.
BACKUP=${LOCATION}.bk~
if [ -f ${LOCATION}.bk~ ]
then
  BACKUP=${LOCATION}.newbk~
  cp $LOCATION ${LOCATION}.newbk~
else
  cp $LOCATION $BACKUP
fi

echo "made backup make.conf"
echo "the backup is at: $BACKUP"
sleep 1

#put make.conf configuring in own function section too, utilising variables for different bases (gentoo, exherbo, etc)
echo "for help with this, refer to chapter 5c of the gentoo handbook
http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=5#doc_chap3"
$WITCH/color.sh QUESTION "how do you wanna handle configuring your make.conf file? (or rather, your $LOCATION file, since it might be different)"
$WITCH/color.sh GREEN "
m - manually edit
d - dont care, do it for me, default it.   (warning, incomplete! overwrites!)
w - wget from _____
c - copy from _____
v - vanilla - dont touch it!
u - use the fully commented one from $SYSPATH/usr/share/portage/config/make.conf
r - restore your backup"
read
case "$REPLY" in
  m)
    $EDITOR $LOCATION
  ;;

  d)
    echo "looks like the make.conf default hasnt been made yet.  you will probably want to copy back from $SYSPATH/etc/make.conf~rawvanillaoriginal or $SYSPATH/etc/make.conf~wtfanewbackup $SYSPATH/usr/share/portage/config/make.conf or another from somewhere else, or make your own now, and maybe go to #witchlinux on irc.freenode.net and tell digitteknohippie he forgot he left the make.conf section in such a state of disrepair." | tee $LOCATION
  ;;

  w)
    echo "enter the url where your make.conf is located:"
    read MAKECONFURL
    wget $MAKECONFURL -o $LOCATION
  ;;

  c)
    echo "enter the location where your make.conf is located (e.g. $SYSPATH/usr/share/portage/config/make.conf):"
    read MAKECONFLOC
    cp $MAKECONFLOC $LOCATION
  ;;

  v)
    echo "well that is easily done.  ... done."
  ;;

  u)
    echo "here goes"
    echo "cp $SYSPATH/usr/share/portage/config/make.conf $LOCATION"
    cp $SYSPATH/usr/share/portage/config/make.conf $LOCATION
  ;;

  r)
    echo "so you want to restore your backup?"
    cp $BACKUP $LOCATION
  ;;
esac

gentoo_config() {
  $WITCH/color.sh QUESTION "not finished with your make.conf yet.  wanna pick a fast portage-mirror? "
  $WITCH/color.sh GREEN "
    m - manually edit
    d - choose near mirror(s) with mirrorselect. [recommended]
  v - vanilla - dont touch it."
  read REPLY

  case $REPLY in
    m)
      echo "forget to do that first time?"
      $EDITOR $SYSPATH/etc/make.conf
    ;;
    d)
      echo "now we cleverly do: mirrorselect -i -o >> $SYSPATH/etc/make.conf"
      mirrorselect -i -o >> $SYSPATH/etc/make.conf
    ;;
    v)
      echo "well that is easily done.  ... done."
    ;;
  esac
}

if [ "$METADISTRO" == "GENTOO" ]; then
  gentoo_config
fi

#might this chunk aught be looped? so multiple checks can be done after edits?  or is that just silly?
#no, it is silly as it is now.
echo "look at this and make sure it looks right. press 'q' to exit. press enter when you're ready."
read enter
less $LOCATION
$WITCH/color.sh QUESTION "does that look right? (y/n)"
read

if [ "$REPLY" == "n" ]; then
  echo "fix it then:"
  sleep 1
  $EDITOR $LOCATION
fi

#remove this line if the above suggested looping gets made
echo "well if it is not sorted as you want, you can always tweak it later when we're in the chroot system."
#might wanna consider making that able to be called any time (or at least specific non-borky times)
sleep 1


code:
# Needs some changes. METADISTRO has been included for usage.
# REQUIRES FIXING

#MIX ... this is where the addaption from gentoo to poly-distro develops
#once this is "if"ed up, it will make much more sense for the mix... many distro bases will effectively skip this, having their package manager need no "installation", already present with their "stage" equivalent.

echo "======================"
BROWSER=$(sed -n '2p' $WITCH/config.txt)
PROX=$(sed -n '3p' $WITCH/config.txt)
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
PACKAGEMGR=$(sed -n '4p' $WITCH/config.base.txt)
echo "Browser: $BROWSER"
echo "Proxy: $PROX"
echo "Package manager: $PACKAGEMGR"
echo "Distro name: $DISTRONAME"

METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
echo "Metadistro: $METADISTRO"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

function howdlpkg {
  echo
  $WITCH/color.sh QUESTION "how would you like to fetch your package manager"
  echo
  $WITCH/color.sh GREEN "
        A.    get it same way as in gentoo handbook (instructive)
        B.    enter a direct URL to the package manager (INCOMPLETE)
        C.    enter a location in the file system (already have downloaded)(INCOMPLETE)
  D.    already extracted"

  read Stage3dlmethod
  case $Stage3dlmethod in
    A|a)
      echo "$Stage3dlmethod was selected."
      sleep 1
      browserpkg
    ;;

    B|b)
      echo "$Stage3dlmethod was selected."
      sleep 4
      urlpkg
    ;;

    C|c)
      echo "$Stage3dlmethod was selected."
      sleep 4
      locpkg
    ;;

    D|d)
      echo "Proceeding..."
      sleep 2
    ;;
  esac
}

# as with stage download above, this needs to be put in a more automated and option-able method.  likely using "case - esac" or using earlier defined packagemanager choice.  ... so likely will warrant a refunctionising, creating a separate installportage and installpaludis, and... other?
# also, variablise it to be basedistro-savvy, so sensible defaults can be chosen, if ya like.
#read -p "that is as much as we can do for that now.  are you enjoying this so far?"
#[ "$REPLY" == "y" ] echo "well good then.  now we\'ll carry on getting your package manager too" && sleep 2

# Let's make this automated first, then we can unify it easily with case statements.

function browserpkg {
  echo "Now that the stage is installed, we continue to installing your package manager.  READ CAREFULLY:"
  sleep 2
  echo "Press y to use \" $BROWSER \" to navigate http://www.gentoo.org/main/en/mirrors2.xml to the snapshots directory in a mirror close to you.
  in /snapshots/, download the latest Portage snapshot (portage-latest.tar.bz2 NOT portage-latest.tar.xz) by selecting it and pressing D. When it finishes downloading, exit the browser by pressing q."
  #we'll add ability to use any format later.  or maybe ye who is reading this can. :P
  $WITCH/color.sh YELLOW "make sure it's in the $SYSPATH path"
  echo ""
  $WITCH/color.sh QUESTION "ready to download your portage (y - yes) (p - yes, with proxy support)"
  read

  case $REPLY in
    y|Y)
      $BROWSER http://www.gentoo.org/main/en/mirrors.xml
      $WITCH/color.sh QUESTION  "ready to continue? (y)"
      read REPLY
      if [ "$REPLY" == "y" ]; then
        echo "proceeding"
        echo "so what's your package manager filename? (e.g. portage-latest.tar.bz2)"
        read FILENAME
        if [ -f $SYSPATH/$FILENAME ]
        then
          echo "excellent you seem to have got your package manager downloaded successfully."
          extractpkg $SYSPATH/$FILENAME
        else
          echo "sorry, it didnt seem like you got a package manager then... er... wtf do we do now?  carry on n presume it\'s there?  give up and run away crying? try again?  well, it\'s up to you."
          sleep 2
          $WITCH/cauldren.sh
        fi
      fi
    ;;
    p|P)
      $BROWSER -http-proxy $PROX http://www.gentoo.org/main/en/mirrors.xml
      read -p "ready to continue? (y):"
      if [ "$REPLY" == "y" ]; then
        echo "proceeding"
        echo "so what's your package manager filename?"
        read FILENAME
        if [ -f $SYSPATH/$FILENAME ]; then
          echo "excellent you seem to have got your package manager downloaded successfully."
          sleep 2
          extractpkg $SYSPATH/$FILENAME
        else
          echo "sorry, it didnt seem like you got a package manager then... er... wtf do we do now?  carry on n presume it\'s there?  give up and run away crying? try again?  well, it\'s up to you."
          sleep 2
          $WITCH/cauldren.sh
        fi
      fi
    ;;
  esac

  #sort this bit out FIXME
  #md5sum -c portage-latest.tar.bz2.md5sum
}

function urlpkg {
  echo "where are you getting your package manager compressed-tarball from? what's the exact url?"
  read PKGURL
  cd $SYSPATH/usr
  wget $PKGURL
  extractpkg $PKGURL
}

function locpkg {
  echo "where is your package manager compressed-tarball located at? what's the exact file path adress?"
  read PKGLOC
  extractpkg $PKGLOC
}

function extractpkg {
  echo "unpacking your stage3 ($FILE) to $SYSPATH/usr/. this may take some time, please wait."
  echo "extracting $1 to $SYSPATH/usr/"
  tar xvf $1 -C $SYSPATH/usr
}

howdlpkg


code:
##########
##########
## partman
## GLOBAL needs no changes

#MIX ... this is where the addaption from gentoo to poly-distro develops
#there should be no change needed for this section in the mix... nothing distro specific... unless something fancy requested for elaborate bedrock installs, etc.

function partman {
  echo "once you have partitioned your hard drive satasfactorilly, exit the partition manager, and the script will continue."
  $WITCH/color.sh QUESTION "which partition manager do you want to use?"
  $WITCH/color.sh GREEN "
    A.    fdisk
    B.    gparted
  C.    enter your own preference of partition manager"

  read PARTITIONER

  case $PARTITIONER in
    A|a)
      echo "Choice was $PARTITIONER. launching..."
      sleep 5
      fdisk
      echo "okies, i\'m still working on the bit for creating file systems after using fdisk."
    ;;
    B|b)
      echo "Choice was $PARTITIONER. launching..."
      sleep 5
      gparted
    ;;
    C|c)
      echo "Choice was $PARTITIONER. "
      echo "enter name of your prefered partition manager" && read -r PARTMANSEL
      $PARTMANSEL
    ;;
    *)
      echo "Valid Choices are A,B,C, try again."
      partman
    ;;
  esac

  echo "partitioning complete"
}

partman


code:
########
########
## chroot
## GLOBAL needs no changes

#MIX ... this is where the addaption from gentoo to poly-distro develops
#twil b fun getting this "if"ed up to accomodate the different chrootnesses needed.

echo "======================"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
echo "Distro name: $DISTRONAME"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

#put prechroot and wichroot sections in a function too.
#variable-ise this to accomodate differences between systems
echo " copying your net connection dns stuffs to your $DISTRONAME with
\"cp -L /etc/resolv.conf $SYSPATH/etc/resolv.conf\""
cp -L /etc/resolv.conf $SYSPATH/etc/resolv.conf
sleep 2
echo "TO THE CHROOT"
sleep 1
echo "In a few moments, we will change the Linux root towards the new location. To make sure that the new environment works properly, we need to make certain file systems available there as
well."
sleep 7
echo "you should be running this from a clean non-borked system (systemrescuecd is a good choice), if not... pray."
sleep 3

echo "mount -t proc none $SYSPATH/proc"
mount -t proc none $SYSPATH/proc
sleep 1
echo "mount --rbind /sys $SYSPATH/sys"
mount --rbind /sys $SYSPATH/sys
sleep 1
echo "mount --rbind /dev $SYSPATH/dev"
mount --rbind /dev $SYSPATH/dev
sleep 1


code:
echo "======================"
BROWSER=$(sed -n '2p' $WITCH/config.txt)
PROX=$(sed -n '3p' $WITCH/config.txt)
echo "Browser: $BROWSER"
echo "Proxy: $PROX"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
ARCH=$(sed -n '3p' $WITCH/config.base.txt)
echo "Distroname: $DISTRONAME"
echo "Arch: $ARCH"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

#############
#############
# stageinstall
# Needs some changes. METADISTRO has been included for usage.

#MIX ... this is where the addaption from gentoo to poly-distro develops

#copied from digit's witchnotes.
#change the browser bit.  at least extend the explanation, or re-word to something like, "download the .tar.bz2 stage3 file apropriate for your architechture, to $SYSPATH/" and then add a "are you ready to proceed? (have you got the stage3 in your distro-to-be's root dir?)" and perhaps even altering it, since i already have a check in place, change what happens upon that check failing, so that it gives the user time to arrange that to make sure it is there... perhaps even advising/educating on ways to do that (like explaining how with tty n wget or cp etc).

function howdlstage3 {
  echo
  $WITCH/color.sh QUESTION "how would you like to fetch your stage3"
  echo
  $WITCH/color.sh GREEN "
    A.  get it same way as in gentoo handbook (instructive)
    B.  enter a direct URL to the stage3 (INCOMPLETE)
    C.  enter a location in the file system (already have downloaded)(INCOMPLETE)
  D.  already extracted"

  read Stage3dlmethod
  case $Stage3dlmethod in
    A|a)
      echo "$Stage3dlmethod was selected."
      sleep 1
      browserstage3
    ;;

    B|b)
      echo "$Stage3dlmethod was selected."
      sleep 4
      urlstage3
    ;;

    C|c)
      echo "$Stage3dlmethod was selected."
      sleep 4
      locstage3
    ;;

    D|d)
      echo "Proceeding..."
      sleep 2
    ;;
  esac
}

function browserstage3 {
  echo "witchcraft will use browsers to download vital parts (and less vital parts too)"
  sleep 1
  echo "ok"
  sleep 1

  #get links n lynx variablised, so can then have either used throughout with ease (y'know, so like later on it'd be just $TXTBROWSER insteada links, and TXTBROWSER would be referenced to either links or lynx, like so:
  #TXTBROWSER=hash links 2>&- || { echo >&2 "links is not installed.  how about lynx..."; lynx 1; }
  #echo "what is your prefered text webbrowser?" && read -r TXTBROWSER
  #   ... i think.  anyways, i'll not implement (uncomment) that just yet.  it'd mean making the appropriate changes bellow too.

  #variablise to denote any special needs per specific stages (such as the differences between exherbo and gentoo stages.)
  echo "READ INSTRUCTIONS CAREFULLY ~"

  echo "here you need to extract a stage3 compressed tarball to $SYSPATH"
  echo "once you\'ve read these instructions, press y (and enter) to use \"$BROWSER\" web browser to navigate http://www.gentoo.org/main/en/mirrors2.xml to download your stage3 tarball for the base system."
  echo ""
  echo "Once the page loads and you\'ve found a nearby mirror, navigate to the ** releases/$ARCH/autobuilds/ ** directory. There you should see all available stage files for your architecture (they might be stored within subdirectories named after the individual subarchitectures).  download the tar.bz2, not a tar.xz" #we'll add ability to use any format later.  or maybe ye who is reading this can. :P
  echo "If you're using a text browser: Select one and press D to download. Otherwise, download however you wish."
  echo ""
  echo "This may take some time. When it has finished, quit the browser (press q in links browser) (or just close the tab) and the rest of this script will resume."
  $WITCH/color.sh YELLOW "make sure it's in the $SYSPATH path."
  echo ""
  $WITCH/color.sh GREEN "ready to follow those instructions? (y - yes) (p - yes, with proxy support ~ may not work)"
  read

  # appears that to automate it
  # use netstat + wget
  # will do that in another option for downloading stage3.

  case $REPLY in
  y)
    $BROWSER http://www.gentoo.org/main/en/mirrors2.xml || $WITCH/color.sh ERROR "hmm things don't seem to have worked. open up your browser yourself, navigate to http://www.gentoo.org/main/en/mirrors2.xml and download to the witch directory at $SYSPATH"
    read -p "ready to continue? (y):"

    if [ "$REPLY" == "y" ]; then
      echo "proceeding"
      echo "so what's your stage3 filename?"
      read FILENAME
      if [ -f $SYSPATH/$FILENAME ]; then
        echo "excellent you seem to have got your stage3 downloaded successfully."
        extractstage3 $SYSPATH/$FILENAME
      else
        echo "looks like you didn't manage to download your stage3 successfully."
        echo "in a couple of seconds we'll rerun this function."
        sleep 3
        browserstage3
      fi
    fi
  ;;

  p)
        $BROWSER -http-proxy $PROX http://www.gentoo.org/main/en/mirrors.xml || $WITCH/color.sh ERROR "hmm things don't seem to have worked. open up your browser yourself, navigate to http://www.gentoo.org/main/en/mirrors2.xml and download to the witch directory at $SYSPATH"
    read -p "ready to continue? (y):"
    if [ "$REPLY" == "y" ]; then
      echo "proceeding"
      echo "so what's your stage3 filename?"
      read FILENAME
      if [ -f $SYSPATH/$FILENAME ]; then
        echo "excellent you seem to have got your stage3 downloaded successfully."
        sleep 2
        extractstage3 $SYSPATH/$FILENAME
      else
        echo "looks like you didn't manage to download your stage3 successfully."
        echo "in a couple of seconds we'll rerun this function."
        sleep 3
        browserstage3
      fi
    fi
  ;;

  n) exit ;;
  esac
}

function urlstage3 {
  echo "where are you getting your stage3 compressed-tarball from? what's the exact url?"
  read STAGE3URL
  cd $SYSPATH
  wget $STAGE3URL
  extractstage3 $STAGE3URL
}

function locstage3 {
  echo "where is your stage3 compressed-tarball located at? what's the exact file path adress?"
  read STAGE3LOC
  extractstage3 $STAGE3LOC
}

function extractstage3 {
  #set this so user can choose if they want verbose output
  echo "unpacking your stage3 ($FILE) to $SYSPATH. this may take some time, please wait."
  echo "extracting $1 to $SYSPATH"
  tar xvf $1 -C $SYSPATH
}

#script starts here.
sleep 1
echo

howdlstage3


code:
############
############
# wichroot
# Needs some changes. METADISTRO has been included for usage.
# Oh, and refactor it to make it easier to unify. Only some sections require change.

#MIX ... this is where the addaption from gentoo to poly-distro develops
#as in prechroot, twil be fun "if"ing up this to accomodate the unique chrootnesses.

echo "======================"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
PACKAGEMGR=$(sed -n '4p' $WITCH/config.base.txt)
echo "Distro name: $DISTRONAME"
echo "PACKAGEMGR: $PACKAGEMGR"

METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
echo "Metadistro: $METADISTRO"

ROOTDEV=$(sed -n '5p' $WITCH/config.base.txt)
echo "Root filesystem location: $ROOTDEV"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

################### wichroot likely needs an end bit to de-chroot, to make the rest of the script run. !!!!!!!!!!!!!!!!

echo "ENTER THE CHROOT" # http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ <- will tell you how... at least the basics of it.  this still likely means packaging up the rest of the installer for the chrooted half, into a cat-eof'd && chmod+x'd script just prior to the chroot, and then running that.
sleep 1

# clear the file
echo > $WITCH/procedure.d/wichroot_script.sh.new

while read line
do
  if [[ -n "$line" ]]; then
    if [[ "$(echo $line | grep 'DISTRONAME=placeholder')" == "$line" ]]; then
      # check if line is DISTRONAME=placeholder --> normal string equality check does not work
      line="DISTRONAME=$DISTRONAME"
    fi

    if [[ "$(echo $line | grep 'PACKAGEMGR=placeholder')" == "$line" ]]; then # etc...
      line="PACKAGEMGR=$PACKAGEMGR"
    fi

    if [[ "$(echo $line | grep 'METADISTRO=placeholder')" == "$line" ]]; then
      line="METADISTRO=$METADISTRO"
    fi

    if [[ "$(echo $line | grep 'ROOTDEV=placeholder')" == "$line" ]]; then
      line="ROOTDEV=$ROOTDEV"
    fi
  fi
  echo "$line" >> $WITCH/procedure.d/wichroot_script.sh.new

done < $WITCH/procedure.d/wichroot_script.sh

mv $WITCH/procedure.d/wichroot_script.sh.new $SYSPATH/bin/witchroot
chmod +x $SYSPATH/bin/witchroot
echo "chroot $SYSPATH /bin/bash /bin/witchroot"
sleep 1
chroot $SYSPATH /bin/bash /bin/witchroot

#or rather... need to get it so that the stuff in the CHEOFings, that gets put in witchroot script, gets initiated once you've chrooted...  but then, how do you tell it to execute that...   .... ah.   the issue remains. prolly better do as i said at the start of this chrootings, and get the gist of the basics from: http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ and stop freaking out over it.


code:
#! /bin/bash
##########################################
##########################################
###################       wichroot       #
##########################################
##########################################

### variables assignment - will be rewritten into a new script and that script will be sent.
DISTRONAME=placeholder
PACKAGEMGR=placeholder
METADISTRO=placeholder
ROOTDEV=placeholder

### functions here to make life easier
install_pkg() { # put the packages to be installed as a string.

  # so... what happens if the string is different? like in debian you install this but in gentoo you install that
  # as a rule of thumb choose the most generic one, then add a if statement to check for the name and install what it's supposed to be
  case "$PACKAGEMGR" in
    "portage")
      echo "Installing package $1 ..."
      emerge $1
    ;;
    "dpkg")
      echo "Installing package $1 ..."
      aptitude install $1
    ;;
  esac
}

update_pkg() {
  case "$PACKAGEMGR" in
    "portage")
      echo "updating with \"emerge --sync\" not so quietly though.  may take several minutes..."
      emerge --sync
      echo "portage is now up to date."
      sleep 1
      # add some savvy check to know if there's a new portage, n then have the script do, as the handbook says: If you are warned that a new Portage version is available and that you should update Portage, you should do it now using emerge --oneshot portage.
    ;;

    "dpkg") # little example
      echo "updating with \"aptitude update\" not so quietly though. may take several minutes..."
      aptitude update
      echo "your system is now up to date"
      sleep 1
    ;;
  esac
}

echo "creating a new environment by essentially creating environment variables, then loading those variables into memory using source."
case "$METADISTRO" in
  "GENTOO")
    echo "env-update"
    env-update
  ;;
esac

echo "source /etc/profile"
source /etc/profile
echo "export PS1='\($DISTRONAME chroot\) \$PS1'"
export PS1="\($DISTRONAME chroot\) $PS1"
sleep 1

sleep 2 && clear

echo "making sure the $PACKAGEMGR tree of $DISTRONAME is up to date..."
echo
update_pkg

sleep 2 && clear

#################################################################################
#this is the best work-around i've come up with yet to deal with passing the required variables to the chrooted environment.  it's not ideal, i know, and i'm certain there's a more elegant solution out there, but for now, this will have to do.
echo "since you're now well and truly in your newly chrooted environment, you need to set some variables again.  ~ this is an unfortunate kludge solution.  hack up, or put up. ~"
echo
echo "what is your prefered text editor? (type the name of it\'s executable as exists on host system):"
read CHEDITOR
export EDITOR="$CHEDITOR"

#mibi move it to before the portage sync'ing?
#################################################################################

sleep 2 && clear
gentoo_config() { ## GENTOO SPECIFIC
  #put profile selection into own function(s) too?  variablise and caseifthenesac it for the various bases and their variations (such as the number of profiles they offer)
  echo "First, a small definition is in place."
  sleep 1
  echo "A profile is a building block for any Gentoo system. Not only does it specify default values for USE, CFLAGS and other important variables, it also locks the system to a certain range of package versions. This is all maintained by the Gentoo developers.

Previously, such a profile was untouched by the users. However, there may be certain situations in which you may decide a profile change is necessary.

  You can see what profile you are currently using (the one with an asterisk next to it)"
  echo "with eselect profile list:"
  sleep 1
  echo
  eselect profile list

  sleep 3
  echo
  echo "pick a number of profile you would like to switch to, if any, careful not to select a number that doesnt exist.  (type letter and hit enter)"
  echo "Choose a number from 1 to 15. The default is marked with an asterick."

  read PROFILESELECT

  echo "Choice was $PROFILESELECT. doing: eselect profile set $PROFILESELECT"
  sleep 1
  eselect profile set $PROFILESELECT

  echo "you can always try changing this later, using eselect."
}

case "$METADISTRO" in
  "GENTOO")
    gentoo_config
  ;;
esac

sleep 2 && clear

######start of chroot, i added a cheditor and chbrowser bit.  so this is redundant now... i hope, since i commented it out.
###editor section to be improved
#echo "incase your chrooted environment doesnt like your editor choice from your host os you can get a new one here."
#emerge -uqv nano
#CHEDITOR=nano #FIX ME augment that shit soon
#EDITOR=nano
#echo "setting editor to $EDITOR " && sleep 1

#######
#useflags section.
#######
#may decide to break this bit up and put in a seperate function() at some point perhaps.

useflags() {
  echo "you should have already made a make.conf file, and depending on what option you picked, and what you did, you may have already configured your USE flags, if you have not, not to worry, we can do that now, or even change them later."
  echo
  echo "what would you like to do for your useflags in make.conf?"

  echo "
    m - manually edit
    d - dont care, do it for me, default it.  (warning, incomplete! overwrites!)
    w - wget from _____ (warning this will overwrite existing make.conf)
    c - copy from _____ (warning this will overwrite existing make.conf)
    v - vanilla - dont touch it!  leave as is now.
    u - use the fully commented one from /mnt/$DISTRONAME/usr/share/portage/config/make.conf (warning, this will overwrite existing make.conf)
  enter letter of preference: "
  read REPLY
  case "$REPLY" in
    m)
      $EDITOR /etc/make.conf
    ;;

    d)
      echo "looks like the make.conf default hasnt been made yet.  you will probably want to copy back from /etc/make.conf~rawvanillaoriginal or /usr/share/portage/config/make.conf or another from somewhere else, or make your own now, and maybe go to \#witchlinux on irc.freenode.net and tell digitteknohippie he forgot he left the make.conf section in such a state of disrepair."
    ;;

    w)
      echo "enter the url where your make.conf is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):"
      read MAKECONFURL
      wget $MAKECONFURL -o /etc/make.conf
    ;;

    c)
      echo "enter the location where your make.conf is located (e.g. /usr/share/portage/config/make.conf):"
      read MAKECONFLOC
      cp $MAKECONFLOC /etc/make.conf
    ;;

    v)
      echo "well that is easily done.  ... done."
    ;;

    u)
      cp /usr/share/portage/config/make.conf /etc/make.conf
    ;;
  esac

  #FIXME ^ default
}

useflags

sleep 2 && clear

locale_select() {
  #functionise these following bits too?  i presume they are all fairly universal, n not much (if any) variation between base distros.
  echo "You will probably only use one or maybe two locales on your system. You can specify locales you will need in /etc/locale.gen

e.g.

en_GB ISO-8859-1
en_GB.UTF-8 UTF-8
en_US ISO-8859-1
en_US.UTF-8 UTF-8

m - manually edit
d - dont care, do it for me, default it.  (warning, incomplete! overwrites!)
w - wget from _____ (warning this will overwrite existing locale.gen)
c - copy from _____ (warning this will overwrite existing locale.gen)
  v - vanilla - dont touch it!  leave as is now."
  read REPLY
  case "$REPLY" in
    m)
      $EDITOR /etc/locale.gen
    ;;

    d)
      echo "looks like the locale.gen default hasnt been made yet.  you will probably want to go to #witchlinux on irc.freenode.net and tell digitteknohippie he forgot he left the locale.gen section in such a state of disrepair." >> /etc/locale.gen
    ;;

    w)
      echo "enter the url where your make.conf is located:"
      read MAKECONFURL
      wget $MAKECONFURL -o /etc/locale.gen
    ;;

    c)
      echo "enter the location where your make.conf is located (e.g. /usr/share/portage/config/make.conf):"
      read MAKECONFLOC
      cp $MAKECONFLOC /etc/locale.gen
    ;;

    v)
      echo "well that is easily done.  ... done.  locale.gen as is."
    ;;
  esac

  #consider changing to "locale-gen -a" ~ see man page, and try it out. or add that as an option above.
  echo "now running locale-gen" && locale-gen
  sleep 1
}

locale_select

sleep 2 && clear

kernel() {
  #presumably  put the kernel section in a variablised functionised chunk too?   could do with some clean up of what is pre-kernel-getting and what is actually kernel-getting
  echo "now you will likely need a kernel too"
  sleep 1
  echo "lets get your timezone sorted for that..."
  echo "Look for your timezone in /usr/share/zoneinfo, then we will copy it to /etc/localtime"
  sleep 2
  echo
  ls /usr/share/zoneinfo
  echo
  read -p "enter timezone (e.g. America, GMT): " TIMEZONE

  cp /usr/share/zoneinfo/$TIMEZONE /etc/localtime

  echo "okay."
  sleep 2 && echo
  echo "The core around which all distributions are built is the Linux kernel. It is the layer between the user programs and your system hardware. Gentoo provides its users several possible kernel sources. A full listing with description is available at http://www.gentoo.org/doc/en/gentoo-kernel.xml "

  sleep 3
  #see previous comment.   kernel-getting.
  #exherbo has taught us well here... let the user choose what kernel they want.
  #grand expanding of this section, offering:
  #genkernel, debian kernels, hurd, freebsd, vanila kernel.org kernels, hurd+mach, hurd+l4, xenkernel, etc etc etc.
  # ....there-in we will see why digitteknohippie insist's it's called witch, before it's called witchlinux... the linux kernel need not even be present.  :)

  echo "so lets get on with getting you a kernel..."
  sleep 1
  # figure out a nice way to do this
  echo "how would you like to get a kernel?"
  case "$METADISTRO" in
    "GENTOO") echo "i - gentoo-sources and genkernel " ;;
    "DEBIAN") echo "i - debian repositories " ;;
  esac
  echo "m - manual (incomplete)"
  echo
  read -p "select which option: "
  case "$REPLY" in
    i) ## here you go. start making it seperate.
      case "$METADISTRO" in
        "GENTOO")
          install_pkg "genkernel gentoo-sources"
          genkernel --menuconfig all
          # symlinking starts
          ln -s /boot/kernel* /boot/vmlinuz
          ln -s /boot/initramfs* /boot/initramfs.img
        ;;
        "DEBIAN") ## ask for kernel version since debian has different kernels
          ## added as a proof of concept. fill it in later
        ;;
      esac
    ;;

    m)
      echo "woah there cowboy, how complete do you think this script is already!?  didnt we tell you this bit was incomplete.  ...you will have to sort that out entirely yourself later then.  http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=7#doc_chap3 might b handy"
    ;;
  esac

  sleep 2
  echo "- skipping kernel modules section, due to incompleteness.  see 7.e. Kernel Modules here: http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=7#doc_chap5 "
  #echo "you might want kernel modules too right?"

  # FIXME
  #
  #echo "To view all available modules"
  #
  #ls /boot/linux*
  #find /lib/modules/$KERNV/ -type f -iname '*.o' -or -iname '*.ko' | less
  ### need to get the just compiled kernel name and version extracted cleanly, to be inserted there on $KERNV
  # FIXME

  #ls -l /usr/src/linux

}

kernel

sleep 2 && clear

#put fstab section in it's own function
fstab() {
  echo "
_______What is fstab?

Under Linux, all partitions used by the system must be listed in /etc/fstab. This file contains the mount points of those partitions (where they are seen in the file system structure), how they should be mounted and with what special options (automatically or not, whether users can mount them or not, etc.)

_______Creating /etc/fstab

/etc/fstab uses a special syntax. Every line consists of six fields, separated by whitespace (space(s), tabs or a mixture). Each field has its own meaning:

The first field shows the partition described (the path to the device file). you can specify a UUID here too.
The second field shows the mount point at which the partition should be mounted
The third field shows the filesystem used by the partition
The fourth field shows the mount options used by mount when it wants to mount the partition. As every filesystem has its own mount options, you are encouraged to read the mount man page (man mount) for a full listing. Multiple mount options are comma-separated.
The fifth field is used by dump to determine if the partition needs to be dumped or not. You can generally leave this as 0 (zero).
The sixth field is used by fsck to determine the order in which filesystems should be checked if the system wasn not shut down properly. The root filesystem should have 1 while the rest should have 2 (or 0 if a filesystem check is not necessary).

---------------
so as you should already know, you configured your partitions some time ago. still remember them?

if not, open up another terminal and type in 'chroot /mnt/$DISTRONAME'.
Once you enter a new chroot environment type in 'sudo fdisk -l'

if yes, great!

  "
  echo "so lets get on with setting up your fstab"
  sleep 1
  echo "how would you like to configure your fstab?
m - manual         (opens in editor)
s - skip           (manual later)
g - guided         (warning incomplete)
  select which option:   "
  read
  case "$REPLY" in
    m)
      echo "manual editing /etc/fstab selected"
      $EDITOR /etc/fstab
    ;;

    s)
      echo "skipping..."
    ;;

    g)
      echo "silly sausage, this bit hasnt been made yet.  you can just sort out your fstab by yourself later.   fyi, this section will include a series of input choices for the various partitions/mounts."
    ;;
  esac

  # FIXME ^ inset the fstab populator bit.  && add the variable-ised root, home n boot partitions...
}

fstab

sleep 2 && clear

network() {
  ####NETWORK#### mk1

  # FIXME the whole network section could do with an overhaul and simplification and cleaning up.

  ###old first attempt at making the network section
  ###echo "whadya call this computer (what is your hostname)?
  ###- this will be set in /etc/conf.d/net"
  ###read NETNOM
  ###echo "dns_domain_lo=\"$NETNOM\"" >> /etc/conf.d/net
  ###
  ###echo "wanna use DHCP for connection? (if you dont know what that means, it is still likely you do)"
  ###echo "config_eth0=\"dhcp\"" >> /etc/conf.d/net

  # FIXME ^ add NIS section, asking first if they want it, then follow the same a above, except of course, use >> instead of > for the /et/conf.d/net http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=8

  # FIXME ^ change to a menu selection, allowing manual editing of hostname and net configs as an option, as well as "do it now" option, as above.

  # FIXME ^ net'll likely need mending, since the host and net files

  ###############
  #___#######___#
  ####NETWORK####
  #___#######___#
  ###############
  ############### mk2  (put network mk2 in own function.  network mk1 can probably be deleted now, right?
  sleep 2 && clear
  echo "you will wanna be online too right?"

  #this is probably excessive for just hostname, right?  and domain name bellow too...
  echo "what do you want to do about your hostname (in /etc/conf.d/hostname)
m - manually edit
d - dont care, do it for me, default it.  (overwrites!)
w - wget from _____ (warning this will overwrite existing /etc/conf.d/hostname)
c - copy from _____ (warning this will overwrite existing /etc/conf.d/hostname)
v - vanilla - dont touch it.  leave as is now.
  e - enter hostname now. (warning this will overwrite existing /etc/conf.d/hostname)"
  read
  case "$REPLY" in
    m)
      echo "ok, to $EDITOR /etc/conf.d/hostname"
      $EDITOR /etc/conf.d/hostname
    ;;

    d)
      echo "witchgnubox" > /etc/conf.d/hostname
    ;;

    w)
      echo "enter the url where your hostname filef is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):"
      read HOSTNOMURL
      wget $HOSTNOMURL -o /etc/conf.d/hostname
    ;;

    c)
      echo "enter the location where your hostname file is located (e.g. /mnt/myexternal/myconfigbkpoverlay/etc/conf.d/hostname):"
      read HOSTNOMLOC
      cp $HOSTNOMLOC /etc/conf.d/hostname
    ;;

    v)
      echo "well that is easily done.  ... done."
    ;;

    e)
      read -p "whadya call this computer (what is your hostname)?
- this will be set in /etc/conf.d/hostname
      ENTER HOSTNAME:" HOSTNOM
      echo "hostname=$HOSTNOM " > /etc/conf.d/hostname
    ;;
  esac

  sleep 2 && echo
  # edit this line, so that it finishes using $HOSTNOM.  would be easy if you just used last option only... but if insisting on the excessive version here, then we wikl need a clever extraction of $HOSTNOM from /etc/conf.d/hostname.  not important rly... so i am just commenting on this rather than getting it done, so it doesnt interupt my flow.
  echo "ok, so that should be your /etc/conf.d/hostname configured as it has your hostname."
  sleep 2 && echo
  # the /etc/conf.d/net is a far mroe elaborate config file than hpostname.  this is dangerously inadequate!  ... so i added the "RECCOMENDED"s, as well as the warnings already in place.
  echo "what do you want to do about your domain name (in /etc/conf.d/net)
m - RECOMMENDED: manually edit
d - dont care, do it for me, default it.  (adds ns_domain_lo=\"witchnet\")
w - wget from _____ (warning this will overwrite existing /etc/conf.d/net)
c - copy from _____ (warning this will overwrite existing /etc/conf.d/net)
v - RECOMMENDED: vanilla - dont touch it!  leave as is now.
  e - enter network name now. (warning this will overwrite existing /etc/conf.d/net)"
  read REPLY
  case "$REPLY" in
    m)
      $EDITOR /etc/conf.d/net
    ;;

    d)
      echo "ns_domain_lo=\"witchnet\"" >> /etc/conf.d/net
    ;;

    w)
      echo "enter the url where your hostname file is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):"
      read -r HOSTNOMURL
      wget $HOSTNOMURL -o /etc/conf.d/net
    ;;

    c)
      echo "enter the location where your hostname file is located (e.g. /mnt/myexternal/myconfigbkpoverlay/etc/conf.d/net):"
      read HOSTNOMLOC
      cp $HOSTNOMLOC /etc/conf.d/net
    ;;

    v)
      echo "well that is easily done.  ... done."
    ;;

    e)
      echo "whadya call this network (what is your net)?
      - this will be set in /etc/conf.d/net"
      read -p "ENTER DOMAIN NAME:" DOMNOM
      echo "ns_domain_lo=\"$DOMNOM\"" > /etc/conf.d/net
    ;;
  esac

  sleep 2 && echo

  echo "u wanna use dhcp right? y/n:  "
  read REPLY
  if [ "$REPLY" == "y" ]
  then
    echo "config_eth0=\"dhcp\"" >> /etc/conf.d/net
  fi

  echo "and u want to have networking activated at boot automatically for you, of course, right? y/n:  "
  read REPLY
  if [ "$REPLY" == "y" ]
  then
    echo
    echo "ok.. "
    sleep 2
    echo "cd /etc/init.d"
    cd /etc/init.d

    echo "ln -s net.lo net.eth0"
    ln -s net.lo net.eth0

    echo "this next bit is clever.  you should learn about rc-update.  a nice feature of gentoo."
    sleep 2
    echo "rc-update add net.eth0 default"
    rc-update add net.eth0 default
  fi

  sleep 2 && echo

  echo "If you have several network interfaces, you need to create the appropriate net.eth1, net.eth2 etc. just like you did with net.eth0."
  echo
  echo "now we inform linux about your network. in /etc/hosts"
  # FIXME obviously this needs work prior, as already commented on, to make sure these variables are set more cleanly and cleverly.
  echo "127.0.0.1 localhost" > /etc/hosts
  # see 2.9 / 2.10 for more elaborate stuff required to be set up here.  ... yes, /etc/hosts needs a more elaborate series of questions asked for it.
  echo "need to manually edit it? [y/n]"
  read
  if [ "$REPLY" == "y" ]
  then
    $EDITOR /etc/hosts
  fi

  #PCMCIA section.
  echo "do you need PCMCIA? y/n:  "
  read
  if [ "$REPLY" == "y" ]
  then
    install_pkg pcmciautils
  fi
}

network

sleep 2 && clear

##############
#___######___#
####SYSTEM####
#___######___#
##############

# http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=8#doc_chap2

echo "First we set the root password with \"passwd\""
passwd
echo "that should be your root password configured.  dont forget it, remember it."

sleep 2 && echo

echo "Gentoo uses /etc/rc.conf for general, system-wide configuration. Here comes /etc/rc.conf, enjoy all the comments in that file :) ... iz u ready for this? (y):"
read REPLY
if [ "$REPLY" == "y" ]
then
  $EDITOR /etc/rc.conf
fi

sleep 2 && clear

echo "hopefully you have got all you need, sorted in rc.conf.  if you changed your editor in rc.conf, this next bit should use it instead now."
sleep 1
echo "Gentoo uses /etc/conf.d/keymaps to handle keyboard configuration. Edit it to configure your keyboard."
sleep 2
echo "Take special care with the keymap variable. If you select the wrong keymap, you will get weird results when typing on your keyboard."
sleep 1
echo "-> do you need to change your keymap? [y/n]"
read
if [ "$REPLY" == "y" ]
then
  $EDITOR /etc/conf.d/keymaps
fi

sleep 2 && clear

echo "Gentoo uses /etc/conf.d/hwclock to set clock options. Edit it according to your needs. wanna change time? [y/n]"
read
if [ "$REPLY" == "y" ]
then
  $EDITOR /etc/conf.d/hwclock
fi
# FIXME^ that was just barely a step past sheer lazy.

sleep 2 && clear
echo "so according to what you have got now, the date is:" && date
sleep 3
echo "ok, so you should probably have your network, main config file (rc.conf), keyboard and clock configured.
now lets get tooled up with a system logger, command scheduler, and more file and network tools."
sleep 1

sleep 2 && clear

echo ""
echo "Installing Necessary System Tools"
sleep 1
#may want/need to variablise this, n have some checks of variables to know how to proceed for each base distros different stage3s
echo "Some tools are missing from the stage3 archive because several packages provide the same functionality. It is now up to you to choose which ones you want to install.

The first tool you need to decide on has to provide logging facilities for your system. Unix and Linux have an excellent history of logging capabilities -- if you want you can log everything that happens on your system in logfiles. This happens through the system logger.

Gentoo offers several system loggers to choose from. There are:
 - sysklogd, which is the traditional set of system logging daemons,
 - syslog-ng, an advanced system logger,
and metalog which is a highly-configurable system logger. Others might be available through Portage as well - our number of available packages increases on a daily basis.

If you plan on using \"sysklogd\" or \"syslog-ng\" you might want to install \"logrotate\" afterwards as those system loggers do not provide any rotation mechanism for the log files.

To install the system logger of your choice, emerge it and have it added to the default runlevel using rc-update.

choose a systemlogger to install and add to startup: "
sleep 1
echo "
a. emerge syslogd && rc-update add syslogd default
b. emerge syslog-ng && rc-update add syslog-ng default
c. emerge metalog && rc-update add metalog default
d. enter name of other system logger
e. no thnx (only if you are sure)

select a,b,c or d and press ENTER.
"
read REPLY
case $REPLY in
  a)
    install_pkg syslogd
    rc-update add syslogd default
  ;;

  b)
    install_pkg syslog-ng
    rc-update add syslog-ng default
  ;;

  c)
    install_pkg metalog
    rc-update add metalog default
  ;;

  d)
    read -p "enter name of your choice of system logger: " SYSLOGA
    install_pkg $SYSLOGA
    rc-update add $SYSLOGA default   #add a sort of failsafe, so that if the emerge fails because no such package exists, user can then choose a,b,c,d or e again.  ~ yes, see this is an example where putting this into functions makes sense.  ...but i will carry on with this rudimentary version for now.
  ;;
esac

sleep 2 && clear

#put crons into function(s) too
echo "now on to command schedulers, a.k.a. cron daemons."

echo "Although it is optional and not required for your system, it is wise to install one. But what is a cron daemon? A cron daemon executes scheduled commands. It is very handy if you need to execute some command regularly (for instance daily, weekly or monthly).

Gentoo offers three possible cron daemons:
 - vixie-cron
 - dcron
 - fcron

If you do not know what to choose, use vixie-cron."

echo "which cron daemon do you want?
a. emerge vixie-cron && rc-update add vixie-cron default
b. emerge dcron && rc-update add dcron default && crontab /etc/crontab
c. emerge fcron && rc-update add fcron default && crontab /etc/crontab
d. enter name of other cron
e. no cron (r u sure?)"
read
case "$REPLY" in
  a)
    install_pkg vixie-cron
    rc-update add vixie-cron default
  ;;

  b)
    install_pkg dcron
    rc-update add dcron default
    crontab /etc/crontab
  ;;

  c)
    install_pkg fcron
    rc-update add fcron default
    crontab /etc/crontab
  ;;

  d)
    read -p  "enter name of your choice of cron: " CRONNER
    install_pkg $CRONNER
    rc-update add $CRONNER default
    crontab /etc/crontab   #add a sort of failsafe, so that if the emerge fails because no such package exists, user can then choose a,b,c,d or e again.  ~ yes, see this is an example where putting this into functions makes sense.  ...but i will carry on with this rudimentary version for now.
  ;;
esac

sleep 2 && clear

#functionise
echo "If you want to index your files so you are able to quickly locate them using the locate tool, you need to install sys-apps/mlocate.
do you want locate? [y/n]"
read
if [ "$REPLY" == "y" ]
then
  install_pkg mlocate
fi

sleep 2 && clear

#functionise
#re-write to add automation and other options?
echo "will you need dhcp or ppp?
d. dhcp
p. ppp
b. both
q. neither
"
read

case "$REPLY" in
  d) install_pkg dhcp ;;
  p) install_pkg ppp ;;
  b) install_pkg "dhcp ppp" ;;
esac

sleep 2 && clear

#oh rly, not even gonna give them a choice?  there is far more than just one.  :P  ;)  FIX ME... and functionise.   bootloader section could pretty much do with a whole rewrite.
#give them syslinux too. it's a nice bootloader. maybe lilo.
echo "Now that your kernel is configured and compiled and the necessary system configuration files are filled in correctly, it is time to install a program that will fire up your kernel when you start the system. Such a program is called a bootloader."
sleep 2
echo "so, do you want your bootloader to be on a current existing system? if not, we'll put the bootloader into your witch. [y/n]"
read REPLY

if [ $REPLY == "y" ]
then
  echo "okay."
  sleep 1
  echo "this section is still incomplete, sorry. hack it up :D"
  # chroot into the main drive (hackish method). then configure the current bootloader there.
  # for syslinux you need to install to the witch too.

  # and to make sure i don't forget
  # copy chain.c32 over to /boot/extlinux/
  # then type this out:
  # label witchname - metadistro
  # kernel /boot/extlinux/chain.c32
  # append hd0 1
  #  hd0 -> xth drive. like sda would be hd0, sdb would be hd1 and etc.
  #  1 -> partition 1. like /sda1 and /sdb1

  # that should clear things up.
  echo "i guess you should check out the file 'wichroot.sh' in 'procedure.d' and look at line 759 to 777 :D and figure out things on your own"
else
  echo "note, this section is just minimally done, very basic.  you will no doubt want to manually configure your boot loader properly.  here, we are just auto-populating it with a basic configuration which will most likely be unsuitable for anything but the most basic of partition configurations with a single boot (no \"dual boot\" or \"multi boot\"."
  echo "read more at http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10"

  echo "so which bootloader do you want?"
  echo "g - grub (grub grub grub)"
  echo "s - good old syslinux"
  read BOOTLOADER

  case $BOOTLOADER in
    g)
      echo "so you want grub."

      echo "installing grub in a moment. we'll install ncurses first."
      sleep 2
      install_pkg grub

      echo "a backup is created at /boot/grub/grub.conf.bk~"
      cp /boot/grub/grub.conf /boot/grub/grub.conf.bk~
      # note to self, find out a way to add incremental numberings to such copyings, so backups can be non-destructive.  you know like, ~if file exists then~
      echo "copied backup of any existing grub.conf to /boot/grub/grub.conf~origbkp"
      sleep 2
      echo "
        default 0
        timeout 30
        splashimage=(hd0,0)/boot/grub/splash.xpm.gz

        title=$DISTRONAME - $METADISTRO
        root (hd0,0)
        kernel /boot/kernel-2.6.12-gentoo-r10 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/$ROOTDEV udev
        initrd /boot/initramfs-genkernel-amd64-2.6.12-gentoo-r10

        # Only in case you want to dual-boot
        title=Windows XP
        rootnoverify (hd0,5)
        makeactive
      chainloader +1" > /boot/grub/grub.conf
    ;;
  esac
fi

# tee that^ so the folks can see what you mean by:
sleep 1
echo "as an interim kluge until you hack up something better, some crap has been thrown in your bootloader section. so you will want to find out what your kernel and initrd are called and what bootloader kernel options you want passed to it, and edit those in apropriately."
sleep 2

# ^ make a seditor to convert sda1 to (hd0,0) and so on. then use $ROOTDEV seditor'd to create GRUBDEV, and use $GRUBDEV in "root (hd0,0)" as "root $GRUBDEV" instead.
# use either something like uname -r or a clever ls /boot, to determine the kernel and define it as a variable (or use clever brackets n shiz) to use in place of initrd /boot/initramfs-genkernel-amd64-2.6.12-gentoo-r10
# yes basically i've done a cop-out for this section.  i am become lazyness.  lol.
# FIX ME ... FIX ME  ... FIX MEEEEE.   that boot section needs a serious re-work... lazy ass ....  wtf.

echo "job done. your base system is installed.  now lets make it a witch. :)"

#one very important final thought:
exit
# ;D  see, that was rather important, right?  ^_^

##########################################
##########################################
###################       wichroot       #
##########################################
##########################################
####       the wichroot fits into
####                 the here-CHEOF like i
####                 mentioned whenst echo
####                 "ENTER THE CHROOT" as
####                 this^^^ is just to be
####                 able to use some more
####                 syntax highlighting!!
##########################################
########################################## ok. did that... shud b ok, from _cheof_ to _cheof_  ... but now, we need to get all the variables passed into the chroot system too.
##########################################  .... uhhh check the CHEOF (the chroot EOF "here" command)... isnt it missing something?


code:
############
#############
# driveprep
# GLOBAL needs no change.

echo "======================"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
echo "Distro name: $DISTRONAME"
INTERVENE=$(sed -n '4p' $WITCH/config.txt)
echo "Intervene? $INTERVENE"
echo "======================"

#this is the partition preparation function.  calls of it  aught imediately preceed the stageinstall function

show_disk() {
  sleep 1
  echo
  $WITCH/color.sh GREEN "here's a nice little list of your drives."
  fdisk -l
  echo
}

create_mnt() {
  if [ ! -d /mnt/$a ]
  then
    mkdir /mnt
  fi

  echo "your new OS installation / distro name is $DISTRONAME (this will make a directory of that name in /mnt/___.):"
  if [ ! -d /mnt/$DISTRONAME/$a ]
  then
    mkdir /mnt/$DISTRONAME
  fi

  cd /mnt/$DISTRONAME
}

partition() {
  echo "do you need to partition? creating your partition for your own little witch. (y/n) :"
  read REPLY
  if [ "$REPLY" == "y" ]
  then
    $WITCH/procedure.d/partmanselector.sh #calls the partition manager selection function "partmanselector"
  elif [ "$REPLY" == "n" ]
  then
    echo "ok, ready to go so..."
  fi
}

error() { # first parameter is error message, second is fuction to execute
  $WITCH/color.sh ERROR "$1"
  "$2"
}

rootdir() {
  echo "where ya putting your root dir? (e.g. sda3) - (NOT /root, we mean /):"
  read -r ROOTDEV
  echo $ROOTDEV >> $WITCH/config.base.txt # a late 5th line :P

  if [ $INTERVENE == "y" ]
  then
    echo "we're going to mount /dev/$ROOTDEV to /mnt/$DISTRONAME. want a different location? [y/n]"
    read REPLY
    if [ $REPLY == "y" ]
    then
      echo "okay, type in your wanted location."
      read LOCATION
      mount /dev/$ROOTDEV $LOCATION || error "something went wrong. try again" rootdir
    else
      echo "okay."
      sleep 1
      mount /dev/$ROOTDEV /mnt/$DISTRONAME || error "something went wrong. try again" rootdir
    fi
  else
    mount /dev/$ROOTDEV /mnt/$DISTRONAME || error "something went wrong. try again" rootdir
  fi
}

boot() {
  echo "you want a separate boot right? [y/n]:"
  read
  if [ "$REPLY" == "y" ]
  then
    if [ ! -d /mnt/$DISTRONAME/boot/$a ]
    then
      mkdir /mnt/$DISTRONAME/boot
    fi

    echo "where ya putting your boot dir? (e.g. sda1):"
    read -r BOOTDEV
    mount /dev/$BOOTDEV /mnt/$DISTRONAME/boot || error "something went wrong. try again" boot

  fi
  # i wonder, if you can do "if $REPLY=y then else fi" or something like that.
}

home() {
  echo "you want a separate home too? (y):"
  read

  if [ "$REPLY" == "n" ]
  then
    echo "ok your home partition will just be lumped in with root, like the stupid people use."
  elif [ "$REPLY" == "y" ]
  then
    if [ ! -d /mnt/$DISTRONAME/home/$a ]
    then
      mkdir /mnt/$DISTRONAME/home
    fi

    echo "where ya putting your home dir? (e.g. sda1):"
    read -r HOMEDEV
    mount /dev/$HOMEDEV /mnt/$DISTRONAME/home || error "something went wrong. try again" home
  else
    home
  fi
}

dimg_script() {
  mkdir $WITCH/sys
  mkdir $WITCH/sys/$DISTRONAME
}

# start of execution of methods
if [ "$DIMG_RUN" == "true" ]; then
  dimg_script
else
  show_disk
  create_mnt
  partition
  rootdir
  boot
  home
fi

sleep 1


code:
############
############
# initialmakeconf
# Gentoo's make.conf is in /etc/portage/ and not in /etc/

echo "======================"
EDITOR=$(sed -n '1p' $WITCH/config.txt)
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
echo "Editor: $EDITOR"
echo "(base) Distro name: $DISTRONAME"
METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
echo "METADISTRO: $METADISTRO"
echo "======================"

###### ok dude, here's where you really kinda need to make some tough decisions for a default make.conf, and also make options, and manual make.conf editing.  ... n seriously, some sembelence of a default for rowan witch, would make sense.

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=$/mnt/$DISTRONAME
fi

## here goes. the variable selection based on different distros
LOCATION="$SYSPATH/etc/make.conf"
case "$METADISTRO" in
  "GENTOO") LOCATION="$SYSPATH/etc/portage/make.conf" ;; # look at http://www.gossamer-threads.com/lists/gentoo/dev/259544
esac

# being a nice guy, i'll create a symbolic link for them.
if [ "$LOCATION" != "$SYSPATH/etc/make.conf" ]
then
  echo "since your make.conf is in $LOCATION and not $SYSPATH/etc/make.conf we'll create a symbolic link for you."
  ln -s $LOCATION $SYSPATH/etc/make.conf
fi

#backup the original one.
BACKUP=${LOCATION}.bk~
if [ -f ${LOCATION}.bk~ ]
then
  BACKUP=${LOCATION}.newbk~
  cp $LOCATION ${LOCATION}.newbk~
else
  cp $LOCATION $BACKUP
fi

echo "made backup make.conf"
echo "the backup is at: $BACKUP"
sleep 1

#put make.conf configuring in own function section too, utilising variables for different bases (gentoo, exherbo, etc)
echo "for help with this, refer to chapter 5c of the gentoo handbook
http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=5#doc_chap3"
$WITCH/color.sh QUESTION "how do you wanna handle configuring your make.conf file? (or rather, your $LOCATION file, since it might be different)"
$WITCH/color.sh GREEN "
m - manually edit
d - dont care, do it for me, default it.   (warning, incomplete! overwrites!)
w - wget from _____
c - copy from _____
v - vanilla - dont touch it!
u - use the fully commented one from $SYSPATH/usr/share/portage/config/make.conf
r - restore your backup"
read
case "$REPLY" in
  m)
    $EDITOR $LOCATION
  ;;

  d)
    echo "looks like the make.conf default hasnt been made yet.  you will probably want to copy back from $SYSPATH/etc/make.conf~rawvanillaoriginal or $SYSPATH/etc/make.conf~wtfanewbackup $SYSPATH/usr/share/portage/config/make.conf or another from somewhere else, or make your own now, and maybe go to #witchlinux on irc.freenode.net and tell digitteknohippie he forgot he left the make.conf section in such a state of disrepair." | tee $LOCATION
  ;;

  w)
    echo "enter the url where your make.conf is located:"
    read MAKECONFURL
    wget $MAKECONFURL -o $LOCATION
  ;;

  c)
    echo "enter the location where your make.conf is located (e.g. $SYSPATH/usr/share/portage/config/make.conf):"
    read MAKECONFLOC
    cp $MAKECONFLOC $LOCATION
  ;;

  v)
    echo "well that is easily done.  ... done."
  ;;

  u)
    echo "here goes"
    echo "cp $SYSPATH/usr/share/portage/config/make.conf $LOCATION"
    cp $SYSPATH/usr/share/portage/config/make.conf $LOCATION
  ;;

  r)
    echo "so you want to restore your backup?"
    cp $BACKUP $LOCATION
  ;;
esac

gentoo_config() {
  $WITCH/color.sh QUESTION "not finished with your make.conf yet.  wanna pick a fast portage-mirror? "
  $WITCH/color.sh GREEN "
    m - manually edit
    d - choose near mirror(s) with mirrorselect. [recommended]
  v - vanilla - dont touch it."
  read REPLY

  case $REPLY in
    m)
      echo "forget to do that first time?"
      $EDITOR $SYSPATH/etc/make.conf
    ;;
    d)
      echo "now we cleverly do: mirrorselect -i -o >> $SYSPATH/etc/make.conf"
      mirrorselect -i -o >> $SYSPATH/etc/make.conf
    ;;
    v)
      echo "well that is easily done.  ... done."
    ;;
  esac
}

if [ "$METADISTRO" == "GENTOO" ]; then
  gentoo_config
fi

#might this chunk aught be looped? so multiple checks can be done after edits?  or is that just silly?
#no, it is silly as it is now.
echo "look at this and make sure it looks right. press 'q' to exit. press enter when you're ready."
read enter
less $LOCATION
$WITCH/color.sh QUESTION "does that look right? (y/n)"
read

if [ "$REPLY" == "n" ]; then
  echo "fix it then:"
  sleep 1
  $EDITOR $LOCATION
fi

#remove this line if the above suggested looping gets made
echo "well if it is not sorted as you want, you can always tweak it later when we're in the chroot system."
#might wanna consider making that able to be called any time (or at least specific non-borky times)
sleep 1


code:
# Needs some changes. METADISTRO has been included for usage.
# REQUIRES FIXING

echo "======================"
BROWSER=$(sed -n '2p' $WITCH/config.txt)
PROX=$(sed -n '3p' $WITCH/config.txt)
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
PACKAGEMGR=$(sed -n '4p' $WITCH/config.base.txt)
echo "Browser: $BROWSER"
echo "Proxy: $PROX"
echo "Package manager: $PACKAGEMGR"
echo "Distro name: $DISTRONAME"

METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
echo "Metadistro: $METADISTRO"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

function howdlpkg {
  echo
  $WITCH/color.sh QUESTION "how would you like to fetch your package manager"
  echo
  $WITCH/color.sh GREEN "
        A.    get it same way as in gentoo handbook (instructive)
        B.    enter a direct URL to the package manager (INCOMPLETE)
        C.    enter a location in the file system (already have downloaded)(INCOMPLETE)
  D.    already extracted"

  read Stage3dlmethod
  case $Stage3dlmethod in
    A|a)
      echo "$Stage3dlmethod was selected."
      sleep 1
      browserpkg
    ;;

    B|b)
      echo "$Stage3dlmethod was selected."
      sleep 4
      urlpkg
    ;;

    C|c)
      echo "$Stage3dlmethod was selected."
      sleep 4
      locpkg
    ;;

    D|d)
      echo "Proceeding..."
      sleep 2
    ;;
  esac
}

# as with stage download above, this needs to be put in a more automated and option-able method.  likely using "case - esac" or using earlier defined packagemanager choice.  ... so likely will warrant a refunctionising, creating a separate installportage and installpaludis, and... other?
# also, variablise it to be basedistro-savvy, so sensible defaults can be chosen, if ya like.
#read -p "that is as much as we can do for that now.  are you enjoying this so far?"
#[ "$REPLY" == "y" ] echo "well good then.  now we\'ll carry on getting your package manager too" && sleep 2

# Let's make this automated first, then we can unify it easily with case statements.

function browserpkg {
  echo "Now that the stage is installed, we continue to installing your package manager.  READ CAREFULLY:"
  sleep 2
  echo "Press y to use \" $BROWSER \" to navigate http://www.gentoo.org/main/en/mirrors2.xml to the snapshots directory in a mirror close to you.
  in /snapshots/, download the latest Portage snapshot (portage-latest.tar.bz2 NOT portage-latest.tar.xz) by selecting it and pressing D. When it finishes downloading, exit the browser by pressing q."
  #we'll add ability to use any format later.  or maybe ye who is reading this can. :P
  $WITCH/color.sh YELLOW "make sure it's in the $SYSPATH path"
  echo ""
  $WITCH/color.sh QUESTION "ready to download your portage (y - yes) (p - yes, with proxy support)"
  read

  case $REPLY in
    y|Y)
      $BROWSER http://www.gentoo.org/main/en/mirrors.xml
      $WITCH/color.sh QUESTION  "ready to continue? (y)"
      read REPLY
      if [ "$REPLY" == "y" ]; then
        echo "proceeding"
        echo "so what's your package manager filename? (e.g. portage-latest.tar.bz2)"
        read FILENAME
        if [ -f $SYSPATH/$FILENAME ]
        then
          echo "excellent you seem to have got your package manager downloaded successfully."
          extractpkg $SYSPATH/$FILENAME
        else
          echo "sorry, it didnt seem like you got a package manager then... er... wtf do we do now?  carry on n presume it\'s there?  give up and run away crying? try again?  well, it\'s up to you."
          sleep 2
          $WITCH/cauldren.sh
        fi
      fi
    ;;
    p|P)
      $BROWSER -http-proxy $PROX http://www.gentoo.org/main/en/mirrors.xml
      read -p "ready to continue? (y):"
      if [ "$REPLY" == "y" ]; then
        echo "proceeding"
        echo "so what's your package manager filename?"
        read FILENAME
        if [ -f $SYSPATH/$FILENAME ]; then
          echo "excellent you seem to have got your package manager downloaded successfully."
          sleep 2
          extractpkg $SYSPATH/$FILENAME
        else
          echo "sorry, it didnt seem like you got a package manager then... er... wtf do we do now?  carry on n presume it\'s there?  give up and run away crying? try again?  well, it\'s up to you."
          sleep 2
          $WITCH/cauldren.sh
        fi
      fi
    ;;
  esac

  #sort this bit out FIXME
  #md5sum -c portage-latest.tar.bz2.md5sum
}

function urlpkg {
  echo "where are you getting your package manager compressed-tarball from? what's the exact url?"
  read PKGURL
  cd $SYSPATH/usr
  wget $PKGURL
  extractpkg $PKGURL
}

function locpkg {
  echo "where is your package manager compressed-tarball located at? what's the exact file path adress?"
  read PKGLOC
  extractpkg $PKGLOC
}

function extractpkg {
  echo "unpacking your stage3 ($FILE) to $SYSPATH/usr/. this may take some time, please wait."
  echo "extracting $1 to $SYSPATH/usr/"
  tar xvf $1 -C $SYSPATH/usr
}

howdlpkg


code:
##########
##########
## partman
## GLOBAL needs no changes

function partman {
  echo "once you have partitioned your hard drive satasfactorilly, exit the partition manager, and the script will continue."
  $WITCH/color.sh QUESTION "which partition manager do you want to use?"
  $WITCH/color.sh GREEN "
    A.    fdisk
    B.    gparted
  C.    enter your own preference of partition manager"

  read PARTITIONER

  case $PARTITIONER in
    A|a)
      echo "Choice was $PARTITIONER. launching..."
      sleep 5
      fdisk
      echo "okies, i\'m still working on the bit for creating file systems after using fdisk."
    ;;
    B|b)
      echo "Choice was $PARTITIONER. launching..."
      sleep 5
      gparted
    ;;
    C|c)
      echo "Choice was $PARTITIONER. "
      echo "enter name of your prefered partition manager" && read -r PARTMANSEL
      $PARTMANSEL
    ;;
    *)
      echo "Valid Choices are A,B,C, try again."
      partman
    ;;
  esac

  echo "partitioning complete"
}

partman


code:
########
########
## chroot
## GLOBAL needs no changes

echo "======================"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
echo "Distro name: $DISTRONAME"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

#put prechroot and wichroot sections in a function too.
#variable-ise this to accomodate differences between systems
echo " copying your net connection dns stuffs to your $DISTRONAME with
\"cp -L /etc/resolv.conf $SYSPATH/etc/resolv.conf\""
cp -L /etc/resolv.conf $SYSPATH/etc/resolv.conf
sleep 2
echo "TO THE CHROOT"
sleep 1
echo "In a few moments, we will change the Linux root towards the new location. To make sure that the new environment works properly, we need to make certain file systems available there as
well."
sleep 7
echo "you should be running this from a clean non-borked system (systemrescuecd is a good choice), if not... pray."
sleep 3

echo "mount -t proc none $SYSPATH/proc"
mount -t proc none $SYSPATH/proc
sleep 1
echo "mount --rbind /sys $SYSPATH/sys"
mount --rbind /sys $SYSPATH/sys
sleep 1
echo "mount --rbind /dev $SYSPATH/dev"
mount --rbind /dev $SYSPATH/dev
sleep 1


code:
echo "======================"
BROWSER=$(sed -n '2p' $WITCH/config.txt)
PROX=$(sed -n '3p' $WITCH/config.txt)
echo "Browser: $BROWSER"
echo "Proxy: $PROX"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
ARCH=$(sed -n '3p' $WITCH/config.base.txt)
echo "Distroname: $DISTRONAME"
echo "Arch: $ARCH"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

#############
#############
# stageinstall
# Needs some changes. METADISTRO has been included for usage.

#copied from digit's witchnotes.
#change the browser bit.  at least extend the explanation, or re-word to something like, "download the .tar.bz2 stage3 file apropriate for your architechture, to $SYSPATH/" and then add a "are you ready to proceed? (have you got the stage3 in your distro-to-be's root dir?)" and perhaps even altering it, since i already have a check in place, change what happens upon that check failing, so that it gives the user time to arrange that to make sure it is there... perhaps even advising/educating on ways to do that (like explaining how with tty n wget or cp etc).

function howdlstage3 {
  echo
  $WITCH/color.sh QUESTION "how would you like to fetch your stage3"
  echo
  $WITCH/color.sh GREEN "
    A.  get it same way as in gentoo handbook (instructive)
    B.  enter a direct URL to the stage3 (INCOMPLETE)
    C.  enter a location in the file system (already have downloaded)(INCOMPLETE)
  D.  already extracted"

  read Stage3dlmethod
  case $Stage3dlmethod in
    A|a)
      echo "$Stage3dlmethod was selected."
      sleep 1
      browserstage3
    ;;

    B|b)
      echo "$Stage3dlmethod was selected."
      sleep 4
      urlstage3
    ;;

    C|c)
      echo "$Stage3dlmethod was selected."
      sleep 4
      locstage3
    ;;

    D|d)
      echo "Proceeding..."
      sleep 2
    ;;
  esac
}

function browserstage3 {
  echo "witchcraft will use browsers to download vital parts (and less vital parts too)"
  sleep 1
  echo "ok"
  sleep 1

  #get links n lynx variablised, so can then have either used throughout with ease (y'know, so like later on it'd be just $TXTBROWSER insteada links, and TXTBROWSER would be referenced to either links or lynx, like so:
  #TXTBROWSER=hash links 2>&- || { echo >&2 "links is not installed.  how about lynx..."; lynx 1; }
  #echo "what is your prefered text webbrowser?" && read -r TXTBROWSER
  #   ... i think.  anyways, i'll not implement (uncomment) that just yet.  it'd mean making the appropriate changes bellow too.

  #variablise to denote any special needs per specific stages (such as the differences between exherbo and gentoo stages.)
  echo "READ INSTRUCTIONS CAREFULLY ~"

  echo "here you need to extract a stage3 compressed tarball to $SYSPATH"
  echo "once you\'ve read these instructions, press y (and enter) to use \"$BROWSER\" web browser to navigate http://www.gentoo.org/main/en/mirrors2.xml to download your stage3 tarball for the base system."
  echo ""
  echo "Once the page loads and you\'ve found a nearby mirror, navigate to the ** releases/$ARCH/autobuilds/ ** directory. There you should see all available stage files for your architecture (they might be stored within subdirectories named after the individual subarchitectures).  download the tar.bz2, not a tar.xz" #we'll add ability to use any format later.  or maybe ye who is reading this can. :P
  echo "If you're using a text browser: Select one and press D to download. Otherwise, download however you wish."
  echo ""
  echo "This may take some time. When it has finished, quit the browser (press q in links browser) (or just close the tab) and the rest of this script will resume."
  $WITCH/color.sh YELLOW "make sure it's in the $SYSPATH path."
  echo ""
  $WITCH/color.sh GREEN "ready to follow those instructions? (y - yes) (p - yes, with proxy support ~ may not work)"
  read

  # appears that to automate it
  # use netstat + wget
  # will do that in another option for downloading stage3.

  case $REPLY in
  y)
    $BROWSER http://www.gentoo.org/main/en/mirrors2.xml || $WITCH/color.sh ERROR "hmm things don't seem to have worked. open up your browser yourself, navigate to http://www.gentoo.org/main/en/mirrors2.xml and download to the witch directory at $SYSPATH"
    read -p "ready to continue? (y):"

    if [ "$REPLY" == "y" ]; then
      echo "proceeding"
      echo "so what's your stage3 filename?"
      read FILENAME
      if [ -f $SYSPATH/$FILENAME ]; then
        echo "excellent you seem to have got your stage3 downloaded successfully."
        extractstage3 $SYSPATH/$FILENAME
      else
        echo "looks like you didn't manage to download your stage3 successfully."
        echo "in a couple of seconds we'll rerun this function."
        sleep 3
        browserstage3
      fi
    fi
  ;;

  p)
        $BROWSER -http-proxy $PROX http://www.gentoo.org/main/en/mirrors.xml || $WITCH/color.sh ERROR "hmm things don't seem to have worked. open up your browser yourself, navigate to http://www.gentoo.org/main/en/mirrors2.xml and download to the witch directory at $SYSPATH"
    read -p "ready to continue? (y):"
    if [ "$REPLY" == "y" ]; then
      echo "proceeding"
      echo "so what's your stage3 filename?"
      read FILENAME
      if [ -f $SYSPATH/$FILENAME ]; then
        echo "excellent you seem to have got your stage3 downloaded successfully."
        sleep 2
        extractstage3 $SYSPATH/$FILENAME
      else
        echo "looks like you didn't manage to download your stage3 successfully."
        echo "in a couple of seconds we'll rerun this function."
        sleep 3
        browserstage3
      fi
    fi
  ;;

  n) exit ;;
  esac
}

function urlstage3 {
  echo "where are you getting your stage3 compressed-tarball from? what's the exact url?"
  read STAGE3URL
  cd $SYSPATH
  wget $STAGE3URL
  extractstage3 $STAGE3URL
}

function locstage3 {
  echo "where is your stage3 compressed-tarball located at? what's the exact file path adress?"
  read STAGE3LOC
  extractstage3 $STAGE3LOC
}

function extractstage3 {
  #set this so user can choose if they want verbose output
  echo "unpacking your stage3 ($FILE) to $SYSPATH. this may take some time, please wait."
  echo "extracting $1 to $SYSPATH"
  tar xvf $1 -C $SYSPATH
}

#script starts here.
sleep 1
echo

howdlstage3


code:
############
############
# wichroot
# Needs some changes. METADISTRO has been included for usage.
# Oh, and refactor it to make it easier to unify. Only some sections require change.

echo "======================"
DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
PACKAGEMGR=$(sed -n '4p' $WITCH/config.base.txt)
echo "Distro name: $DISTRONAME"
echo "PACKAGEMGR: $PACKAGEMGR"

METADISTRO=$(sed -n '2p' $WITCH/config.base.txt)
echo "Metadistro: $METADISTRO"

ROOTDEV=$(sed -n '5p' $WITCH/config.base.txt)
echo "Root filesystem location: $ROOTDEV"
echo "======================"

if [ $DIMG_RUN == "true" ]; then
  SYSPATH=$WITCH/sys/$DISTRONAME
else
  SYSPATH=/mnt/$DISTRONAME
fi

################### wichroot likely needs an end bit to de-chroot, to make the rest of the script run. !!!!!!!!!!!!!!!!

echo "ENTER THE CHROOT" # http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ <- will tell you how... at least the basics of it.  this still likely means packaging up the rest of the installer for the chrooted half, into a cat-eof'd && chmod+x'd script just prior to the chroot, and then running that.
sleep 1

# clear the file
echo > $WITCH/procedure.d/wichroot_script.sh.new

while read line
do
  if [[ -n "$line" ]]; then
    if [[ "$(echo $line | grep 'DISTRONAME=placeholder')" == "$line" ]]; then
      # check if line is DISTRONAME=placeholder --> normal string equality check does not work
      line="DISTRONAME=$DISTRONAME"
    fi

    if [[ "$(echo $line | grep 'PACKAGEMGR=placeholder')" == "$line" ]]; then # etc...
      line="PACKAGEMGR=$PACKAGEMGR"
    fi

    if [[ "$(echo $line | grep 'METADISTRO=placeholder')" == "$line" ]]; then
      line="METADISTRO=$METADISTRO"
    fi

    if [[ "$(echo $line | grep 'ROOTDEV=placeholder')" == "$line" ]]; then
      line="ROOTDEV=$ROOTDEV"
    fi
  fi
  echo "$line" >> $WITCH/procedure.d/wichroot_script.sh.new

done < $WITCH/procedure.d/wichroot_script.sh

mv $WITCH/procedure.d/wichroot_script.sh.new $SYSPATH/bin/witchroot
chmod +x $SYSPATH/bin/witchroot
echo "chroot $SYSPATH /bin/bash /bin/witchroot"
sleep 1
chroot $SYSPATH /bin/bash /bin/witchroot

#or rather... need to get it so that the stuff in the CHEOFings, that gets put in witchroot script, gets initiated once you've chrooted...  but then, how do you tell it to execute that...   .... ah.   the issue remains. prolly better do as i said at the start of this chrootings, and get the gist of the basics from: http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ and stop freaking out over it.


code:
#! /bin/sh
echo "this is only a stub"
echo "the plan for this script called reformation:

 \"a monolithic config stylee thing\"

elaboration:

like an extension of wei2912's refactor-necessitated variable saving to a file.  such that \"witches\" could even just be one config script.

(i'm sure this idea was banded around often, but now there's at least this stub"
echo "..."
# variables format suitable for plain sh parsing.
# easy, human readable and comprehendable.
# defines any/all of base, packages, configs, sources, etc
# remains addaptive addaptive addaptive, open for other user tweakings.
# foss of course.  gnu gpl.


code:
##########
##########
##########
##########
#### rewic
##########
##########
##########
##########

#insert rewic here, once it's sorted out

# NOTE! this function in the script WAS (now removed) a franken-disection-hackage gutted from tazlitoforwitchcraftextractions, which is just a copy of the earliest tazlito to have write-iso included.  it still needs much re-reading n hackage to get to work, especially across all gentoo-esq (and other) distros.    ... so i just completely removed it for now.  i think it was 1.3... er... or 2.1  or..   sometime around there it got the writeiso feature.
#all tazlito changed to rewic, and all slitaz changed to witch.  ;)  just so you know.

###  let the hacking commence!
#removed... ...devomer#

#might wanna consider nabbing some ideas from debian-live-helper and the linux-live scripts famed from the slackers.
#but tazlito's remasterer is rather the tits, so if we could get it to work instead, it'd be... " the tits "
function rewicwitchhunt {
  echo "ADD STUFF HERE, SCRIPT INCOMPLETE.  STUB. here we go hunting for pre-made isos.  more witches to burn!"
  witchhunt.sh
}
function rewicdd {

  echo "here we just dd'up wherever you choose, to wherever you choose.
      ~ though be advised, dd is:
          very low level
          takes long time
          waste a lot of space!"
 sleep 1
 echo "warning!  this method uses dd, aka data-destroyer (due to people not respecting its power).  proceed with caution, there is no going back if you wipe your drive by accident with dd"
 echo "what do you want copied? (enter location of what you want copied)
e.g.:/dev/sdb1"
 read -r WHATDD
 echo "will use $WHATDD as the input to the dd command."

 echo "where do you want it copied to? (please type full path, include filename and extension)
e.g.:/media/chuckdrive/lemule-slack-witch-alpha1.iso"
 read -r LOCDD
 echo "will use $LOCD as the location dd will output to."

 sleep 2
 echo "again, the warning, please make absolute certain, that this is the right way around.

will now proceed to issue this command:

  dd if=$WHATDD of=$LOCDD

if that looks wrong, do not proceed."
 sleep 2
 echo "ok to proceed? (Y/N):"
 read
 read REPLY
   if [ "$REPLY" == "y" ]
     then
       dd if=$WHATDD of=$LOCDD
     else
       rewicmenu
   fi

#should likely rearrange that to ask people to make sure it's right at least three times. ;)

}

function rewictar {
echo "sry this has nothing coded yet, easy enough to do though right, come join the hackup in #witchlinux on irc freenode net"
}

function rewiclinuxlive {
echo "sorry, nothing scripted in for this section yet.  come join the hackup in #witchlinux on irc freenode net.  also, of course, have a look at: http://www.linux-live.org/ "
}

function rewicmenu {

  echo "how u wanna do this?"

  echo "
    A.    dd (use with caution)
    B.    tar (with exclude list if you want)
    C.    linux-live scripts
    D.    tazlito
    E.
    F.    enter your own preference of remaster manager"

  read REWICMETHOD

  case $REWICMETHOD in
    A|a)
      echo "Choice was $REWICMETHOD.  dd"
      rewicdd
    ;;
    B|b)
      echo "Choice was $REWICMETHOD.  tar"
      sleep 1
      rewictar
    ;;
    C|c)
      echo "Choice was $REWICMETHOD.  linux live"
      sleep 1
      rewiclinuxlive
    ;;
    D|d)
      echo "Choice was $REWICMETHOD.  tazlito"
      sleep 1
      rewic
    ;;
    # was gonna add mores... but i'm lazy... and it's not like any are implemented yet.
    E|e)
      echo "ok, taking you to find one we made earlier... let the witch hunt commence."
      sleep 1
      rewicwitchhunt
    ;;
    F|f)
      echo "going back"
      sleep 1
      rewic
    ;;
  esac
}

function rewic {
  echo "rewic, the iso remastery stuff has been gutted from this version while we work out the installer stuff ~ no loss it didnt work yet anyway."

  echo "we strongly urge you to have a look through https://github.com/Digit/witch/issues/5 and in particular, the links in the first comment, which are a collection of resources to point the ways we could go about remastering."

  rewicmenu
}

rewic


code:
#! /bin/bash
#written by digit (+ the community).  most ambitious project yet. see http://github.com/Digit/witch for more

clear #neatness freak

### dont be bothered if the comments seem outta wack, they are.  ...need to go clean that up some more still.
# will remove this guff when the comments n shiz r cleaned up of those redundant or irelevent or outdated or just guff...

#version (probably gonna keep version as "concept v0.00" until it's at least ready for a trial run.
echo "VERSION: gentoo install test v0.00 " #oldversion#echo "VERSION: concept v0.00"
echo "(means dont try to run it yet, for the sake of your computer.  retreat while you can.)"

##dev-intro
#for sake of navigation, check out the functions: rewic, cauldren (and it's functions), distroselector, deskfigselector.  they're all launched in a tree of options, starting at the end of this script, after all the functions have been defined.
echo

#intro
sleep 1
echo "Hi, \"$USER\"."
sleep 1
echo "welcome to the latest incarnation of the witchcraft script."
sleep 1

questions() {
  # your native directory
  echo "Your native directory is... $WITCH"

  $WITCH/color.sh QUESTION "what is your prefered text editor? (type the name of it's executable as exists on host system):"
  read EDITOR
  echo $EDITOR > $WITCH/config.txt #1st line

  $WITCH/color.sh QUESTION "what is your prefered web browser? (type the name of it's executable as exists on host system):"
  read BROWSER
  echo $BROWSER >> $WITCH/config.txt #2nd line

  $WITCH/color.sh QUESTION "so... you need a proxy? you might want to stay hidden :P just press enter if you don't know what i am talking about or you don't need one"
  read PROX
  echo $PROX >> $WITCH/config.txt #3rd line

  $WITCH/color.sh QUESTION "finally are you an ub0r l33t? [y/n] we give ub0r l33ts the supreme choice to intervene (not yet implemeneted :P)"
  read INTERVENE
  echo $INTERVENE >> $WITCH/config.txt #4th line
}

menu() {
  clear
  $WITCH/color.sh QUESTION "what do you want to do?"
  $WITCH/color.sh GREEN "
    A.    write iso of current operating system (rewic)
    B.    install a new operating system (cauldren)
    C.    do it all yourself
  Q.    quit because you don't want to listen to us anymore"

  read WITCHCRAFTMODE

  case $WITCHCRAFTMODE in
    A|a)
      echo "Choice was $WITCHCRAFTMODE. sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
      sleep 5
      $WITCH/rewic.sh
    ;;
    B|b)
      echo "Choice was $WITCHCRAFTMODE. sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
      sleep 5
      $WITCH/cauldren.sh
    ;;
    C|c)
      echo "Choice was $WITCHCRAFTMODE. this part of the script is complete.  for full manual install, simply press ctrl-C at any time to enter fully manual mode. ;)"
      echo "exiting to full manual mode now"
      exit
    ;;
    Q|q)
      exit
    ;;
    *)
      $WITCH/color.sh RED "Valid Choices are A,B,C. Don't press Q. Please."
      sleep 5
      menu
    ;;
  esac
}

echo ""

### time to set up a nice little environmental variable
export WITCH=$(pwd)

#root check
if [[ $EUID -ne 0 ]]
then
  $WITCH/color.sh RED "Hmm, you don't have any root. Poor you."
  $WITCH/color.sh ERROR "go back and get root. before you come back."
  exit 1
else
  $WITCH/color.sh RED "And you've passed thy root test! You may continue..."
  sleep 3
fi

echo
questions

if [ "$DIMG_RUN" == "true" ]; then
  echo "Drive IMaGe generation mode activated."
  $WITCH/cauldren.sh
else
  menu
fi


code:
#! /bin/bash
#written by digit (+ the community).  most ambitious project yet. see http://github.com/Digit/witch for more

clear #neatness freak

### dont be bothered if the comments seem outta wack, they are.  ...need to go clean that up some more still.
# will remove this guff when the comments n shiz r cleaned up of those redundant or irelevent or outdated or just guff...

# digit's new simple tree plan/notion of what witchcraft is about.

#version (probably gonna keep version as "concept v0.00" until it's at least ready for a trial run.
echo "VERSION: gentoo install test v0.00 " #oldversion#echo "VERSION: concept v0.00"
echo "(means dont try to run it yet, for the sake of your computer.  retreat while you can.)"

##dev-intro
#for sake of navigation, check out the functions: rewic, cauldren (and it's functions), distroselector, deskfigselector.  they're all launched in a tree of options, starting at the end of this script, after all the functions have been defined.
echo

#intro
sleep 1
echo "Hi, \"$USER\"."
sleep 1
echo "welcome to the latest incarnation of the witchcraft script."
sleep 1

questions() {
    # your native directory
    echo "Your native directory is... $WITCH"

    $WITCH/color.sh QUESTION "what is your prefered text editor? (type the name of it's executable as exists on host system):"
    read EDITOR
    echo $EDITOR > $WITCH/config.txt #1st line

    $WITCH/color.sh QUESTION "what is your prefered web browser? (type the name of it's executable as exists on host system):"
    read BROWSER
    echo $BROWSER >> $WITCH/config.txt #2nd line

    $WITCH/color.sh QUESTION "so... you need a proxy? you might want to stay hidden :P just press enter if you don't know what i am talking about or you don't need one"
    read PROX
    echo $PROX >> $WITCH/config.txt #3rd line

    $WITCH/color.sh QUESTION "finally are you an ub0r l33t? [y/n] we give ub0r l33ts the supreme choice to intervene (not yet implemeneted :P)"
    read INTERVENE
    echo $INTERVENE >> $WITCH/config.txt #4th line
}

menu() {
    clear
	$WITCH/color.sh QUESTION "what do you want to do?"
	$WITCH/color.sh GREEN "
    A.    write iso of current operating system (rewic)
    B.    install a new operating system (cauldren)
    C.    do it all yourself
    Q.    quit because you don't want to listen to us anymore"

	read WITCHCRAFTMODE

	case $WITCHCRAFTMODE in
		A|a)
            echo "Choice was $WITCHCRAFTMODE. sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
            sleep 5
            $WITCH/rewic.sh
            ;;
		B|b)
            echo "Choice was $WITCHCRAFTMODE. sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
            sleep 5
            $WITCH/cauldren.sh
            ;;
		C|c)
            echo "Choice was $WITCHCRAFTMODE. this part of the script is complete.  for full manual install, simply press ctrl-C at any time to enter fully manual mode. ;)"
            echo "exiting to full manual mode now"
            exit
            ;;
		Q|q)
            exit
            ;;
		*)
            $WITCH/color.sh RED "Valid Choices are A,B,C. Don't press Q. Please."
			sleep 5
			menu
            ;;
	esac
}

echo ""

### time to set up a nice little environmental variable
export WITCH=$(pwd)

#root check
if [[ $EUID -ne 0 ]]
then
    $WITCH/color.sh RED "Hmm, you don't have any root. Poor you."
    $WITCH/color.sh ERROR "go back and get root. before you come back."
    exit 1
else
    $WITCH/color.sh RED "And you've passed thy root test! You may continue..."
    sleep 3
fi

echo
questions
menu


code:
witches
=======

spose we should keep an eye out for em witches too.

... aw heck, just go ask lunacat (and or lunacat2) about 'em.  ... that's in the irc chanel #witchlinux on irc.freenode.net btw.