#!/bin/sh
while [ 0 ]; do
rm -f /tmp/SeTDS /tmp/SeTmount

while [ 0 ]; do
 cat << EOF > /tmp/tmpmsg

ϡɥǥľܥ󥹥ȡ뤹ˤϡPlamo
Linux Υ֡ȥǥʳγƥǥб֥ǥ
쥯ȥĥѡƥ󤬤ʤФʤޤ㤨
СPlamo Linux/dev/hda4/tmp/plamoʲˤ硢
ѡƥȤ/dev/hda4򡢥ǥ쥯ȥȤ
/tmp/plamoꤹɬפޤ/dev/hda4DOS
VFATѡƥǤäƤ⹽ޤ

ѡƥꥹȤ򸫤ˤ[enter]򲡤Ƥ
 \n
EOF
 dialog --title "ѡƥλ" --inputbox \
"`cat /tmp/tmpmsg`" 20 70 2> /tmp/source.part
 if [ $? = 1 -o $? = 255 ]; then
  rm -f /tmp/source.part /tmp/tmpmsg
  exit
 fi
 rm -f /tmp/tmpmsg
 SLACK_DEVICE="`cat /tmp/source.part`"
 rm -f /tmp/source.part
 if [ "$SLACK_DEVICE" = "" ]; then
  dialog --title "ѡƥꥹ" --msgbox "`probe -l | grep -v cylind | grep dev 2> /dev/null`" 22 75
  continue;
 fi
 break;
done

dialog --title "󥹥ȡ븵ǥ쥯ȥ" --inputbox \
"\n\
ΥѡƥΤɤPlamo LinuxΥѥåΤ\n\
ꤷƤa  ap Ȥǥ쥯ȥ꤬¸ߤ\n\
ǥ쥯ȥǤϥѡƥƬ\n\
ˤʤޤʤ/dev/hda4/mnt˥ޥȤƻȤä\n\
/mnt/plamoʲ˥ѥå硢ѡƥ\n\
/dev/hda4ǥ쥯ȥλplamoˤʤޤ \n\n\
ɤPlamo LinuxΥѥåޤ \n" \
19 65 2> /tmp/source.dir
if [ $? = 1 -o $? = 255 ]; then
 rm -f /tmp/source.dir
 exit
fi
SLACK_SOURCE_LOCATION="`cat /tmp/source.dir`"
rm -f /tmp/source.dir
if mount | grep $SLACK_DEVICE 1> /dev/null 2> /dev/null ; then
 # This partition is already mounted, so we will have to
 # tweak things funny.
 rm -f /var/adm/mount 2> /dev/null
 rmdir /var/adm/mount 2> /dev/null
 PREFIX="`mount | grep $SLACK_DEVICE`"
 PREFIX="`echo "$PREFIX" | cut -b14-`"
 end_of_line="1"
 while [ 0 ]; do
  end_of_line="`expr $end_of_line + 1`"
  if [ "`echo "$PREFIX" | cut -b$end_of_line`" = " " ]; then  # Found it!
   end_of_line="`expr $end_of_line - 1`"
   break;
  fi
 done
 PREFIX="`echo "$PREFIX" | cut -b1-$end_of_line`"
 ln -sf $PREFIX /var/adm/mount 
else
 SUCCESS=false
 for type in msdos ext2 ext3 reiserfs jfs xfs ntfs hpfs ; do
   mount -t $type $SLACK_DEVICE /var/adm/mount 1> /dev/null 2> /dev/null
   if [ $? = 0 ]; then # mounted successfully 
     SUCCESS=true
     break;
   fi
 done
 if [ ! $SUCCESS = true ]; then # there was a mount error
  cat << EOF > /tmp/tmpmsg
ѡƥޥȤݤ˥顼ȯޤ\n\
ɤޤ礦

EOF
  dialog --title "ޥȥ顼" --menu "`cat /tmp/tmpmsg`" 10 68 2 \
"Restart" "ľ" \
"Ignore " "顼̵뤷Ʒ³" 2> /tmp/dowhat
  if [ $? = 1 -o $? = 255 ]; then
   rm -f /tmp/dowhat
   exit
  fi
  DOWHAT="`cat /tmp/dowhat`"
  rm -f /tmp/dowhat
  if [ "$DOWHAT" = "Restart" ]; then
   umount /var/adm/mount 2> /dev/null
   continue;
  fi
  echo
 fi # mount error
fi

if [ -d /var/adm/mount/$SLACK_SOURCE_LOCATION ]; then
 echo "/var/adm/mount/$SLACK_SOURCE_LOCATION" > /tmp/SeTDS
 echo "-source_mounted" > /tmp/SeTmount
 echo "/dev/null" > /tmp/SeTsource
 exit
else
 cat << EOF > /tmp/tmpmsg

ޤǥ쥯ȥ$SLACK_SOURCE_LOCATIONϥѡƥ
$SLACK_DEVICEˤ¸ߤޤ

ľޤ
EOF
 dialog --title "󥹥ȡ븵ǥ쥯ȥ꤬Ĥޤ" --yesno "`cat /tmp/tmpmsg`" 10 70
 if [ $? = 1 -o $? = 255 ]; then
  rm -f /tmp/tmpmsg
  exit
 fi
 rm -r /tmp/tmpmsg
fi


if [ ! -d /var/adm/mount/$SLACK_SOURCE_LOCATION/a ]; then
 cat << EOF > /tmp/tmpmsg

ޤǥ쥯ȥ$SLACK_SOURCE_LOCATIONˤ
ɬפʥǥ쥯ȥ(a,apʤ)¸ߤޤ

ľޤ
EOF
 dialog --title "󥹥ȡ븵ǥ쥯ȥ꤬Ĥޤ" --yesno "`cat /tmp/tmpmsg`" 10 70
 if [ $? = 1 -o $? = 255 ]; then
  rm -f /tmp/tmpmsg
  exit
 fi
 rm -r /tmp/tmpmsg
fi

done
