Permalink
Browse files

Add a *VERY* basic text-frontend to "pc-sysinstall". This will

allow users to use text-mode to install PC-BSD / TrueOS. i

Still need to link it into the install media.

Over time this will evolve into a more full-featured installer, but
for now it gets us started.
  • Loading branch information...
1 parent 9558561 commit 0843d04df81c33641eca67f61d057442318b164c @kmoore134 kmoore134 committed Oct 15, 2013
Showing with 331 additions and 0 deletions.
  1. +19 −0 src-sh/Makefile
  2. +54 −0 src-sh/pc-installdialog/Makefile
  3. +257 −0 src-sh/pc-installdialog/pc-installdialog.sh
  4. +1 −0 src-sh/port-files/pkg-plist
View
19 src-sh/Makefile
@@ -36,6 +36,7 @@ SUBTARGETS = \
sub-pcfirst \
sub-pbi \
sub-pbi10 \
+ sub-install \
sub-deinfo \
sub-meta \
sub-warden \
@@ -250,6 +251,19 @@ sub-pcrunx-clean: pc-runxgui/$(MAKEFILE) FORCE
sub-pcrunx-install_subtargets: pc-runxgui/$(MAKEFILE) FORCE
cd pc-runxgui/ && $(MAKE) -f $(MAKEFILE) install
+sub-install: pc-installdialog/$(MAKEFILE) FORCE
+ cd pc-installdialog/ && $(MAKE) -f $(MAKEFILE)
+sub-install-make_default: pc-installdialog/$(MAKEFILE) FORCE
+ cd pc-installdialog/ && $(MAKE) -f $(MAKEFILE)
+sub-install-make_first: pc-installdialog/$(MAKEFILE) FORCE
+ cd pc-installdialog/ && $(MAKE) -f $(MAKEFILE) first
+sub-install-all: pc-installdialog/$(MAKEFILE) FORCE
+ cd pc-installdialog/ && $(MAKE) -f $(MAKEFILE) all
+sub-install-clean: pc-installdialog/$(MAKEFILE) FORCE
+ cd pc-installdialog/ && $(MAKE) -f $(MAKEFILE) clean
+sub-install-install_subtargets: pc-installdialog/$(MAKEFILE) FORCE
+ cd pc-installdialog/ && $(MAKE) -f $(MAKEFILE) install
+
sub-pbi: pbi-manager/$(MAKEFILE) FORCE
cd pbi-manager/ && $(MAKE) -f $(MAKEFILE)
sub-pbi-make_default: pbi-manager/$(MAKEFILE) FORCE
@@ -320,6 +334,7 @@ make_default: sub-libsh-make_default \
sub-pbi-make_default \
sub-pbi10-make_default \
sub-about-make_default \
+ sub-install-make_default \
sub-meta-make_default \
sub-warden-make_default \
sub-pcrunx-make_default \
@@ -343,6 +358,7 @@ make_first: sub-libsh-make_first \
sub-pbi-make_first \
sub-pbi10-make_first \
sub-about-make_first \
+ sub-install-make_first \
sub-meta-make_first \
sub-warden-make_first \
sub-pcrunx-make_first \
@@ -366,6 +382,7 @@ all: sub-libsh-all \
sub-pbi-all \
sub-pbi10-all \
sub-about-all \
+ sub-install-all \
sub-meta-all \
sub-warden-all \
sub-pcrunx-all \
@@ -389,6 +406,7 @@ clean: sub-pbi-clean \
sub-libsh-clean \
sub-lpreserver-clean \
sub-about-clean \
+ sub-install-clean \
sub-meta-clean \
sub-warden-clean \
sub-pcrunx-clean \
@@ -412,6 +430,7 @@ install_subtargets: sub-libsh-install_subtargets \
sub-pbi10-install_subtargets \
sub-lpreserver-install_subtargets \
sub-about-install_subtargets \
+ sub-install-install_subtargets \
sub-meta-install_subtargets \
sub-warden-install_subtargets \
sub-pcrunx-install_subtargets \
View
54 src-sh/pc-installdialog/Makefile
@@ -0,0 +1,54 @@
+#############################################################################
+# Makefile for building: pc-installdialog
+#############################################################################
+
+####### Compiler, tools and options
+
+PREFIX?= /usr/local
+
+AR = ar cqs
+TAR = tar -cf
+COMPRESS = gzip -9f
+COPY = cp -f
+SED = sed
+COPY_FILE = $(COPY)
+COPY_DIR = $(COPY) -R
+INSTALL_FILE = $(COPY_FILE)
+INSTALL_DIR = $(COPY_DIR)
+INSTALL_PROGRAM = $(COPY_FILE)
+DEL_FILE = rm -f
+SYMLINK = ln -f -s
+DEL_DIR = rmdir
+MOVE = mv -f
+CHK_DIR_EXISTS= test -d
+MKDIR = mkdir -p
+
+first: all
+
+all:
+
+clean:
+
+check: first
+
+install_scripts: first FORCE
+ @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)$(PREFIX)/bin/ || $(MKDIR) $(INSTALL_ROOT)$(PREFIX)/bin/
+ -$(INSTALL_FILE) pc-installdialog.sh $(INSTALL_ROOT)$(PREFIX)/bin/pc-installdialog
+
+
+uninstall_scripts: FORCE
+ -$(DEL_FILE) -r $(INSTALL_ROOT)$(PREFIX)/bin/pc-installdialog
+ -$(DEL_DIR) $(INSTALL_ROOT)$(PREFIX)/bin/
+
+
+install_dochmod: first FORCE
+ @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)$(PREFIX)/bin/ || $(MKDIR) $(INSTALL_ROOT)$(PREFIX)/bin/
+ chmod 755 $(PREFIX)/bin/pc-installdialog
+
+
+install: install_scripts install_dochmod FORCE
+
+uninstall: uninstall_scripts FORCE
+
+FORCE:
+
View
257 src-sh/pc-installdialog/pc-installdialog.sh
@@ -0,0 +1,257 @@
+#!/bin/sh
+# License: BSD
+# Author: Kris Moore (kris@pcbsd.org)
+########################################################
+# This script is fairly linear, it will walk through a series of questions
+# and when finished, generate a pc-sysinstall script
+
+# Source our functions
+. /usr/local/share/pcbsd/scripts/functions.sh
+
+TITLE="PC-BSD Install Dialog"
+
+TANS="/tmp/.pcinsdialog.$$"
+
+CFGFILE="/tmp/sys-install.cfg"
+
+get_dlg_ans()
+{
+ if [ -e "$TANS" ] ; then rm ${TANS}; fi
+ if [ -e "$TANS.dlg" ] ; then rm ${TANS}.dlg; fi
+ echo "dialog --title \"$TITLE\" ${@}" >${TANS}.dlg
+ sh ${TANS}.dlg 2>${TANS}
+ exit=$?
+ if [ ! -e "$TANS" ] ; then
+ ANS=""
+ return $exit
+ fi
+ ANS=`cat ${TANS}`
+ return $exit
+}
+
+
+get_sys_type()
+{
+ # First ask the system type
+ get_dlg_ans "--radiolist \"System type\" 12 50 5 desktop \"PC-BSD Desktop\" on server \"TrueOS / FreeBSD Server\" off"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid system type"
+ fi
+ SYSTYPE="$ANS"
+}
+
+
+get_target_disk()
+{
+ # Now we prompt for the disk to install on
+ pc-sysinstall disk-list > /tmp/.dList.$$
+ while read i
+ do
+ fOpt="on"
+ d=`echo $i | cut -d ':' -f 1`
+ desc=`echo $i | cut -d ':' -f 2`
+ dOpts="$dOpts $d \"$desc\" $fOpt"
+ if [ -z "$fOpt" ] ; then fOpt="off"; fi
+ done < /tmp/.dList.$$
+ rm /tmp/.dList.$$
+ get_dlg_ans "--radiolist \"Select target disk\" 12 50 5 ${dOpts}"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid disk selected!"
+ fi
+ SYSDISK="$ANS"
+}
+
+get_target_part()
+{
+ # Now prompt for the full-disk or partition to install onto
+ pc-sysinstall disk-part $SYSDISK > /tmp/.dList.$$
+ dOpts="ALL \"Use entire disk\" on"
+ dFmt=`grep "$SYSDISK-format:" /tmp/.dList.$$ | awk '{print $2}'`
+ if [ "$dFmt" = "MBR" ] ; then
+ dChar="s"
+ DISKFORMAT="MBR"
+ else
+ dChar="p"
+ DISKFORMAT="GPT"
+ fi
+ i=1
+ while :
+ do
+ partRAW="${dChar}${i}"
+ part="${SYSDISK}${dChar}${i}"
+ [ -e "/dev/${part}" ] || break
+ desc="`cat /tmp/.dList.$$ | grep ^${part}-label | cut -d ':' -f 2`"
+ mb="`cat /tmp/.dList.$$ | grep ^${part}-sizemb | awk '{print $2}'`"
+ dOpts="$dOpts $partRAW \"${mb}MB -$desc\" off"
+ i="`expr $i + 1`"
+ done
+ rm /tmp/.dList.$$
+ get_dlg_ans "--radiolist \"Select target partition\" 12 80 5 ${dOpts}"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid disk selected!"
+ fi
+ DISKPART="$ANS"
+}
+
+get_root_pw()
+{
+ while :
+ do
+ get_dlg_ans "--passwordbox 'Enter the root password' 8 30"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid password entered!"
+ fi
+ ROOTPW="$ANS"
+ get_dlg_ans "--passwordbox 'Confirm root password' 8 30"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid password entered!"
+ fi
+ ROOTPWCONFIRM="$ANS"
+ if [ "$ROOTPWCONFIRM" = "$ROOTPW" ] ; then break; fi
+ get_dlg_ans "--yesno 'Password Mismatch, try again?' 8 30"
+ if [ $? -eq 0 ] ; then continue ; fi
+ exit_err "Failed setting root password!"
+ done
+}
+
+get_user_pw()
+{
+ while :
+ do
+ get_dlg_ans "--passwordbox \"Enter the password for $USERNAME\" 8 40"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid password entered!"
+ fi
+ USERPW="$ANS"
+ get_dlg_ans "--passwordbox 'Confirm password' 8 40"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid password entered!"
+ fi
+ USERPWCONFIRM="$ANS"
+ if [ "$USERPWCONFIRM" = "$USERPW" ] ; then break; fi
+ get_dlg_ans "--yesno 'Password Mismatch, try again?' 8 30"
+ if [ $? -eq 0 ] ; then continue ; fi
+ exit_err "Failed setting password!"
+ done
+}
+
+get_user_name()
+{
+ get_dlg_ans "--inputbox 'Enter a username' 8 40"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid username entered!"
+ fi
+ USERNAME="$ANS"
+}
+
+get_user_realname()
+{
+ get_dlg_ans "--inputbox \"Enter the real name for $USERNAME\" 8 40"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid real name entered!"
+ fi
+ USERREALNAME="$ANS"
+}
+
+get_user_shell()
+{
+ get_dlg_ans "--menu \"Select the users shell\" 12 45 10 /bin/sh SH /bin/csh CSH /bin/tcsh TCSH /bin/bash BASH"
+ if [ -z "$ANS" ] ; then
+ exit_err "Invalid SHELL entered!"
+ fi
+ USERSHELL="$ANS"
+}
+
+gen_pc-sysinstall_cfg()
+{
+ # Start the header information
+ echo "# Auto-Generated pc-sysinstall configuration" >${CFGFILE}
+ echo "installInteractive=no" >>${CFGFILE}
+ echo "installMode=fresh" >>${CFGFILE}
+ if [ "$SYSTYPE" = "desktop" ] ; then
+ echo "installType=PCBSD" >>${CFGFILE}
+ echo "netSaveDev=AUTO-DHCP-SLAAC" >> ${CFGFILE}
+ else
+ echo "installType=FreeBSD" >>${CFGFILE}
+ fi
+ echo "packageType=dist" >> ${CFGFILE}
+ if [ "`uname -m`" = "amd64" ] ; then
+ echo "distFiles=base doc games kernel lib32" >> ${CFGFILE}
+ else
+ echo "distFiles=base doc games kernel" >> ${CFGFILE}
+ fi
+ echo "installMedium=local" >>${CFGFILE}
+ echo "localPath=/dist" >>${CFGFILE}
+
+ # Now do the disk block
+ echo "" >> ${CFGFILE}
+ echo "# Disk Setup for $SYSDISK" >> ${CFGFILE}
+ echo "disk0=$SYSDISK" >> ${CFGFILE}
+ echo "partition=$DISKPART" >> ${CFGFILE}
+ echo "bootManager=GRUB" >> ${CFGFILE}
+ echo "partscheme=$DISKFORMAT" >> ${CFGFILE}
+ echo "commitDiskPart" >> ${CFGFILE}
+
+ # Now the partition block
+ echo "" >> ${CFGFILE}
+ echo "# Partition Setup for ${SYSDISK}($DISKPART)" >> ${CFGFILE}
+ echo "# All sizes are expressed in MB" >> ${CFGFILE}
+ echo "# Avail FS Types, UFS, UFS+S, UFS+SUJ, UFS+J, ZFS, SWAP" >> ${CFGFILE}
+ echo "# UFS.eli, UFS+S.eli, UFS+SUJ, UFS+J.eli, ZFS.eli, SWAP.eli" >> ${CFGFILE}
+ echo "disk0-part=ZFS 0 /,/root,/tmp(compress=lz4),/usr(canmount=off),/usr/home,/usr/jails,/usr/obj(compress=lz4),/usr/pbi,/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)" >> ${CFGFILE}
+ echo "disk0-part=SWAP 2000 none" >> ${CFGFILE}
+ echo "commitDiskLabel" >> ${CFGFILE}
+ echo "" >> ${CFGFILE}
+
+ # Now the packages
+ if [ "$SYSTYPE" = "desktop" ] ; then
+ echo "installPackages=pcbsd-base pcbsd-meta-kde pcbsd-meta-kde-accessibility pcbsd-meta-kde-artwork pcbsd-meta-kde-graphics pcbsd-meta-kde-multimedia pcbsd-meta-kde-network pcbsd-meta-kde-pim" >> ${CFGFILE}
+ echo "" >> ${CFGFILE}
+ # Set our markers for desktop to run the first-time boot wizards
+ echo "runCommand=sh /usr/local/share/pcbsd/scripts/sys-init.sh desktop en_US" >> ${CFGFILE}
+ echo "runCommand=touch /var/.runxsetup" >> ${CFGFILE}
+ echo "runCommand=touch /var/.pcbsd-firstboot" >> ${CFGFILE}
+ echo "runCommand=touch /var/.pcbsd-firstgui" >> ${CFGFILE}
+ else
+ echo "installPackages=trueos-base" >> ${CFGFILE}
+ echo "" >> ${CFGFILE}
+ echo "runCommand=sh /usr/local/share/pcbsd/scripts/sys-init.sh server" >> ${CFGFILE}
+ echo "" >> ${CFGFILE}
+
+ # Since on TrueOS, lets save username / passwords
+ echo "rootPass=${ROOTPW}" >> ${CFGFILE}
+ echo "" >> ${CFGFILE}
+ echo "userName=${USERNAME}" >> ${CFGFILE}
+ echo "userPass=${USERPW}" >> ${CFGFILE}
+ echo "userShell=${USERSHELL}" >> ${CFGFILE}
+ echo "userHome=/home/${USERNAME}" >> ${CFGFILE}
+ echo "userGroups=wheel,operator" >> ${CFGFILE}
+ echo "commitUser" >> ${CFGFILE}
+
+ # KPM - TODO, add blocks to create network config, hostname / ssh settings
+ fi
+
+ # Last cleanup stuff
+ echo "" >> ${CFGFILE}
+ echo "runExtCmd=/root/save-config.sh" >> ${CFGFILE}
+ echo "runCommand=newaliases" >> ${CFGFILE}
+
+
+}
+
+# Start the wizard
+get_sys_type
+get_target_disk
+get_target_part
+
+# If doing a server setup, need to prompt for some more details
+if [ "$SYSTYPE" = "server" ] ; then
+ get_root_pw
+ get_user_name
+ get_user_pw
+ get_user_realname
+ get_user_shell
+fi
+
+gen_pc-sysinstall_cfg
+exit 0
View
1 src-sh/port-files/pkg-plist
@@ -22,6 +22,7 @@ bin/pc-xdgutil
bin/pc-firstgui
bin/pc-runxgui
bin/pc-checkxdisplay
+bin/pc-installdialog
bin/enable_user_pefs
sbin/pc-sysinstall
share/lpreserver/backend/zfsmon.sh

0 comments on commit 0843d04

Please sign in to comment.