: loadsys1
:
: Programmet skapar en del av ett ABCenix Ver 5.1 prel. operativsystem
:
: Luxor Datorer AB Motala Sweden
:
: anv{ndning: loadsys1 [-wt winchestertyp     -we winchesterenhet
:		       -ws winchesterstorlek -ke k{llenhet -bs blockstorlek]
: exempel:	1: loadsys1	Detta ger standardv{rden p} alla argument
:		2: loadsys1 -we sa48  -ke mf0	Inneb{r att ett system 
:			   skapas p} en enhet /dev/sa48  och disketten
:			   sitter p} enhet /dev/mf0
KSAK="kanske saknas"
KSAKP="$KSAK programmet"
KSAKB="$KSAK biblioteket"
KSAKF="$KSAK filen"
EK="En konstig"
HASA="har angivits som argument"
ERROR="N}gonting har g}tt snett, felet kan vara n}got av f|ljande"
HLP1="Om Du inte kan }tg{rda felet sj{lv,"
HLP2="kontakta }terf|rs{ljare eller i andra hand"
HELP="$HLP1 E$HLP2 ELuxor Datorer AB kundsupport 0141/16080."
wt=necd5126a
we=sa40
ws=12240
ke=mf2
bs=1024
if test "$1" = ""
then
  echo -n "Vilken winchester (necd5126a) ?:"
  read x
  if test "$x" = ""
  then
    echo "Standard winchestertyp necd5126a vald."
    wt=necd5126a
  else
    wt=$x
    echo "winchestertyp $wt vald."
  fi
  echo -n "Vilket enhet skall winchestern anslutas till (sa40) ?:"
  read x
  if test "$x" = ""
  then
    echo "Standardenhet /dev/sa40 vald."
    we=sa40
  else
    we=$x
    echo "Enhet /dev/$we vald."
  fi
else
  while 
    test '$1'
  do
    case $1 in
	-wt)	shift; wt=$1	; shift ;;
	-we)	shift; we=$1	; shift ;;
	-ws)	shift; ws=$1	; shift ;;
	-ke)	shift; ke=$1	; shift ;;
	-bs)	shift; bs=$1	; shift ;;
	*)	echo -e $ERROR
		echo -e "1: konstigt argument $1."
		echo -e "kontrollera i dokumentationen och starta om."
		exit 1
		;;
    esac
  done
fi
case $wt in
  basf6188)  ws=12240 ;;
  basf6188x) ws=12240 ;;
  basf6188l) ws=12240 ;;
  basf6188-ra) ws=20000 ;;
  basf6188-rl) ws=20000 ;;
  necd5126a)   ws=20000 ;;
  necd5126l)   ws=20000 ;;
  tm755a)      ws=41600 ;;
  micr1325a)   ws=69000 ;;
  basf6194a)   ws=78000 ;;
  cdc9415-86a) ws=69000 ;;
  *) ;;
esac
echo "Kopierar boot sektor fr}n /dev/$ke till /dev/$we." 
if copy /bootsector /dev/$we
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /bin/copy."
  echo -e "2: $EK fil(=/bootsector) $HASA nummer 2."
  echo -e "3: $EK enhet(=/dev/$we) $HASA nummer 3."
  echo -e $HELP
  exit 1
fi
echo "Skapar en filstrukur p} enhet /dev/$we med en storlek p} $ws kbyte."
if /etc/mkfs -b $bs -v $ws /dev/$we
then : 
else
  echo -e $ERROR 
  echo -e "1: $KSAKP /etc/mkfs."
  echo -e "2: $EK blockstorlek(=$bs) $HASA nummer 3."
  echo -e $HELP
  exit 1
fi
echo "Monterar enhet /dev/$we till bibliotek /mnt."
if /etc/mount /dev/$we /mnt
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mount."
  echo -e "2: $EK enhet(=/dev/$we) $HASA nummer 2."
  echo -e "3: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
