source: src-sh/pc-installdialog/pc-installdialog.sh @ 92fb551

enter/10releng/10.0.3releng/10.1releng/10.1.1releng/10.1.2
Last change on this file since 92fb551 was 92fb551, checked in by Kris Moore <kris@…>, 10 months ago

Fix a small bug, check for file, not directory

  • Property mode set to 100755
File size: 22.7 KB
Line 
1#!/bin/sh
2# License: BSD
3# Author: Kris Moore (kris@pcbsd.org)
4########################################################
5# This script is fairly linear, it will walk through a series of questions
6# and when finished, generate a pc-sysinstall script
7
8# Source our functions
9. /usr/local/share/pcbsd/scripts/functions.sh
10
11# Dialog menu title
12TITLE="PC-BSD Install Dialog"
13
14# pc-sysinstall config file to write out to
15CFGFILE="/tmp/sys-install.cfg"
16
17# Default ZFS layout
18ZFSLAYOUT="/(compress=lz4),/root(compress=lz4),/tmp(compress=lz4),/usr(canmount=off),/usr/home(compress=lz4),/usr/jails(compress=lz4),/usr/obj(compress=lz4),/usr/pbi(compress=lz4),/usr/ports(compress=lz4),/usr/ports/distfiles(compress=off),/usr/src(compress=lz4),/var(canmount=off),/var/audit(compress=lz4),/var/log(compress=lz4),/var/tmp(compress=lz4)"
19
20# Ugly master list of settable ZFS properties
21ZPROPS="aclinherit(discard|noallow|restricted|passthrough|passthrough-x),aclmode(discard|groupmask|passthrough|restricted),atime(on|off),canmount(on|off|noauto),checksum(on|off|fletcher2|fletcher4|sha256),compress(on|off|lzjb|gzip|zle|lz4),copies(1|2|3),dedup(on|off|verify|sha256),exec(on|off),primarycache(all|none|metadata),readonly(on|off),secondarycache(all|none|metadata),setuid(on|off),sharenfs(on|off),logbias(latency|throughput),snapdir(hidden|visible),sync(standard|always|disabled),jailed(off|on)"
22
23PCSYS="/root/pc-sysinstall/pc-sysinstall"
24if [ ! -e "$PCSYS" ] ; then
25  PCSYS="/usr/local/sbin/pc-sysinstall"
26fi
27
28# The current ZPOOL type should default to single
29ZPOOL_TYPE="single"
30
31change_zpool()
32{
33  get_zpool_menu
34  gen_pc-sysinstall_cfg
35}
36
37get_zpool_menu()
38{
39  while :
40  do
41    dOpts="done \"Exit zpool menu\" single \"Convert to single-disk\""
42
43    diskTot=`${PCSYS} disk-list | wc -l | awk '{print $1}'`
44    if [ $diskTot -gt 1 ] ; then
45      dOpts="$dOpts mirror \"Convert to mirror\" raidz1 \"Convert to raidz1\""
46    fi
47    if [ $diskTot -gt 2 ] ; then
48      dOpts="$dOpts raidz2 \"Convert to raidz2\""
49    fi
50    if [ $diskTot -gt 3 ] ; then
51      dOpts="$dOpts raidz3 \"Convert to raidz3\""
52    fi
53
54    get_dlg_ans "--menu \"Current zpool: $ZPOOL_TYPE - $SYSDISK $ZPOOL_DISKS\" 20 50 10 ${dOpts}"
55    if [ -z "$ANS" ] ; then
56       exit_err "Invalid option selected!"
57    fi
58    case $ANS in
59       done) break ;;
60     single) ZPOOL_DISKS=""
61             ZPOOL_TYPE="single"
62             ;;
63     mirror) get_zpool_disks "mirror" "1" ;;
64     raidz1) get_zpool_disks "raidz1" "1" ;;
65     raidz2) get_zpool_disks "raidz2" "2" ;;
66     raidz3) get_zpool_disks "raidz3" "3" ;;
67          *) ;;
68    esac
69  done
70}
71
72get_zpool_disks() {
73  local type=$1
74  local min=$2
75
76  while :
77  do
78    dOpts=""
79
80    ${PCSYS} disk-list > /tmp/.dList.$$
81    while read i
82    do
83      # Get the disk dev
84      d=`echo $i | cut -d ':' -f 1`
85
86      # Dont need to list the existing target disk
87      if [ "$SYSDISK" = "$d" ] ; then continue ; fi
88
89      # Get the disk description
90      desc=`echo $i | cut -d ':' -f 2`
91      size="`${PCSYS} disk-info $d | grep size | cut -d '=' -f 2`MB"
92      dOpts="$dOpts $d \"$desc ($size)\" off"
93    done < /tmp/.dList.$$
94    rm /tmp/.dList.$$
95
96
97    get_dlg_ans_no_exit "--single-quoted --checklist \"Select at least $min additional disk(s) for $type\" 22 45 15 ${dOpts}"
98    if [ $? -ne 0 ] ; then break; fi
99
100     ANS=`echo $ANS | sed "s|'||g"`
101
102     count=`echo $ANS | wc -w | awk '{print $1}'`
103     if [ $count -lt $min ] ; then
104        echo "Please select at least $min additional disks!"
105        rtn
106        continue
107     fi
108
109     ZPOOL_DISKS="$ANS"
110     ZPOOL_TYPE="$type"
111     break
112  done
113}
114
115change_zfs()
116{
117  get_zfs_layout
118  gen_pc-sysinstall_cfg
119}
120
121get_zfs_layout()
122{
123  while :
124  do
125    dOpts="done \"Exit dataset menu\" add \"New ZFS dataset\""
126    for z in `echo $ZFSLAYOUT | sed 's|,| |g'`
127    do
128       d=`echo $z | cut -d '(' -f 1`
129       echo "$z" | grep -q '('
130       if [ $? -eq 0 ] ; then
131         desc="(`echo $z | cut -d '(' -f 2`"
132       else
133         desc=""
134       fi
135       dOpts="$dOpts $d \"$desc\""
136    done
137    get_dlg_ans "--menu \"Select dataset to edit\" 22 78 15 ${dOpts}"
138    if [ -z "$ANS" ] ; then
139       exit_err "Invalid dataset selected!"
140    fi
141    case $ANS in
142       done) break ;;
143        add) add_dataset ;;
144          *) edit_dataset "$ANS" ;;
145    esac
146  done
147}
148
149get_zfs_dset_opt()
150{
151  local changeOpt="$1"
152  dOpts=""
153
154  # Build a list of dataset options to display
155  for z in `echo $ZPROPS | sed 's|,| |g'`
156  do
157    zOpt=`echo $z | cut -d '(' -f 1`
158    if [ "$zOpt" != "$changeOpt" ] ; then continue ; fi
159
160    zOps=`echo $z | cut -d '(' -f 2 | cut -d ')' -f 1`
161    for o in `echo $zOps | sed 's,|, ,g'`
162    do
163       d="$o" 
164       desc="($o)"
165       dOpts="$dOpts $d \"$desc\""
166    done
167    break
168  done
169
170  # Ask what to do on this dataset
171  get_dlg_ans "--menu \"Set option for $changeOpt on $2\" 22 50 15 unset 'Unset this option' cancel 'Cancel' ${dOpts}"
172  if [ -z "$ANS" ] ; then
173     exit_err "Invalid option selected!"
174  fi
175
176  if [ "$ANS" = "unset" ] ; then ANS="" ; fi
177  if [ "$ANS" = "cancel" ] ; then ANS="CANCELED" ; fi
178  VAL=$ANS ; export VAL
179}
180
181edit_dataset()
182{
183
184  dOpts=""
185
186  # Pull a list of dataset options from the users layout
187  for z in `echo $ZFSLAYOUT | sed 's|,| |g'`
188  do
189     d=`echo $z | cut -d '(' -f 1`
190     if [ "$d" != "$1" ] ; then continue ; fi
191     curOpts="`echo $z | cut -d '(' -f 2 | cut -d ')' -f 1`"
192  done
193
194  # Build a list of dataset options to display
195  for z in `echo $ZPROPS | sed 's|,| |g'`
196  do
197    d=`echo $z | cut -d '(' -f 1`
198    desc="(unset)"
199    for o in `echo $curOpts | sed 's,|, ,g'`
200    do
201       _opt="`echo $o | cut -d '=' -f 1`"
202       if [ "$_opt" != "$d" ] ; then continue ; fi
203       desc="(`echo $o | cut -d '=' -f 2`)"
204    done
205    dOpts="$dOpts $d \"$desc\""
206  done
207
208  # Ask what to do on this dataset
209  get_dlg_ans "--menu \"Editing dataset: ${1}\" 22 50 15 delete 'Remove the dataset' cancel 'Cancel' ${dOpts}"
210  if [ -z "$ANS" ] ; then
211     exit_err "Invalid dataset selected!"
212  fi
213  case $ANS in
214    cancel) return ;;
215    delete) NEWLAYOUT=""
216            for z in `echo $ZFSLAYOUT | sed 's|,| |g'`
217            do
218              d=`echo $z | cut -d '(' -f 1` 
219              if [ "$d" = "$1" ] ; then continue ; fi
220              if [ -z "$NEWLAYOUT" ] ; then
221                NEWLAYOUT="${z}"
222              else
223                NEWLAYOUT="$NEWLAYOUT,${z}"
224              fi
225            done
226            ZFSLAYOUT="$NEWLAYOUT"
227            ;;
228         *) cOpt=$ANS 
229            get_zfs_dset_opt "$cOpt" "$1"
230            newOpt="$VAL"
231            if [ "$newOpt" = "CANCELED" ] ; then return ; fi
232
233            NEWLAYOUT=""
234            for z in `echo $ZFSLAYOUT | sed 's|,| |g'`
235            do
236               d=`echo $z | cut -d '(' -f 1`
237               if [ "$d" != "$1" ] ; then
238                 if [ -z "$NEWLAYOUT" ] ; then
239                   NEWLAYOUT="${z}"
240                 else
241                   NEWLAYOUT="$NEWLAYOUT,${z}"
242                 fi
243                 continue
244               fi
245               
246               # Add this option to our optList
247               NEWOPTLIST=""
248               optList="`echo $z | cut -d '(' -f 2 | cut -d ')' -f 1`"
249               if [ "$optList" = "$z" ] ; then optList="" ; fi
250               addedOpt=0
251               for o in `echo $optList | sed 's,|, ,g'`
252               do
253                  _opt="`echo $o | cut -d '=' -f 1`"
254                  if [ "$_opt" != "$cOpt" ] ; then
255                     if [ -z "$NEWOPTLIST" ] ; then
256                        NEWOPTLIST="${o}"
257                     else
258                        NEWOPTLIST="$NEWOPTLIST|${o}"
259                     fi
260                     continue
261                  fi
262                  addedOpt=1
263                  # If the user unset this opt, lets skip adding it
264                  if [ -z "$newOpt" ] ; then continue ; fi
265                  if [ -z "$NEWOPTLIST" ] ; then
266                     NEWOPTLIST="${cOpt}=${newOpt}"
267                  else
268                     NEWOPTLIST="$NEWOPTLIST|${cOpt}=${newOpt}"
269                  fi
270               done
271
272               # If we need to add the opt fresh
273               if [ $addedOpt -eq 0 ] ; then
274                  if [ -z "$NEWOPTLIST" ] ; then
275                     NEWOPTLIST="${cOpt}=${newOpt}"
276                  else
277                     NEWOPTLIST="$NEWOPTLIST|${cOpt}=${newOpt}"
278                  fi
279               fi
280
281               opt=""
282               if [ -n "$NEWOPTLIST" ] ; then opt="($NEWOPTLIST)"; fi
283               if [ -z "$NEWLAYOUT" ] ; then
284                  NEWLAYOUT="${d}${opt}"
285               else
286                  NEWLAYOUT="$NEWLAYOUT,${d}${opt}"
287               fi
288            done
289            ZFSLAYOUT="$NEWLAYOUT"
290            ;;
291  esac
292}
293
294add_dataset()
295{
296    get_dlg_ans "--inputbox 'Enter dataset mountpoint' 8 40"
297    if [ -z "$ANS" ] ; then
298       exit_err "Invalid dataset entered!"
299    fi
300
301    # Make sure it starts with a /
302    echo $ANS | grep -q "^/" 
303    if [ $? -ne 0 ] ; then
304       return
305    fi
306
307    # Check for duplicates
308    for z in `echo $ZFSLAYOUT | sed 's|,| |g'`
309    do
310       d=`echo $z | cut -d '(' -f 1`
311       if [ "$d" = "$ANS" ] ; then
312          echo "Error, this dataset already exists!"
313          rtn
314          return
315       fi
316    done
317
318    # Save the dataset
319    ZFSLAYOUT="$ZFSLAYOUT,$ANS"
320}
321
322get_dlg_ans_no_exit()
323{
324  TANS="/tmp/.pcinsdialog.$$"
325  if [ -e "$TANS" ] ; then rm ${TANS}; fi
326  if [ -e "$TANS.dlg" ] ; then rm ${TANS}.dlg; fi
327  while :
328  do
329    echo "dialog --title \"$TITLE\" ${@}" >${TANS}.dlg
330    sh ${TANS}.dlg 2>${TANS}
331    local err=$?
332
333    if [ ! -e "$TANS" ] ; then
334       ANS=""
335       return $err
336    fi
337    ANS=`cat ${TANS}`
338    return $err
339  done
340}
341
342get_dlg_ans()
343{
344  TANS="/tmp/.pcinsdialog.$$"
345  if [ -e "$TANS" ] ; then rm ${TANS}; fi
346  if [ -e "$TANS.dlg" ] ; then rm ${TANS}.dlg; fi
347  while :
348  do
349    echo "dialog --title \"$TITLE\" ${@}" >${TANS}.dlg
350    sh ${TANS}.dlg 2>${TANS}
351    if [ $? -ne 0 ] ; then
352      dialog --title "$TITLE" --yesno 'Exit the installer?' 8 30
353      if [ $? -eq 0 ] ; then exit_err "User canceled install" ; fi
354      continue
355    fi
356
357    if [ ! -e "$TANS" ] ; then
358       ANS=""
359       return
360    fi
361    ANS=`cat ${TANS}`
362    return
363  done
364}
365
366
367get_sys_type()
368{
369  # First ask the system type
370  get_dlg_ans "--radiolist \"System type\" 12 50 5 desktop \"PC-BSD Desktop\" on server \"TrueOS / FreeBSD Server\" off"
371  if [ -z "$ANS" ] ; then
372     exit_err "Invalid system type"
373  fi
374  SYSTYPE="$ANS"
375
376  # If on a desktop, lets just set DHCP
377  if [ "$SYSTYPE" = "desktop" ] ; then
378     SYSNIC="AUTO-DHCP-SLAAC"
379  fi
380}
381
382get_sys_bootmanager()
383{
384  # Ask the boot-manager
385  get_dlg_ans "--radiolist \"Boot Manager\" 12 50 5 GRUB \"GRUB - Recommended\" on BSD \"FreeBSD Boot-Loader\" off none \"No boot-loader\" off"
386  if [ -z "$ANS" ] ; then
387     exit_err "Invalid bootmanager type"
388  fi
389  SYSBOOTMANAGER="$ANS"
390
391  # If we are not using grub, nothing left to ask
392  if [ "$SYSBOOTMANAGER" != "GRUB" ]; then return; fi
393
394  # If we are using GRUB, ask if we want to do GELI encryption
395  dialog --title "$TITLE" --yesno 'Enable full-disk encryption with GELI?' 8 30
396  if [ $? -ne 0 ] ; then return ; fi
397  get_dlg_ans "--inputbox 'Enter encryption password' 8 40"
398
399  if [ -z "$ANS" ] ; then
400     echo "No password specified!  GELI encryption is currently disabled.  Please run the wizard again to setup GELI encryption!"; rtn
401     USINGGELI="NO"
402     return
403  fi
404     
405  GELIPASS="$ANS"
406  get_dlg_ans "--inputbox 'Enter password (again)' 8 40"
407  if [ -z "$ANS" ] ; then
408     echo "No password specified!  GELI encryption is currently disabled.  Please run the wizard again to setup GELI encryption!"; rtn
409     USINGGELI="NO"
410     return
411  fi
412     
413  if [ "$GELIPASS" != "$ANS" ]; then
414     echo "ERROR: Password mismatch! GELI encryption is currently disabled.  Please run the wizard again to setup GELI encryption!";
415     rtn
416     USINGGELI="NO"
417     return
418  fi
419
420  USINGGELI="YES"
421
422}
423
424get_target_disk()
425{
426  # Now we prompt for the disk to install on
427  dOpts=""
428  ${PCSYS} disk-list > /tmp/.dList.$$
429  while read i
430  do
431     fOpt="on"
432     d=`echo $i | cut -d ':' -f 1`
433     desc=`echo $i | cut -d ':' -f 2`
434     size="`${PCSYS} disk-info $d | grep size | cut -d '=' -f 2`MB"
435     dOpts="$dOpts $d \"$desc ($size)\" $fOpt" 
436     if [ -z "$fOpt" ] ; then fOpt="off"; fi
437  done < /tmp/.dList.$$
438  rm /tmp/.dList.$$
439  get_dlg_ans "--radiolist \"Select target disk\" 12 50 5 ${dOpts}"
440  if [ -z "$ANS" ] ; then
441     exit_err "Invalid disk selected!"
442  fi
443  SYSDISK="$ANS"
444}
445
446get_hardware_info()
447{
448
449  #This is to detect an active network card for FreeBSD & PC-BSD
450   ifconfig | grep -q 'status: active'
451   if [ $? -eq 0 ] ; then
452     echo "Compatible Active Network Card Detected"
453     rtn
454   else
455     echo "No Compatible Active Network Card Detected"
456     rtn
457     fi
458}
459
460get_target_part()
461{
462  # Now prompt for the full-disk or partition to install onto
463  ${PCSYS} disk-part $SYSDISK > /tmp/.dList.$$
464  dOpts="ALL \"Use entire disk\" on"
465  dFmt=`grep "$SYSDISK-format:" /tmp/.dList.$$ | awk '{print $2}'` 
466  if [ "$dFmt" = "MBR" ] ; then
467    dChar="s"
468    DISKFORMAT="MBR"
469  else
470    dChar="p"
471    DISKFORMAT="GPT"
472  fi
473  i=1
474  while :
475  do
476     partRAW="${dChar}${i}"
477     part="${SYSDISK}${dChar}${i}"
478     [ -e "/dev/${part}" ] || break
479     desc="`cat /tmp/.dList.$$ | grep ^${part}-label | cut -d ':' -f 2`"
480     mb="`cat /tmp/.dList.$$ | grep ^${part}-sizemb | awk '{print $2}'`"
481     dOpts="$dOpts $partRAW \"${mb}MB -$desc\" off" 
482     i="`expr $i + 1`"
483  done
484  rm /tmp/.dList.$$
485  get_dlg_ans "--radiolist \"Select target partition\" 12 80 5 ${dOpts}"
486  if [ -z "$ANS" ] ; then
487     exit_err "Invalid disk selected!"
488  fi
489  DISKPART="$ANS"
490}
491
492get_root_pw()
493{
494  while :
495  do
496    get_dlg_ans "--passwordbox 'Enter the root password' 8 30"
497    if [ -z "$ANS" ] ; then
498       exit_err "Invalid password entered!"
499    fi
500    ROOTPW="$ANS"
501    get_dlg_ans "--passwordbox 'Confirm root password' 8 30"
502    if [ -z "$ANS" ] ; then
503       exit_err "Invalid password entered!"
504    fi
505    ROOTPWCONFIRM="$ANS"
506    if [ "$ROOTPWCONFIRM" = "$ROOTPW" ] ; then break; fi
507    dialog --title "$TITLE" --yesno 'Password Mismatch, try again?' 8 30
508    if [ $? -eq 0 ] ; then continue ; fi
509    exit_err "Failed setting root password!"
510  done
511}
512
513get_user_pw()
514{
515  while :
516  do
517    get_dlg_ans "--passwordbox \"Enter the password for $USERNAME\" 8 40"
518    if [ -z "$ANS" ] ; then
519       exit_err "Invalid password entered!"
520    fi
521    USERPW="$ANS"
522    get_dlg_ans "--passwordbox 'Confirm password' 8 40"
523    if [ -z "$ANS" ] ; then
524       exit_err "Invalid password entered!"
525    fi
526    USERPWCONFIRM="$ANS"
527    if [ "$USERPWCONFIRM" = "$USERPW" ] ; then break; fi
528    dialog --title "$TITLE" --yesno 'Password Mismatch, try again?' 8 30
529    if [ $? -eq 0 ] ; then continue ; fi
530    exit_err "Failed setting password!"
531  done
532}
533
534get_user_name()
535{
536    get_dlg_ans "--inputbox 'Enter a username' 8 40"
537    if [ -z "$ANS" ] ; then
538       exit_err "Invalid username entered!"
539    fi
540    USERNAME="$ANS"
541}
542
543get_user_realname()
544{
545    get_dlg_ans "--inputbox \"Enter the real name for $USERNAME\" 8 40"
546    if [ -z "$ANS" ] ; then
547        ANS="$USERNAME"
548    fi
549    USERREALNAME="$ANS"
550}
551
552get_user_shell()
553{
554    get_dlg_ans "--menu \"Select the users shell\" 12 45 10 /bin/sh SH /bin/csh CSH /bin/tcsh TCSH /bin/bash BASH"
555    if [ -z "$ANS" ] ; then
556       exit_err "Invalid SHELL entered!"
557    fi
558    USERSHELL="$ANS"
559}
560
561get_hostname()
562{
563    get_dlg_ans "--inputbox 'Enter a system Hostname' 8 40"
564    if [ -z "$ANS" ] ; then
565       exit_err "Invalid hostname entered!"
566    fi
567    SYSHOSTNAME="$ANS"
568}
569
570get_sshd()
571{
572  SYSSSHD=""
573  dialog --title "$TITLE" --yesno 'Enable SSH?' 8 30
574  if [ $? -ne 0 ] ; then return ; fi
575  SYSSSHD="YES"
576}
577
578get_netconfig()
579{
580  SYSNIC=""
581  SYSNICIP=""
582  SYSNICDNS=""
583  SYSNICMASK=""
584  SYSNICROUTE=""
585
586  dialog --title "$TITLE" --yesno 'Enable networking?' 6 30
587  if [ $? -ne 0 ] ; then return ; fi
588
589  dOpts="auto \"Automatic DHCP\" on"
590  ${PCSYS} detect-nics > /tmp/.dList.$$
591  while read i
592  do
593     d="`echo $i | cut -d ':' -f 1`"
594     desc="`echo $i | cut -d '<' -f 2 | cut -d '>' -f 1`"
595     dOpts="$dOpts $d \"$desc\" off"
596  done < /tmp/.dList.$$
597  rm /tmp/.dList.$$
598  get_dlg_ans "--radiolist \"Select network card to configure\" 12 50 5 ${dOpts}"
599  if [ -z "$ANS" ] ; then
600     exit_err "Invalid NIC selected!"
601  fi
602  SYSNIC="$ANS"
603  if [ "$SYSNIC" = "auto" ] ; then
604     SYSNIC="AUTO-DHCP-SLAAC"
605     return
606  fi
607
608  get_dlg_ans "--inputbox \"Enter the IP address for $SYSNIC\" 8 40"
609  if [ -z "$ANS" ] ; then
610     exit_err "Invalid IP entered!"
611  fi
612  SYSNICIP="$ANS"
613
614  get_dlg_ans "--inputbox \"Enter the Netmask for $SYSNIC\" 8 40"
615  if [ -z "$ANS" ] ; then
616     exit_err "Invalid real name entered!"
617  fi
618  SYSNICMASK="$ANS"
619
620  get_dlg_ans "--inputbox \"Enter the DNS address for $SYSNIC\" 8 40"
621  if [ -z "$ANS" ] ; then
622     exit_err "Invalid real name entered!"
623  fi
624  SYSNICDNS="$ANS"
625
626  get_dlg_ans "--inputbox \"Enter the Gateway address for $SYSNIC\" 8 40"
627  if [ -z "$ANS" ] ; then
628     exit_err "Invalid real name entered!"
629  fi
630  SYSNICROUTE="$ANS"
631
632}
633
634gen_pc-sysinstall_cfg()
635{
636   # Start the header information
637   echo "# Auto-Generated pc-sysinstall configuration" >${CFGFILE}
638   echo "installInteractive=no" >>${CFGFILE}
639   echo "installMode=fresh" >>${CFGFILE}
640   if [ "$SYSTYPE" = "desktop" ] ; then
641     echo "installType=PCBSD" >>${CFGFILE}
642   else
643     echo "installType=FreeBSD" >>${CFGFILE}
644   fi
645   echo "packageType=dist" >> ${CFGFILE}
646   if [ "`uname -m`" = "amd64" ] ; then
647     echo "distFiles=base doc games kernel lib32" >> ${CFGFILE}
648   else
649     echo "distFiles=base doc games kernel" >> ${CFGFILE}
650   fi
651   echo "installMedium=local" >>${CFGFILE}
652   echo "localPath=/dist" >>${CFGFILE}
653
654   if [ -n "$SYSHOSTNAME" ] ; then
655      echo "" >> ${CFGFILE}
656      echo "hostname=$SYSHOSTNAME" >> ${CFGFILE}
657   fi
658   if [ -n "$SYSNIC" ] ; then
659      echo "" >> ${CFGFILE}
660      echo "netSaveDev=$SYSNIC" >> ${CFGFILE}
661      if [ "$SYSNIC" != "AUTO-DHCP-SLAAC" ] ; then
662        echo "netSaveIP_${SYSNIC}=$SYSNICIP" >> ${CFGFILE}
663        echo "netSaveMask_${SYSNIC}=$SYSNICMASK" >> ${CFGFILE}
664        echo "netSaveNameServer_${SYSNIC}=$SYSNICDNS" >> ${CFGFILE}
665        echo "netSaveDefaultRouter_${SYSNIC}=$SYSNICROUTE" >> ${CFGFILE}
666      fi
667   fi
668
669
670   # Now do the disk block
671   echo "" >> ${CFGFILE}
672   echo "# Disk Setup for $SYSDISK" >> ${CFGFILE}
673   echo "disk0=$SYSDISK" >> ${CFGFILE}
674   echo "partition=$DISKPART" >> ${CFGFILE}
675   echo "bootManager=${SYSBOOTMANAGER}" >> ${CFGFILE}
676   echo "partscheme=$DISKFORMAT" >> ${CFGFILE}
677   echo "commitDiskPart" >> ${CFGFILE}
678
679   # Now the partition block
680   echo "" >> ${CFGFILE}
681   echo "# Partition Setup for ${SYSDISK}($DISKPART)" >> ${CFGFILE}
682   echo "# All sizes are expressed in MB" >> ${CFGFILE}
683   echo "# Avail FS Types, UFS, UFS+S, UFS+SUJ, UFS+J, ZFS, SWAP" >> ${CFGFILE}
684   echo "# UFS.eli, UFS+S.eli, UFS+SUJ, UFS+J.eli, ZFS.eli, SWAP.eli" >> ${CFGFILE}
685
686   # What file-system are we using now?
687   FSTAG="ZFS"
688   if [ "$USINGGELI" = "YES" ] ; then FSTAG="ZFS.eli"; fi
689
690   # Doing a single disk zpool, or a mirror/raidz[1-3]?
691   if [ "$ZPOOL_TYPE" = "single" ] ; then
692     echo "disk0-part=$FSTAG 0 ${ZFSLAYOUT}" >> ${CFGFILE}
693   else
694     echo "disk0-part=$FSTAG 0 ${ZFSLAYOUT} (${ZPOOL_TYPE}: `echo $ZPOOL_DISKS | sed 's| |,|g'`)" >> ${CFGFILE}
695   fi
696
697   # If using GELI encryption, add it to config file
698   if [ "$USINGGELI" = "YES" ] ; then
699     echo "encpass=$GELIPASS" >> ${CFGFILE}
700   fi
701
702   echo "disk0-part=SWAP.eli 2000 none" >> ${CFGFILE}
703   echo "commitDiskLabel" >> ${CFGFILE}
704   echo "" >> ${CFGFILE}
705
706   # Now the packages
707   if [ "$SYSTYPE" = "desktop" ] ; then
708     echo "installPackages=misc/pcbsd-base misc/pcbsd-meta-kde" >> ${CFGFILE}
709     echo "" >> ${CFGFILE}
710     # Set our markers for desktop to run the first-time boot wizards
711     echo "runCommand=sh /usr/local/share/pcbsd/scripts/sys-init.sh desktop en_US" >> ${CFGFILE}
712     echo "runCommand=touch /var/.runxsetup" >> ${CFGFILE}
713     echo "runCommand=touch /var/.pcbsd-firstboot" >> ${CFGFILE}
714     echo "runCommand=touch /var/.pcbsd-firstgui" >> ${CFGFILE}
715   else
716     echo "installPackages=misc/trueos-base" >> ${CFGFILE}
717     echo "" >> ${CFGFILE}
718     echo "runCommand=sh /usr/local/share/pcbsd/scripts/sys-init.sh server" >> ${CFGFILE}
719     echo "" >> ${CFGFILE}
720
721     # Since on TrueOS, lets save username / passwords
722     echo "rootPass=${ROOTPW}" >> ${CFGFILE}
723     echo "" >> ${CFGFILE}
724     echo "userName=${USERNAME}" >> ${CFGFILE}
725     echo "userPass=${USERPW}" >> ${CFGFILE}
726     echo "userShell=${USERSHELL}" >> ${CFGFILE}
727     echo "userHome=/home/${USERNAME}" >> ${CFGFILE}
728     echo "userGroups=wheel,operator" >> ${CFGFILE}
729     echo "commitUser" >> ${CFGFILE}
730   fi
731
732   # Last cleanup stuff
733   echo "" >> ${CFGFILE}
734   echo "runExtCmd=/root/save-config.sh" >> ${CFGFILE}
735   echo "runCommand=newaliases" >> ${CFGFILE}
736
737   # Are we enabling SSHD?
738   if [ "$SYSSSHD" = "YES" ] ; then
739     echo "runCommand=echo 'sshd_enable=\"YES\"' >> /etc/rc.conf" >> ${CFGFILE}
740   fi
741
742}
743
744change_disk_selection() {
745  get_target_disk
746  get_target_part
747  get_sys_bootmanager
748  gen_pc-sysinstall_cfg
749}
750
751start_full_wizard() 
752{
753  # Start the wizard
754  get_sys_type
755  get_target_disk
756  get_target_part
757  get_sys_bootmanager
758
759  # If doing a server setup, need to prompt for some more details
760  if [ "$SYSTYPE" = "server" ] ; then
761     get_root_pw
762     get_user_name
763     get_user_pw
764     get_user_realname
765     get_user_shell
766  fi
767  gen_pc-sysinstall_cfg
768}
769
770# Adjust network options
771change_networking() {
772  get_hostname
773  get_netconfig
774  get_sshd
775  gen_pc-sysinstall_cfg
776}
777
778start_edit_menu_loop()
779{
780
781  while :
782  do
783    dialog --title "PC-BSD Text Install - Edit Menu" --menu "Please select from the following options:" 18 40 10 disk "Change disk ($SYSDISK)" zpool "Change zpool settings" zfs "Change ZFS layout" network "Change networking" view "View install script" edit "Edit install script" back "Back to main menu" 2>/tmp/answer
784    if [ $? -ne 0 ] ; then break ; fi
785
786    ANS="`cat /tmp/answer`"
787
788    case $ANS in
789       disk) change_disk_selection
790             rtn
791             ;;
792    network) change_networking
793             ;;
794        zfs) change_zfs
795             ;;
796      zpool) change_zpool
797             ;;
798       view) more ${CFGFILE}
799             rtn
800             ;;
801       edit) vi ${CFGFILE}
802             rtn
803             ;;
804       back) break ;;
805          *) ;;
806    esac
807  done
808
809}
810
811start_menu_loop()
812{
813
814  while :
815  do
816    dialog --title "PC-BSD Text Install" --menu "Please select from the following options:" 18 40 10 install "Start the installation" wizard "Re-run install wizard" edit "Edit install options" hardware "check compatibility" quit "Quit install wizard" 2>/tmp/answer
817    if [ $? -ne 0 ] ; then break ; fi
818
819    ANS="`cat /tmp/answer`"
820
821    case $ANS in
822     wizard) start_full_wizard
823             rtn
824             ;;
825       edit) start_edit_menu_loop
826             ;;
827    install) echo "This will begin the installation, continue?"
828             echo -e "(y/n)\c"
829             read tmp
830             if [ "$tmp" = "y" -o "$tmp" = "Y" ] ; then
831                ${PCSYS} -c ${CFGFILE}
832                rtn
833             fi
834             ;;
835   hardware) get_hardware_info
836             ;;
837       quit) break ;;
838          *) ;;
839    esac
840  done
841
842}
843
844
845
846if [ -e "$CFGFILE" ] ; then
847   cp ${CFGFILE} ${CFGFILE}.bak
848   rm ${CFGFILE}
849fi
850
851start_full_wizard
852start_menu_loop
853
854exit 0
Note: See TracBrowser for help on using the repository browser.