echo "Kopierar /boot /abcenix /.profile /loadsys fr}n /dev/$ke till /dev/$we." 
for i in /boot /abcenix /.profile /loadsys
do
  if copy -om $i /mnt
  then : 
  else
    echo -e $ERROR
    echo -e "1: $KSAKP /bin/copy."
    echo -e "2: $KSAKF $i."
    echo -e "3: $KSAKB /mnt."
    echo -e $HELP
    exit 1
  fi
done
echo "Skapar bibliotek p} enhet /dev/$we."
for i in /dev /etc /hnd /hnd/isam_mount /mf2 /mnt /sas /tmp /usr \
	 /usr/adm /usr/spool /usr/spool/lpd /usr/spool/mail /usr/tmp /win

do
  if mkdir /mnt$i
  then : 
  else
    echo -e $ERROR
    echo -e "1: $KSAKP /bin/mkdir."
    echo -e "2: $KSAKB /mnt."
    echo -e $HELP
    exit 1
  fi
done
echo "[ndrar skyddet p} n}gra filer p} enhet /dev/$we."
for i in /tmp /mnt /mf2 /usr/tmp /win /usr/adm /usr/spool \
	 /usr/spool/lpd /usr/spool/mail /hnd/isam_mount
do
  if chmod a+rw /mnt$i
  then : 
  else
    echo -e $ERROR
    echo -e "1: $KSAKP /bin/chmod."
    echo -e "2: $KSAKB /mnt."
    echo -e $HELP
    exit 1
  fi
done
echo "Kopierar bibliotek fr}n /dev/$ke till /dev/$we."
for i in /bin /dev /etc /lib /sas /tmp /usr
do
  if copy -omrt $i /mnt
  then : 
  else
    echo -e $ERROR
    echo -e "1: $KSAKP /bin/copy."
    echo -e "2: $KSAKB /mnt."
    echo -e "3: $KSAKF $i."
    echo -e $HELP
    exit 1
  fi
done
echo "Skapar olika enheter p} /dev/$we."
if /etc/mknod /mnt/dev/mem c 3 0 ; chmod 600 /mnt/dev/mem
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/kmem c 3 1 ; chmod 600 /mnt/dev/kmem
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi 
if /etc/mknod /mnt/dev/autosw c 3 5 ; chmod 444 /mnt/dev/autosw
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/bclock c 3 6 ; chmod 644 /mnt/dev/bclock
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/nvram c 3 7 ; chmod 644 /mnt/dev/nvram
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/log c 3 9 ; chmod 600 /mnt/dev/log
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/mf2-ibm c 9 66 ; chmod 666 /mnt/dev/mf2-ibm
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/wd40 c 14 40 ; chmod 644 /mnt/dev/wd40
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/st0 c 5 178 ; chmod 644 /mnt/dev/st0
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/lp c 1 0 ; chmod 622 /mnt/dev/lp
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/tty02 c 1 2 ; chmod 666 /mnt/dev/tty02
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/tty03 c 1 3 ; chmod 666 /mnt/dev/tty03
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/tty c 2 0 ; chmod 666 /mnt/dev/tty
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/DBinoutb c 3 8 ; chmod 600 /mnt/dev/DBinoutb
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
if /etc/mknod /mnt/dev/DBIdrv c 13 0 ; chmod 600 /mnt/dev/DBIdrv
then : 
else
  echo -e $ERROR
  echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
  echo -e "2: $KSAKB /mnt."
  echo -e $HELP
  exit 1
fi
echo "Skapar enheter f|r f|nsterhanteraren."
for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
do
  if /etc/mknod /mnt/dev/wtty$i c 3 2 ; chmod 666 /mnt/dev/wtty$i
  then : 
  else
    echo -e $ERROR
    echo -e "1: $KSAKP /etc/mknod eller /bin/chmod."
    echo -e "2: $KSAKB /mnt eller /mnt/dev."
    echo -e $HELP
    exit 1
  fi
done
echo "Nu tas systemet ner och }terstartas fr}n winchester $we."
kill 1
