SAWADA Keiji
card_capto****@users*****
2006年 3月 12日 (日) 14:18:57 JST
Index: dlkit2/sv/add-client.sub diff -u /dev/null dlkit2/sv/add-client.sub:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/add-client.sub Sun Mar 12 14:18:57 2006 @@ -0,0 +1,452 @@ +#!/bin/sh +# -*- shell-script -*- +# add-client.sub - register client to this kit; generate work space +# for this client and (re)start servers. +# +# Copyright (c) 2005-2006 SAWADA Keiji <card_capto****@users*****> +# Copyright (c) 2005-2006 teelime <teeli****@users*****> +# +# This program is free software and has two license options; GNU +# General Public License, or Common Development and Distribution +# License. You can and must select one when you redistribute and/or +# modify this program. Whatever you choose, this software comes with +# absolutely no warranty. + +set -e + +cl_pool=pool/$CL_CONFIG +trandir=$cl_pool/trandir +cachedir=$cl_pool/cache +client_config=config/client.$CL_CONFIG.conf +config_in=$trandir/config.in + +asserta='== << Assertion >> ==================================================' +assertz='=====================================================================' + +#---------------------------------------------------------------------- +# common subroutines +echon() { + printf "%s" "$@" +} + +typep() { + cmd=$1 ; TMP=$IFS ; IFS=: ; set $PATH + for dir + do + if [ -x "$dir/$cmd" ]; then + echo "$dir/$cmd"; IFS=$TMP; return 0 + fi + done + IFS=$TMP; return 1 +} + +perror() { + echo "ERROR: " "$@" + exit 1 +} + +apply_m4() { + # apply_m4 -Dmacro=value input.m4 > output + (echo ". $trandir/config.in" + echo "m4 \\" + sed -n 's/^\([^#=]*\)=.*$/\1/p' < $config_in | sort -u | sed 's/\(.*\)/-D\1="$\1" \\/' + echo "$@" + ) | sh +} + +#---------------------------------------------------------------------- +# basic preparations + +sanity_check() { + x=${SV_INSTROOT:?"SV_INSTROOT is not set"} + x=${CL_CONFIG:?"CL_CONFIG is not set"} +} + +check_install_type() { + echon "Checking installation type... " + case "$INSTALL_TYPE" in + type1|disklessify) + use_dvddir=false # already installed + use_fin_root=true # rootdir on NFS (post-install) + ;; + type2|netinstall) + use_dvddir=true # going to install + use_fin_root=false # rootdir on hard drive (post-install) + ;; + type3|diskless|type4|offline) + use_dvddir=true # going to install + use_fin_root=true # rootdir on NFS (post-install) + ;; + *) + perror "choose INTALL_TYPE value from: " \ + "disklessify, netinstall, diskless, offline" + ;; + esac + echo "$INSTALL_TYPE" + + case "$BOOT_TYPE" in + newboot) + use_instroot=true # rootdir on NFS at install-time + ;; + *) + perror "BOOT_TYPE should be newboot" + ;; + esac +} + +prepare_pool_dir() { + if [ ! -d $cl_pool ]; then + mkdir $cl_pool + fi + rm -rf $trandir; mkdir $trandir + rm -rf $cachedir; mkdir $cachedir + + ( echo "##################################### begin config/server00.conf" + cat config/server00.conf + echo "##################################### end config/server00.conf" + echo "##################################### begin $client_config" + cat $client_config + echo "##################################### end $client_config" + echo "##################################### begin config/server99.conf" + cat config/server99.conf + echo "##################################### end config/server99.conf" + ) > $config_in +} + +check_dir_existence() { + # subroutine for directory existence checking + var=${1:?} + dir=${2:?} + + if [ -z "$dir" ]; then + perror "$var: is not set" + elif [ ! -d "$dir" ]; then + perror "$var: $dir: does not exist" + fi +} + +check_base_dirs() { + echo "Checking base directory existence..." + + if $use_dvddir; then + check_dir_existence "SV_DVDDIR" "$SV_DVDDIR" + check_dir_existence "SV_PKGDIR" "$SV_PKGDIR" + fi + + if $use_instroot; then + mkdir -p $SV_INSTROOT + check_dir_existence "SV_INSTROOT" "$SV_INSTROOT" + fi + + if $use_fin_root; then + mkdir -p $SV_FIN_ROOT + check_dir_existence "SV_FIN_ROOT" "$SV_FIN_ROOT" + fi +} + +#---------------------------------------------------------------------- +# packages + +enumerate_packages() { + echo "Enumerating packages to install..." + + args="-h $SV_DVDDIR" + test ! -z "$TOC_LOCALE" && args="$args -L $TOC_LOCALE" + for x in $PKG_CLUSTER; do args="$args -c $x"; done + for x in $PKG_CATEGORY; do args="$args -y $x"; done + for x in $PKG_LOCALE; do args="$args -l $x"; done + args="$args $PKG_EXTRA" + + sv/enum-pkgs.pl $args > $trandir/pkglist + echo "Enumerating packages to install... done" +} + +#---------------------------------------------------------------------- +# NFS server stuff + +add_dfstab() { + # subroutine for adding entries of NFS export file + # (=/etc/dfs/dfstab or /etc/exports) + + if [ ! -f $cachedir/instdir_exported ]; then + echo "$fmt" | m4 -DNM="$nm" -DDIR="$SV_DVDDIR" >> $cachedir/dfstab + fi + if [ ! -f $cachedir/fin_root_exported ]; then + echo "$fmt" | m4 -DNM="$nm" -DDIR="$SV_FIN_ROOT" >> $cachedir/dfstab + fi + if [ ! -f $cachedir/swapfile_exported ]; then + echo "$fmt" | m4 -DNM="$nm" -DDIR="$SV_SWAPFILE" >> $cachedir/dfstab + fi + + echo $asserta + echo "NFS server seems not to export required shares." + echo "This script adds missing one, go on attempt." + echo "WARNING: $file will be modified." + echo $assertz + backup_distfile $file + cat $cachedir/dfstab >> $file +} + +warn_no_export() { + # subroutine for warning to add NFS export entries + echo $asserta + cat <<EOF +NFS server seems not to export required shares. This script go on +attempt, but it is unlikely to complete. If NFS doesn't export them +realy, export following directories and run this script again. + +Client needs to be suid-enabled, readable and writable as root. See +man exports (on most Unix systems) or man dfstab (on Solaris family) +for more detail. +EOF + echon "Directories to be exported:" + test ! -f $cachedir/instdir_exported && echon " $SV_DVDDIR" + test ! -f $cachedir/fin_root_exported && echon " $SV_FIN_ROOT" + test ! -f $cachedir/swapfile_exported && echon " $SV_SWAPFILE" + echo '' + echo "Hosts to be exported: $SV_NAME $CL_NAME" + echo $assertz +} + +check_nfs_export() { + echon "Checking NFS server status... " + showmount=`typep showmount` + #showmount=/zzzz # debug dummy + if [ ! -x "$showmount" ]; then + echo "unknown ('showmount' command is not found)" + echo "WARNING: probed NFS export list will be inaccurate" + showmount=true + elif $showmount -e $SV_NAME > /dev/null 2>&1; then + echo "seems working, good" + else + echo "seems stopped, bad situation" + echo "WARNING: going on anyway, but you probably need to (re)start NFS server" + fi + + echon "Checking NFS export list... " + #SV_DVDDIR=/zzzz # debug dummy + #SV_INSTROOT=/zzzz # debug dummy + #SV_FIN_ROOT=/zzzz # debug dummy + #SV_SWAPFILE=/zzzz # debug dummy + set +e + $showmount -e $SV_NAME | tail +2 | while read line; do + set -- $line + echon " $1" + expr "$SV_DVDDIR" : "$1" > /dev/null && echo "$2" > $cachedir/instdir_exported + expr "$SV_INSTROOT" : "$1" > /dev/null && echo "$2" > $cachedir/instroot_exported + expr "$SV_FIN_ROOT" : "$1" > /dev/null && echo "$2" > $cachedir/fin_root_exported + expr "$SV_SWAPFILE" : "$1" > /dev/null && echo "$2" > $cachedir/swapfile_exported + done + set -e + + # if we don't use it, treat it as exported + $use_dvddir || touch $cachedir/instdir_exported + $use_instroot || touch $cachedir/instroot_exported + $use_fin_root || touch $cachedir/fin_root_exported + $use_fin_root || touch $cachedir/swapfile_exported + + echo "" + warn_export=false + if [ ! -f $cachedir/instdir_exported ]; then + echo "WARNING: $SV_NAME does not export $SV_DVDDIR" + warn_export=true + fi + if [ ! -f $cachedir/instroot_exported ]; then + echo "WARNING: $SV_NAME does not export $SV_INSTROOT" + warn_export=true + fi + if [ ! -f $cachedir/fin_root_exported ]; then + echo "WARNING: $SV_NAME does not export $SV_FIN_ROOT" + warn_export=true + fi + if [ ! -f $cachedir/swapfile_exported ]; then + echo "WARNING: $SV_NAME does not export $SV_SWAPFILE" + warn_export=true + fi + + if $warn_export; then + set +e + case "$SV_NFSD_PREF" in + solaris) + fmt="share -F nfs -o rw=NM,root=NM DIR" + file=/etc/dfs/dfstab; nm="$SV_NAME:$CL_NAME"; add_dfstab + shareall + ;; + generic_linux) # untested + fmt="DIR NM(rw,no_root_squash,async)" + file=/etc/dfs/dfstab; nm="$SV_NAME,$CL_NAME"; add_dfstab + exports -ra + ;; + debian) # untested + fmt="DIR NM(rw,no_root_squash,async)" + file=/etc/dfs/dfstab; nm="$SV_NAME,$CL_NAME"; add_dfstab + /etc/init.d/nfs-kernel-server restart + ;; + suse) # RHEL4, CentOS4.1, SUSE9.3 # untested + fmt="DIR NM(rw,no_root_squash,async)" + file=/etc/dfs/dfstab; nm="$SV_NAME,$CL_NAME"; add_dfstab + /etc/init.d/nfs restart + ;; + aix) # untested + fmt="DIR NM,rw=NM" + file=/etc/dfs/dfstab; nm="$SV_NAME:$CL_NAME"; add_dfstab + exports -ra + ;; + generic_bsd) # untested + fmt="DIR NM" + file=/etc/dfs/dfstab; nm="$SV_NAME $CL_NAME"; add_dfstab + exports -ra + ;; + tru64) # untested + fmt="DIR NM -rw=NM" + file=/etc/dfs/dfstab; nm="$SV_NAME:$CL_NAME"; add_dfstab + exports -a + ;; + hpux|irix) # untested + fmt="DIR -rw=NM" + file=/etc/dfs/dfstab; nm="$SV_NAME:$CL_NAME"; add_dfstab + exports -a + ;; + sunos4) # untested + fmt="DIR -rw=NM" + file=/etc/dfs/dfstab; nm="$SV_NAME,$CL_NAME"; add_dfstab + exports -a + ;; + *) + warn_no_export + ;; + esac + set -e + else + echo "Checking NFS export list... done" + fi +} + + +#---------------------------------------------------------------------- +# TFTP stuff + +menu=`echo $CL_MAC | sed -e ''` + +generate_menu_list() { + # subroutine for generating GRUB menu.lst file + apply_m4 -DINSTUPDATE1 sv/grub-menu.m4 > $cl_pool/menu-inst.lst + apply_m4 -DPOSTUPDATE1 sv/grub-menu.m4 > $cl_pool/menu-fin.lst +} + +prepare_tftpboot_newboot() { + echon "Preparing TFTP..." + + echon " pxegrub" + mkdir -p $SV_TFTPROOT/boot + rm -rf $SV_TFTPROOT/boot/grub + cp -rp $SV_DVDDIR/boot/grub $SV_TFTPROOT/boot + + echon " multiboot" + cp $SV_DVDDIR/boot/multiboot $SV_TFTPROOT/boot + + echo " done" +} + +prepare_tftpboot() { + case "$BOOT_TYPE" in + newboot) + generate_menu_list + prepare_tftpboot_newboot + ;; + esac +} + +check_tftpd_newboot() { + echon "Checking TFTP accessibility... " + set +e + tftp=`typep tftp` + set -e + #tftp=/bin/true # debug + if [ -x "$tftp" ]; then + echo "get /boot/grub/pxegrub $cachedir/pxegrub" | $tftp $SV_NAME > /dev/null 2>&1 + echo "get /boot/multiboot $cachedir/multiboot" | $tftp $SV_NAME > /dev/null 2>&1 + + warn_tftp=false + diff $cachedir/pxegrub $SV_TFTPROOT/boot/grub/pxegrub > /dev/null 2>&1 || warn_tftp=true + diff $cachedir/multiboot $SV_TFTPROOT/boot/multiboot > /dev/null 2>&1 || warn_tftp=true + + if $warn_tftp; then + echo "failed" + echo $asserta + echo "Failed to retrieve file(s) from TFTP server." + echo "Probably TFTP server is not running." + echo $assertz + else + echo "done" + fi + else + echo "skipped, 'tftp' command missing" + fi +} + +check_tftpd() { + case "$BOOT_TYPE" in + newboot) check_tftpd_newboot ;; + esac +} + +#---------------------------------------------------------------------- +# DHCP stuff + +generate_dhcpd_conf_newboot() { + echon "Generating DHCP configuration file... " + apply_m4 sv/dhcpd00.conf.m4 > pool/dhcpd00.conf + apply_m4 sv/dhcpd-client.conf.m4 > $cl_pool/dhcpd-client.conf + apply_m4 sv/dhcpd99.conf.m4 > pool/dhcpd99.conf + echo "done" +} + +generate_dhcpd_conf() { + case "$BOOT_TYPE" in + newboot) generate_dhcpd_conf_newboot ;; + esac +} + +#---------------------------------------------------------------------- +generate_sysidcfg() { + if [ "x$CL_SYSIDCFG" = xyes ]; then + echon "Generating sysidcfg file... " + mkdir -p + ( echo "name_service=NONE" + echo "network_interface=primary {dhcp protocol_ipv6=$CL_SYSIDCFG_IPv6}" + echo "security_policy=NONE" + echo "system_locale=$CL_LANG" + echo "timezone=$CL_TIMEZONE" + echo "timeserver=$CL_SYSIDCFG_TIMESERVER" + if [ -f "$CL_SYSIDCFG_X" ]; then cat "$CL_SYSIDCFG_X"; fi + ) > $cl_pool/sysidcfg + echo "done" + fi +} + +#---------------------------------------------------------------------- +prepare_non_std_driver() { + for drv in $NON_STD_DRIVER; do + echo "Generating install script for $drv driver..." + sh ./sv/non-std-driver-setup.sh "$drv" $trandir + done +} + +#---------------------------------------------------------------------- +# main + +sanity_check +check_install_type +prepare_pool_dir +check_base_dirs +$use_dvddir && enumerate_packages +check_nfs_export +prepare_tftpboot +check_tftpd +generate_dhcpd_conf_newboot +generate_sysidcfg +prepare_non_std_driver + +echo "" +echo "Done adding client \"$CL_CONFIG\"" Index: dlkit2/sv/copy-latest-boot_archive-to-tftpboot.sh diff -u /dev/null dlkit2/sv/copy-latest-boot_archive-to-tftpboot.sh:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/copy-latest-boot_archive-to-tftpboot.sh Sun Mar 12 14:18:57 2006 @@ -0,0 +1,13 @@ +#!/bin/sh +# sv.mk-copy-latest-boot_archive-to-tftpboot.sh - copy the latest boot_archive file +# to the tftpboot directory. + +# Copyright (c) 2006 teelime <teeli****@users*****> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License AND Common +# Development and Distribution License. + +. ./config.in + +cp -pf $SV_FIN_ROOT/$BOOT_ARCHIVE_SRC $SV_PXEBOOTDIR Index: dlkit2/sv/dhcpd-client.conf.m4 diff -u /dev/null dlkit2/sv/dhcpd-client.conf.m4:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/dhcpd-client.conf.m4 Sun Mar 12 14:18:57 2006 @@ -0,0 +1,8 @@ + + host CL_NAME { + next-server SV_IPADDR; + option host-name "CL_NAME"; + hardware ethernet CL_MAC; + fixed-address CL_IPADDR; + filename "boot/grub/pxegrub"; + } Index: dlkit2/sv/dhcpd00.conf.m4 diff -u /dev/null dlkit2/sv/dhcpd00.conf.m4:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/dhcpd00.conf.m4 Sun Mar 12 14:18:57 2006 @@ -0,0 +1,12 @@ +ddns-update-style interim; +default-lease-time 3600; +max-lease-time 86400; + +option space grub; +option grub.configfile code 150 = text; + +subnet SUBNET_ADDR netmask SUBNET_MASK { + range LEASE_RANGE; + option subnet-mask SUBNET_MASK; + option broadcast-address BROADCAST; + option routers ROUTER; Index: dlkit2/sv/dhcpd99.conf.m4 diff -u /dev/null dlkit2/sv/dhcpd99.conf.m4:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/dhcpd99.conf.m4 Sun Mar 12 14:18:57 2006 @@ -0,0 +1 @@ +} Index: dlkit2/sv/enum-pkgs.pl diff -u /dev/null dlkit2/sv/enum-pkgs.pl:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/enum-pkgs.pl Sun Mar 12 14:18:57 2006 @@ -0,0 +1,216 @@ +#!/usr/bin/env perl +# enum-pkgs.pl - enumerate packages for Solaris installation +# +# Copyright (c) 2005-2006 SAWADA Keiji <card_capto****@users*****> +# +# This program is free software and has two license options; GNU +# General Public License, or Common Development and Distribution +# License. You can and must select one when you redistribute and/or +# modify this program. Whatever you choose, this software comes with +# absolutely no warranty. + +sub read_pkg_toc { + @_ = glob($pkgtoc_pat); + die ".packagetoc should be one and only under $topdir" if($#_ != 0); + my $pkgtoc = $_[0]; + + open(FD, $pkgtoc) || die; + while($_ = <FD>) { + chomp(); split('='); + if($_[0] eq 'PKG') { + $pkg = $_[1]; + } elsif($_[0] eq 'NAME') { + $pkg_name{$pkg} = $_[1]; + } elsif($_[0] eq 'PKGDIR') { + $pkg_dir{$pkg} = $_[1]; + } elsif($_[0] eq 'CATEGORY') { + $pkg_category{$pkg} = $_[1]; + } elsif($_[0] eq 'SUNW_LOC') { + $pkg_locale{$pkg} = $_[1]; + } + } + close(FD); + printf STDERR "loaded %d entries from %s\n", int(keys(%pkg_name)), $pkgtoc; + 1; +} + +sub read_clst_toc { + @_ = glob($clsttoc_pat); + die ".clustertoc should be one and only under $topdir" if($#_ != 0); + my $clsttoc = $_[0]; + + my $memb_list = []; + open(FD, $clsttoc) || die; + while($_ = <FD>) { + chomp(); split('='); + if($_[0] eq 'CLUSTER' or $_[0] eq 'METACLUSTER') { + $clst_type{$pkg = $_[1]} = $_[0]; + } elsif($_[0] eq 'DESC') { + $clst_desc{$pkg} = $_[1]; + } elsif($_[0] eq 'NAME') { + $clst_name{$pkg} = $_[1]; + } elsif($_[0] eq 'SUNW_CSRMEMBER') { + push @$memb_list, $_[1]; + #print join(',', @$memb_list); + } elsif($_[0] eq 'END') { + $clst_memb{$pkg} = $memb_list; + $memb_list = []; + } + } + close(FD); + printf STDERR "loaded %d entries from %s\n", int(keys(%clst_name)), $clsttoc; + 1; +} + +sub read_order_list { + @_ = glob($order_pat); + die ".order should be one and only under $topdir" if($#_ != 0); + my $order = $_[0]; + + open(FD, $order) || die; + while($_ = <FD>) { + chomp($_); + push(@order_list, $_); + } + close(FD); + printf STDERR "loaded %d entries from %s\n", int(@order_list), $order; + 1; +} + +sub select_packages_by_category { + my ($category) = @_; + my $pkg, @ret, %cats; + + for $pkg (keys(%pkg_category)) { + #printf "%s, %s, %s\n", $category, $pkg, $pkg_category{$pkg};## + %cats = map { $_ => 1} split(',', $pkg_category{$pkg}); + if($cats{$category}){ + push(@ret, $pkg); + } + } + @ret; +} + +sub select_packages_by_locale { + my ($locale) = @_; + my $pkg, @ret, %locs; + + for $pkg (keys(%pkg_locale)) { + #printf "%s, %s, %s\n", $locale, $pkg, $pkg_locale{$pkg};## + %locs = map { $_ => 1} split(',', $pkg_locale{$pkg}); + if($locs{$locale}){ + push(@ret, $pkg); + } + } + @ret; +} + +sub expand_cluster { + my ($pkg) = @_; + my @ret = (); + + if(exists($clst_type{$pkg})) { + my $members = $clst_memb{$pkg}; + foreach $cpkg (@$members) { + @ret = (@ret, expand_cluster($cpkg)); + } + } else { + @ret = ($pkg); + } + return @ret; +} + +sub print_all_clusters { + for $pkg (@pkg_list) { + my $members = $clst_memb{$pkg}; + printf "%s: %s, %s, <%s>\n", $pkg, $clst_type{$pkg}, $clst_name{$pkg}, join(',', @$members); + } +} + +sub reorder_packages { + my %in = map {$_ => ''} @_; + foreach $cand (@order_list) { + if(exists($in{$cand})) { + push(@sorted, $cand); + delete($in{$cand}); + } + } + return (@sorted, keys(%in)); +} + + +#---------------------------------------------------------------------- +# main + +$topdir = '/export/home/install'; + +if($ARGV[0] eq '-h') { # should be first + shift(@ARGV); + $topdir = shift(@ARGV); +} +if($ARGV[0] eq '-L') { # should be first/next + shift(@ARGV); + $loc = shift(@ARGV); + $pkgtoc_pat = "$topdir/Solaris_*/Product/locale/$loc/.packagetoc"; + $clsttoc_pat = "$topdir/Solaris_*/Product/locale/$loc/.clustertoc.default"; +} else { + $pkgtoc_pat = "$topdir/Solaris_*/Product/.packagetoc"; + $clsttoc_pat = "$topdir/Solaris_*/Product/.clustertoc"; +} +$order_pat = "$topdir/Solaris_*/Product/.order"; + +read_pkg_toc; +read_clst_toc; +read_order_list; + +# print join("\n", select_packages_by_category('ja')); +# print join(',', expand_cluster('SUNWCprog')) . "\n"; +# print join("\n", reorder_packages(expand_cluster('SUNWCprog'))); + + @ pkgs = (); +while($arg = shift(@ARGV)) { + if($arg eq '-c') { + $clst = shift(@ARGV); + @_ = expand_cluster($clst); + printf STDERR "selected %d packages by cluster %s\n", int(@_), $clst; + @pkgs = (@pkgs, @_); + next; + + } elsif($arg eq '-C') { + foreach $clst (keys(%clst_type)) { + print "$clst - $clst_name{$clst}\n" + if($clst_type{$clst} eq 'METACLUSTER'); + } + exit(0); + + } elsif($arg eq '-y') { + $category = shift(@ARGV); + @_ = select_packages_by_category($category); + printf STDERR "selected %d packages by category %s\n", int(@_), $category; + @pkgs = (@pkgs, @_); + + } elsif($arg eq '-l') { + $locale = shift(@ARGV); + @_ = select_packages_by_locale($locale); + printf STDERR "selected %d packages by locale %s\n", int(@_), $locale; + @pkgs = (@pkgs, @_); + + } else { + $pkg_dir{$arg} = $arg if not exists $pkg_dir{$arg}; + push(@pkgs, $arg); + } +} + +if($#pkgs < 1) { + print STDERR <<EOT; +Usage: sv.enum-pkgs [-h inst_dir] [-L cat_locale] + [-c cluster] [-y category] [-l locale] [packages] ... + sv.enum-pkgs -C +EOT + exit(1); +} + @ pkgdir = map { $pkg_dir{$_} } reorder_packages(@pkgs); + +printf STDERR "total %d packages selected\n", int(@pkgdir); + +print join("\n", @pkgdir) . "\n"; Index: dlkit2/sv/finish-client.sub diff -u /dev/null dlkit2/sv/finish-client.sub:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/finish-client.sub Sun Mar 12 14:18:57 2006 @@ -0,0 +1,37 @@ +#!/bin/sh + +set -eux +cl_pool=pool/$CL_CONFIG + +#---------------------------------------------------------------------- +# common subroutines + +echon() { + printf "%s" "$@" +} + +backup_distfile() { + file=${1:?} + if [ ! -f "$file.dist" ]; then + cp -p "$file" "$file.dist" + fi +} + +#--------------------------------------------------------------------- +create_boot_archive() { + cp -p $SV_FIN_ROOT/platform/i86pc/boot_archive \ + $SV_PXEBOOTDIR/boot_archive.${CL_NAME} +} + +restart_dhcpd() { + case "$BOOT_TYPE" in + newboot) + echo "Install menu.lst to TFTP directory..." + menu=`echo menu.lst.01$CL_MAC | sed -e 's/://g'` + cp -p $cl_pool/menu-fin.lst $SV_TFTPROOT/$menu + ;; + esac +} + +create_boot_archive +restart_dhcpd Index: dlkit2/sv/get-non-std-drivers.sh diff -u /dev/null dlkit2/sv/get-non-std-drivers.sh:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/get-non-std-drivers.sh Sun Mar 12 14:18:57 2006 @@ -0,0 +1,51 @@ +#!/bin/sh +# -*- shell-script -*- +# sv.get-non-std-drivers - get third party drivers + +WGET=wget +mkdir -p site_drv +cd site_drv + +#---------------------------------------------------------------------- + +xlink() { + # find a file specified by given glob, and make link to it + LINK=${1:?}; FILE=${2:?} + if [ -f "$FILE" ]; then + echo " Found $NAME driver at $FILE ($LINK)" + rm -f "$LINK" + ln "$FILE" "$LINK" + else + echo "ERROR: link=$LINK file=$FILE" + fi +} + +#---------------------------------------------------------------------- +MURAYAMA_URL=homepage2.nifty.com/mrym3/taiyodo + +murayama_extract() { + # usage: murayama_extract NAME MAJOR_VERSION + NAME=${1:?}; MAJ=${2:?} + TGZ="$MURAYAMA_URL/$NAME-$MAJ*.tar.gz" + echo "Extracting $NAME driver archive" + gzip -dc $TGZ | tar xf - + xlink $NAME.i386 $NAME-$MAJ*/i386/$NAME + xlink $NAME.amd64 $NAME-$MAJ*/amd64/$NAME +} + +echo "Fetching archives from http://$MURAYAMA_URL/eng/..." +$WGET -q -m -l 1 http://$MURAYAMA_URL/eng/ +murayama_extract alta 1 +murayama_extract bcf 0 +murayama_extract gani 0 +murayama_extract ife 0 +murayama_extract nfo 0 +murayama_extract ni 0 +murayama_extract rf 1 +murayama_extract rh 1 +#murayama_extract rh 2 +murayama_extract sfe 1 +murayama_extract tne 0 +murayama_extract tu 0 +murayama_extract vel 0 + Index: dlkit2/sv/grub-menu.m4 diff -u /dev/null dlkit2/sv/grub-menu.m4:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/grub-menu.m4 Sun Mar 12 14:18:57 2006 @@ -0,0 +1,96 @@ +default=1 +timeout=10 + +dnl ###################################################################### +ifdef(`INSTUPDATE1', `dnl +define(`LOADER', ``/boot/multiboot'')dnl +define(`KERNFILE', ``kernel/unix'')dnl +define(`MODULE', ``/boot/boot_archive.''CL_NAME``.inst'')dnl +define(`PROPDEF', `fstype=nfs,server-ip=SV_IPADDR,server-name=SV_NAME,server-path=SV_INSTROOT')dnl + +title Install Solaris (diskless-kit) + kernel LOADER KERNFILE - nowin -B PROPDEF + module MODULE + +title Install Solaris with kernel debugger (diskless-kit) + kernel LOADER KERNFILE -kv - nowin -B PROPDEF + module MODULE +')dnl +dnl +dnl ###################################################################### +ifdef(`POSTUPDATE1', `dnl +define(`LOADER', ``/boot/multiboot'')dnl +define(`KERNFILE', ``kernel/unix'')dnl +define(`MODULE', ``/boot/boot_archive.''CL_NAME)dnl +define(`PROPDEF', `fstype=nfs,server-ip=SV_IPADDR,server-name=SV_NAME,server-path=SV_FIN_ROOT')dnl + +title Solaris (diskless-kit) + kernel LOADER KERNFILE -B PROPDEF + module MODULE + +title Solaris with kernel debugger (diskless-kit) + kernel LOADER KERNFILE -kv -B PROPDEF + module MODULE +')dnl +dnl +dnl ###################################################################### +ifdef(`DISKLESSIFY', `dnl +define(`LOADER', ``/boot/multiboot'')dnl +define(`KERNFILE', ``kernel/unix'')dnl +define(`MODULE', ``/boot/boot_archive'')dnl +define(`PROPDEF', `fstype=nfs,server-ip=SV_IPADDR,server-name=SV_NAME,server-path=SV_INSTROOT')dnl +define(`POSTPROPDEF', `fstype=nfs,server-ip=SV_IPADDR,server-name=SV_NAME,server-path=SV_FIN_ROOT')dnl +#---------------------------------------------------------------------- + +title Disklessify Solaris (PXE) * Remove this section later + kernel LOADER KERNFILE - nowin -B PROPDEF + module MODULE +title Disklessify Solaris with kernel debugger (PXE) * Remove this section later + kernel LOADER KERNFILE -kv - nowin -B PROPDEF + module MODULE +title Solaris (PXE) * Use this section after disklessfying + kernel LOADER KERNFILE -B POSTPROPDEF + module MODULE +title Solaris with kernel debugger (PXE) * use this section after disklessifying + kernel LOADER KERNFILE -kv -B POSTPROPDEF + module MODULE +')dnl +dnl +dnl ###################################################################### +ifdef(`NETINSTALL', `dnl +define(`LOADER', ``/boot/multiboot'')dnl +define(`KERNFILE', ``kernel/unix'')dnl +define(`MODULE', ``/boot/boot_archive'')dnl +define(`PROPDEF', `install_media=SV_IPADDR:SV_DVDDIR,fstype=nfs,server-ip=SV_IPADDR,server-name=SV_NAME,server-path=SV_INSTROOT')dnl +#---------------------------------------------------------------------- + +title Install Solaris (PXE) + kernel LOADER KERNFILE - nowin -B PROPDEF + module MODULE +title Install Solaris with kernel debugger (PXE) + kernel LOADER KERNFILE -kv - nowin -B PROPDEF + module MODULE +')dnl +dnl +dnl ###################################################################### +ifdef(`DISKLESS', `dnl +define(`LOADER', ``/boot/multiboot'')dnl +define(`KERNFILE', ``kernel/unix'')dnl +define(`MODULE', ``/boot/boot_archive'')dnl +define(`PROPDEF', `fstype=nfs,server-ip=SV_IPADDR,server-name=SV_NAME,server-path=SV_INSTROOT')dnl +define(`POSTPROPDEF', `fstype=nfs,server-ip=SV_IPADDR,server-name=SV_NAME,server-path=SV_FIN_ROOT')dnl +#---------------------------------------------------------------------- + +title Install Solaris (PXE) * Remove this section later + kernel LOADER KERNFILE - nowin -B PROPDEF + module MODULE +title Install Solaris with kernel debugger (PXE) * Remove this section later + kernel LOADER KERNFILE -kv - nowin -B PROPDEF + module MODULE +title Solaris (PXE) * Use this section after installing + kernel LOADER KERNFILE -B POSTPROPDEF + module MODULE +title Solaris with kernel debugger (PXE) * use this section after installing + kernel LOADER KERNFILE -kv -B POSTPROPDEF + module MODULE +')dnl Index: dlkit2/sv/install-client.sub diff -u /dev/null dlkit2/sv/install-client.sub:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/install-client.sub Sun Mar 12 14:18:57 2006 @@ -0,0 +1,356 @@ +#!/bin/sh +# -*- shell-script -*- +# install-client: + +set -eu +cl_pool=pool/${CL_CONFIG:?"CL_CONFIG not set"} +trandir=$cl_pool/trandir +cachedir=$cl_pool/cache + +OSTYPE=`uname -s` + +#---------------------------------------------------------------------- +# common subroutines +echon() { + printf "%s" "$@" +} + +perror() { + echo "ERROR: " "$@" + exit 1 +} + +backup_distfile() { + file=${1:?} + if [ ! -f "$file.dist" ]; then + cp -p "$file" "$file.dist" + fi +} + +copy_hier() { + # copy_hier src dst + src=${1:?}; dst=${2:?} + (cd "$src" && tar cpf - .) | (cd "$dst" && tar xpf -) +} + +toupper() { + tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ +} + +#---------------------------------------------------------------------- +sanity_check() { + x=${SV_INSTROOT:?"SV_INSTROOT is not set"} + x=${CL_CONFIG:?"CL_CONFIG is not set"} +} + +#---------------------------------------------------------------------- +make_swap_file() { + echon "Making swap file for client... " + + if [ -f $SV_SWAPFILE ]; then + chown root $SV_SWAPFILE + chmod 1600 $SV_SWAPFILE + echo "already done" + else + dd bs=1048576 if=/dev/zero of=$SV_SWAPFILE count=$SV_SWAPSIZE 2> /dev/null + chown root $SV_SWAPFILE + chmod 1600 $SV_SWAPFILE + echo "done" + fi +} + +#---------------------------------------------------------------------- +create_mininfsroot() { + if [ ! -d $SV_INSTROOT/.tmp_proto ]; then + miniroot_img=/var/tmp/dlkit-miniroot-img-$$ + miniroot_mnt=/tmp/dlkit-miniroot-mnt-$$ + mkdir $miniroot_mnt + echon "Extracting original miniroot image to $SV_INSTROOT..." + gzip -dc $SV_DVDDIR/boot/x86.miniroot > $miniroot_img + case "$OSTYPE" in + SunOS) + DEVICE=`lofiadm -a $miniroot_img` + mount -F ufs -r $DEVICE $miniroot_mnt + copy_hier $miniroot_mnt $SV_INSTROOT + umount $miniroot_mnt + lofiadm -d $DEVICE + ;; + Linux) + mount -o loop -t ufs $miniroot_img $miniroot_mnt + copy_hier $miniroot_mnt $SV_INSTROOT + umount $miniroot_mnt + ;; + *) + echo "Not inplemented yet" + ;; + esac + rm $miniroot_img + rmdir $miniroot_mnt + echo "done" + fi + + if [ ! -d $SV_INSTROOT/.tmp_proto ]; then # sanity check + perror "$SV_INSTROOT/.tmp_proto missing, failed to extract miniroot?" + fi + + copy_hier $SV_INSTROOT/.tmp_proto/root/etc $SV_INSTROOT/tmp/root/etc +} + +#---------------------------------------------------------------------- +prepare_installation_env() { + echon "Preparing installation environment..." + + echon " SMF repository" # TODO: still needs this? + backup_distfile $SV_INSTROOT/etc/svc/repository.db + rm -f $SV_INSTROOT/etc/svc/repository-boot* + + echon ", system" + backup_distfile $SV_INSTROOT/etc/system + (cat $SV_INSTROOT/etc/system.dist + echo "" + echo "* Added by dlkit" + echo "set nfs_dlboot:dldebug=1" + echo "set strplumb:strplumbdebug=1" + ) > $SV_INSTROOT/etc/system + + echon ", rtc_config" + rm -f $SV_INSTROOT/etc/rtc_config + echo zone_info=Japan > $SV_INSTROOT/etc/rtc_config + echo zone_lag=-32400 >> $SV_INSTROOT/etc/rtc_config + + echon ", bootenv.rc" + backup_distfile $SV_INSTROOT/boot/solaris/bootenv.rc + rm -f $SV_INSTROOT/boot/solaris/bootenv.rc + cp -p $SV_INSTROOT/.tmp_proto/root/boot/solaris/bootenv.rc \ + $SV_INSTROOT/boot/solaris/bootenv.rc + echon ", md.conf" + rm -f $SV_INSTROOT/kernel/drv/md.conf + cp -p $SV_INSTROOT/.tmp_proto/root/kernel/drv/md.conf \ + $SV_INSTROOT/kernel/drv/md.conf + echon ", sbpro.conf" + rm -f $SV_INSTROOT/kernel/drv/sbpro.conf + cp -p $SV_INSTROOT/platform/i86pc/kernel/drv/sbpro.conf \ + $SV_INSTROOT/kernel/drv/sbpro.conf + + if [ ! -z "$CL_KEYBOARD" ]; then + echon ", keyboard type[$CL_KEYBOARD]" + echo "setprop kbd-type '$CL_KEYBOARD'" >> $SV_INSTROOT/boot/solaris/bootenv.rc + fi + + if [ ! -z "$CL_NFS_CLIENT_VERSION" ]; then + echon ", NFS protocol version" + backup_distfile $SV_INSTROOT/etc/default/nfs + (cat $SV_INSTROOT/etc/default/nfs.dist + echo "NFS_CLIENT_VERSMAX=$CL_NFS_CLIENT_VERSION" + ) > $SV_INSTROOT/etc/default/nfs + fi + + echon ", installation scripts" + backup_distfile $SV_INSTROOT/sbin/install-setup + + case "$INSTALL_TYPE" in + disklessify) + cp -p cl/install-setup-disklessify $SV_INSTROOT/sbin/install-setup + ;; + + netinstall) + cp -p $SV_INSTROOT/sbin/install-setup.dist \ + $SV_INSTROOT/sbin/install-setup + # XXX TODO + cp -p cl.post-install-netinstall $SV_INSTROOT/sbin/post-setup + echo "Reducing the limitation of physical memory size..." + echon " " + patch -p0 < install-setup-reduce-memory-limitation.patch $SV_INSTROOT/sbin/install-setup + ;; + + diskless) + cp -p cl/install-setup-diskless $SV_INSTROOT/sbin/install-setup + ;; + + offline) + ;; + esac + + # TODO: still needs this? + cp /dev/null $SV_INSTROOT/boot/solaris/bootargs.rc + + echo '.' +} + +install_non_std_driver() { + for drv in $NON_STD_DRIVER; do + echo "Installing $drv driver..." + mkdir -p $trandir/site_drv + cp site_drv/$drv.* $trandir/site_drv + sh $trandir/cm.non-std-driver.$drv server $trandir + echo "Installing $drv driver... done" + done +} + +#---------------------------------------------------------------------- +prepare_postinstall_env() { + echo "Preparing post-installation environment..." + + pi_etc=$trandir/etc # postinstall /etc + rm -rf $pi_etc; mkdir $pi_etc + + # /etc/.* + echon " sysidtool" + touch $pi_etc/.UNCONFIGURED + touch $pi_etc/.NFS4inst_state.domain + cp cl/sysidtool $pi_etc/.sysIDtool.state + + # /etc/* + for f in nsswitch.conf defaultdomain resolv.conf auto_master auto_home; do + var=`echo "cl_etc_$f" | sed 's/\./_/g' | toupper` + set +u; eval "val=\$$var"; set -u + if [ -f "$val" ]; then + echon ", $f" + cat $val /dev/null > $pi_etc/$f + fi + done + + # /etc/inet/* + for f in hosts ntp.conf; do + var=`echo "cl_etc_inet_$f" | sed 's/\./_/g' | toupper` + eval "val=\$$var" + if [ -f "$val" ]; then + echon ", inet/$f" + mkdir -p $pi_etc/inet + #backup_distfile $pi_etc/inet/$f + cat $val /dev/null > $pi_etc/inet/$f + fi + done + + if [ "x$CL_ETC_INET_HOSTS" = "x*minimum*" ]; then + echon ", etc/hosts" + mkdir -p $pi_etc/inet + echo "127.0.0.1 localhost loghost" > $pi_etc/inet/hosts + echo "$SV_IPADDR $SV_NAME" >> $pi_etc/inet/hosts + fi + + # /etc/openwin/* + if [ -f "$CL_OWCONFIG" ]; then + echon ", openwin/server/etc/OWconfig" + mkdir -p $pi_etc/openwin/server/etc + cp "$CL_OWCONFIG" $pi_etc/openwin/server/etc/OWconfig + fi + + # /etc/X11/* + if [ -f "$CL_XORGCONF" ]; then + echon ", X11/xorg.conf" + mkdir -p $pi_etc/X11 + cp "$CL_XORGCONF" $pi_etc/X11/xorg.conf + fi + + # /etc/rcS.d/* + if [ ! -z "$CL_HOSTID" ]; then + mkdir -p $pi_etc/rcS.d + set -- `dd bs=1 count=4 if="$CL_HOSTID" 2> /dev/null | od -t x4` + echon ", rcS.d/S05hostid [hostid=0x$2]" + hostid10=`printf "%u" "0x$2"` + (echo 'test ! "x$1" = xstart && exit 0' + echo 'test ! -x /usr/bin/adb && exit 0' + echo "hostid10=$hostid10" + echo 'set -- `echo "$hostid10" | sed "s/\(.\)/ 0x3\1/g"`' + echo '(echo "hw_serial/v$1"; shift' + echo 'for val in "$@"; do echo "+/v$val"; done' + echo 'echo "+/v0") | adb -kw > /dev/null') > $pi_etc/rcS.d/S05hostid + chmod a+x $pi_etc/rcS.d/S05hostid + fi + + # /etc/rc2.d/* + echon ", rc2.d/S98xserver-check" + mkdir -p $pi_etc/rc2.d + cp cl/s98xserver-check $pi_etc/rc2.d/S98xserver-check + chmod a+x $pi_etc/rc2.d/S98xserver-check + + # /etc/nsswitch.conf (again) + case "$CL_ETC_NSSWITCH_CONF" in + '*files*') echo 'files' > $trandir/nsswitch.templ ;; + '*nis*') echo 'nis' > $trandir/nsswitch.templ ;; + '*nisplus*') echo 'nisplus' > $trandir/nsswitch.templ ;; + '*dns*') echo 'dns' > $trandir/nsswitch.templ ;; + '*ldap*') echo 'ldap' > $trandir/nsswitch.templ ;; + esac + + echo "." +} + +#---------------------------------------------------------------------- +transfer_installation_script() { + # copy pool/$CL_CONFIG/trandir to server:$SV_INSTROOT/dlkit(=client:/dlkit) + echon "Transferring install scripts for client... " + + required_files="cl/diskless-installer cl/disklessify cl/dlpkgadd" + + cp $required_files $trandir + mkdir -p $trandir/pkgs.done + + case "$BOOT_TYPE" in + newboot) + # client can access directly + (cd $SV_INSTROOT && rm -rf dlkit) + cp -r $trandir $SV_INSTROOT/dlkit + ;; + esac + + echo "done" +} + +#---------------------------------------------------------------------- +create_boot_archive() { + echo "Creating boot_archive for installation..." + case "$OSTYPE" in + SunOS) + $SV_INSTROOT/boot/solaris/bin/create_ramdisk $SV_INSTROOT + ;; + Linux) + tempdir=/tmp/tmp.$$ + mkdir $tempdir # fails if already there, but it's intentional + files="prtconf lockfs" + for file in $files; do + touch $tempdir/$file; chmod +x $tempdir/$file + done + PATH=${PATH}:$tempdir; export PATH + $SV_INSTROOT/boot/solaris/bin/create_ramdisk $SV_INSTROOT + rm -rf $tempdir + ;; + *) + echo "Not implemented yet" + ;; + esac + + echo "Installing boot_achive for installation to TFTP directory..." + cp -p $SV_INSTROOT/platform/i86pc/boot_archive \ + $SV_PXEBOOTDIR/boot_archive.${CL_NAME}.inst +} + +#---------------------------------------------------------------------- + +restart_dhcpd() { + case "$BOOT_TYPE" in + newboot) + echo "Install menu.lst to TFTP directory..." + menu=`echo menu.lst.01$CL_MAC | sed -e 's/://g'` + cp -p $cl_pool/menu-inst.lst $SV_TFTPROOT/$menu + sv/restart-dhcpd.sh "$SV_DHCPD_PREF" + ;; + esac +} + + +#---------------------------------------------------------------------- + +sanity_check +make_swap_file +[ "$INSTALL_TYPE" != "netinstall" -a "$BOOT_TYPE" = "newboot" ] && create_mininfsroot +prepare_installation_env +install_non_std_driver +prepare_postinstall_env +transfer_installation_script +[ "$INSTALL_TYPE" != "netinstall" -a "$BOOT_TYPE" = "newboot" ] && create_boot_archive +restart_dhcpd + +echo "" +echo "Done installation for client \"$CL_CONFIG\" (on server side)" Index: dlkit2/sv/mk-grubmenu-newbootpostupdate1.sh diff -u /dev/null dlkit2/sv/mk-grubmenu-newbootpostupdate1.sh:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/mk-grubmenu-newbootpostupdate1.sh Sun Mar 12 14:18:57 2006 @@ -0,0 +1,27 @@ +#!/bin/sh +# sv.mk-grubmenu-newbootpostupdate1.sh - utility to generate GRUB's menu.lst file +# when after diskless-installing. + +# Copyright (c) 2006 teelime <teeli****@users*****> +# Copyright (c) 2006 SAWADA Keiji <card_capto****@users*****> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License AND Common +# Development and Distribution License. + +asserta='== << Assertion >> ==================================================' + +apply_m4() { + # apply_m4 -Dmacro=value input.m4 > output + CONFIG=./config.in + (echo ". $CONFIG" + echo "m4 \\" + sed -n 's/^\([^#=]*\)=.*$/\1/p' < $CONFIG | sort -u | sed 's/\(.*\)/-D\1="$\1" \\/' + echo "$@" + ) | sh +} + +. ./config.in + +echo "menu.lst" +apply_m4 -DPOSTUPDATE1 sv.grub-menu.m4 > $SV_PXEBOOTDIR/grub/menu.lst Index: dlkit2/sv/mk-sv-dvddir.sh diff -u /dev/null dlkit2/sv/mk-sv-dvddir.sh:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/mk-sv-dvddir.sh Sun Mar 12 14:18:57 2006 @@ -0,0 +1,53 @@ +#!/bin/sh +# sv.mk-sv-dvddir.sh - utility to copy whole the DVD contents +# to your hard disk. + +# Copyright (c) 2006 teelime <teeli****@users*****> +# Copyright (c) 2006 SAWADA Keiji <card_capto****@users*****> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License AND Common +# Development and Distribution License. + +#---------------------------------------------------------------------- +# subroutines +echon() { + printf "%s" "$@" +} + +copy_hier() { + # copy_hier src dst + src=${1:?}; dst=${2:?} + (cd "$src" && tar cpf - .) | (cd "$dst" && tar xpf -) +} + +. ./config.in + +TMPDIR=/tmp/tmp.$$ +OSTYPE=`uname -s` + +if [ ! -d $SV_DVDDIR ]; then + mkdir $TMPDIR + mkdir $SV_DVDDIR + case "$OSTYPE" in + SunOS) + DEVICE=`lofiadm -a $SV_DVDPATH` + mount -F hsfs -r $DEVICE $TMPDIR + echon "copying whole DVD contents to $SV_DVDDIR..." + copy_hier $TMPDIR $SV_DVDDIR + umount $TMPDIR + lofiadm -d $DEVICE + ;; + Linux) + mount -o loop $SV_DVDPATH $TMPDIR + echon "copying whole DVD contents to $SV_DVDDIR..." + copy_hier $TMPDIR $SV_DVDDIR + umount $TMPDIR + ;; + *) + echo "Not inplemented yet" + ;; + esac + rm -rf $TMPDIR + echo "done" +fi Index: dlkit2/sv/non-std-driver-setup.sh diff -u /dev/null dlkit2/sv/non-std-driver-setup.sh:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/non-std-driver-setup.sh Sun Mar 12 14:18:57 2006 @@ -0,0 +1,311 @@ +#!/bin/sh +# -*- shell-script -*- +# sv.non-std-driver-setup - create script to install third party driver. +# +# Usage: non-std-driver-setup {server | offline | client} [dest_base_dir] + +NAME=${1:?} +DEST_DIR=${2:-.} + +generate_common_part() { + cat <<'EOF' +backup_distfile() { + file=${1:?} + if [ ! -f "$file.dist" ]; then + echo "$NAME: $file: made backup" + cp -p "$file" "$file.dist" + fi +} + +cp_drv() { + src=${1:?}; dst=${2:?} + cp "$src" "$dst" + chown root "$dst" + chgrp sys "$dst" + chmod 755 "$dst" +} + +unused_major() { + awk '{maj[$2]=1} + END{for(i=0;i<512;i++)if(maj[i]==0){print i;exit}}' +} + +add_driver_aliases() { + echo "$NAME: Configuring etc/driver_aliases" + backup_distfile $root/etc/driver_aliases + (cat $root/etc/driver_aliases.dist + echo "$DRIVER_ALIASES" + ) > $root/etc/driver_aliases +} + +add_minor_perm() { + echo "$NAME: Configuring etc/minor_perm" + backup_distfile $root/etc/minor_perm + (cat $root/etc/minor_perm.dist + echo "$NAME:* 0600 root sys" + ) > $root/etc/minor_perm +} + +add_name_to_major() { + echo "$NAME: Configuring etc/name_to_major" + backup_distfile $root/etc/name_to_major + major=`unused_major < $root/etc/name_to_major.dist` + (cat $root/etc/name_to_major.dist + echo "$NAME $major" + ) > $root/etc/name_to_major +} + +add_etc_system() { + echo "$NAME: Configuring etc/system" + backup_distfile $root/etc/system + echo "forceload: drv/$NAME" >> $root/etc/system +} + +add_devicedb_master() { + echo "$NAME: Configuring boot/solaris/devicedb/master" + backup_distfile $root/boot/solaris/devicedb/master + (cat $root/boot/solaris/devicedb/master.dist + echo "$DEVDB_MASTER" + ) > $root/boot/solaris/devicedb/master +} + +fake_add_drv() { + add_driver_aliases + add_minor_perm + add_name_to_major + add_etc_system + add_devicedb_master +} + +case "$1" in + server) + # assuming $CWD/config.in exists. ran at server-side. + # modifies install-time root filesystem. + . $DEST_DIR/config.in + if [ "x$BOOT_TYPE" = xnewboot ]; then + targetdir=$SV_INSTROOT/kernel/drv + root=$SV_INSTROOT + else + echo "ERROR: BOOT_TYPE should be 'newboot'" + fi + ;; + offline) + # assuming $CWD/config.in exists. ran at server-side. + # modifies postinstall-time root filesystem. + . $DEST_DIR/config.in + targetdir=$SV_FIN_ROOT/kernel/drv + root=$SV_FIN_ROOT + ;; + client) + # ran at client-side. + # modifies postinstall-time root filesystem. + targetdir=/a/kernel/drv + root=/a + ;; + *) + echo "Usage: $0 {server | offline | client}" + ;; +esac + +# installs driver executables +copied=n +for srcdir in . site_drv; do + if [ -f ${srcdir}/${NAME} ]; then + cp_drv ${srcdir}/${NAME} ${targetdir}/${NAME} + copied=y${copied} + fi + if [ -f ${srcdir}/${NAME}.i386 ]; then + cp_drv ${srcdir}/${NAME}.i386 ${targetdir}/${NAME} + copied=y${copied} + fi + if [ -f ${srcdir}/${NAME}.amd64 -a -d ${targetdir}/amd64 ]; then + cp_drv ${srcdir}/${NAME}.amd64 ${targetdir}/amd64/${NAME} + copied=y${copied} + fi + if [ -f ${srcdir}/${NAME}.conf ]; then + cp_drv ${srcdir}/${NAME}.conf ${targetdir}/${NAME}.conf + fi +done +if [ $copied = n ]; then + echo "ERROR: ${NAME} driver not copied" +fi + +# update driver registration configuration +fake_add_drv + +EOF +} + +gen_script() { + if [ ! "x$NAME" = "x$DRV_NAME" ]; then return; fi + DRIVER_ALIASES='' + DEVDB_MASTER='' + while read devid desc; do + eval desc=$desc + if [ -z "$DRIVER_ALIASES" ]; then + DRIVER_ALIASES="$NAME \"$devid\"" + else + DRIVER_ALIASES="$DRIVER_ALIASES +$NAME \"$devid\"" + fi + if [ -z "$DEVDB_MASTER" ]; then + DEVDB_MASTER="$devid $devid net pci none \"$desc\"" + else + DEVDB_MASTER="$DEVDB_MASTER +$devid $devid net pci none \"$DRV_FMLY, $desc\"" + fi + done + + (echo "#!/bin/sh" + echo "# installer for $NAME driver" + echo "set -e # stop on any error" + echo "" + echo "NAME='$NAME'" + echo "DEST_DIR='"$DEST_DIR"'" + echo "" + echo "DRIVER_ALIASES='$DRIVER_ALIASES'" + echo "" + echo "DEVDB_MASTER='$DEVDB_MASTER'" + echo "" + + generate_common_part + ) > $DEST_DIR/cm.non-std-driver.$NAME + chmod a+x $DEST_DIR/cm.non-std-driver.$NAME +} + + +DRV_NAME=alta +DRV_FMLY="Sundance Technology ST201" +gen_script <<EOF +pci1186,1002 "D-Link DFE-550TX" +pci13f0,201 "Generic ST201" +EOF + +DRV_NAME=bcf +DRV_FMLY="Broadcom BCM4401" +gen_script <<EOF +pci14e4,4401 "BCM4401" +pci14e4,4402 "BCM4401B0" +pci14e4,170c "BCM4401B0" +EOF + +DRV_NAME=gani +DRV_FMLY="Realtek RTL8169/8110" +gen_script <<EOF +pci10ec,8169 "Generic RTL8169" +pci1259,c107 "corega CG-LAPCIGT/Allied Telesys" +EOF + +DRV_NAME=ife +DRV_FMLY="Intel i8255x" +gen_script <<EOF +pci8086,1029 "82559 Ethernet Controller" +pci8086,1030 "82559 InBusiness 10/100" +pci8086,1229 "82557/8/9 [Ethernet Pro 100]" +pci8086,2449 "82801BA/BAM/CA/CAM Ethernet Controller" +EOF + +DRV_NAME=nfe +DRV_FMLY="nVIDIA nForce ethernet chipsets" +gen_script <<EOF +pci10de,1c3 "nForce Ethernet Controller" +pci10de,66 "nForce2 Ethernet Controller" +pci10de,d6 "nForce3 Ethernet" +pci10de,86 "MCP2A Ethernet Controller" +pci10de,8c "MCP2A Ethernet Controller" +pci10de,e6 "CK8S Ethernet Controller" +pci10de,df "CK8S Ethernet Controller" +pci10de,56 "CK804 Ethernet Controller" +pci10de,57 "CK804 Ethernet Controller" +pci10de,37 "MCP04 Ethernet Controller" +pci10de,38 "MCP04 Ethernet Controller" +EOF + +DRV_NAME=ni +DRV_FMLY="NE2000 compatibles" +gen_script <<EOF +pci1106,926 "VIA 82C926 Amazon (works 16bit transfer only)" +pc10ec,8029 "Realtek 8029 (32bit and 16bit transfer)" +pci1050,940 "Winbond 89C940" +pci1050,5a5a "Winbond 89C940F" +pci11f6,1401 "Compex ReadyLink 2000" +pci8e2e,3000 "KTI ET32P2" +pci4a14,5000 "NetVin NV5000" +pci10bd,e34 "SureCom NE34" +EOF + + +DRV_NAME=rf +DRV_FMLY="Realtek RTL8129/813X/810X" +gen_script <<EOF +pci10ec,8129 "RTL8129 Generic / NDC NE100TX-E" +pci10ec,8138 "RT-8139B/C Generic" +pci1186,1300 "RTL8139B DLink 538TX/530TX+" +pci10ec,8139 "RTL8139/C/C+ Generic" +pci1113,1211 "RTL81xx / SMC2-1211TX/Accton MPX5030" +pci18a,106 "RTL81xx / LevelOne FPC-0106TX" +pci21b,8139 "RTL8139c / Compaq HNE-300" +EOF + + +DRV_NAME=rh +DRV_FMLY="VIA Rhine" +gen_script <<EOF +pci1106,6100 "Rhine-I Generic" +pci1106,3043 "Rhine-I VT86C100A/DL10030A Generic" +pci1106,3065 "Rhine-II VT6102 Generic" +pci1106,3106 "Rhine-III VT6105 Generic" +pci1106,3053 "Rhine-III VT6105M Generic" +EOF + + +DRV_NAME=sfe +DRV_FMLY="SiS SiS900" +gen_script <<EOF +pci1039,900 "SiS900 Generic" +pci100b,20 "NS DP83815 Generic" +pci1039,7016 "SiS7016 Generic" +EOF + + +DRV_NAME=tne +DRV_FMLY="TI ThunderLAN TNETE100A" +gen_script <<EOF +pcie11,ae32 "Compaq Netelligent 10/100 TX" +pcie11,ae34 "Compaq Netelligent 10 T UTP" +pcie11,ae35 "Compaq Integrated NetFlex-3/P" +pcie11,ae40 "Compaq Netelligent Dual10/100 TX UTP" +pcie11,ae43 "Compaq Netelligent Integrated 10/100 TX UTP" +pcie11,b011 "Compaq Netelligent 10/100 TX Embedded UTP" +pcie11,b012 "Compaq Netelligent 10 T/2 PCI UTP/Coax" +pcie11,b030 "Compaq Netelligent 10/100 TX UTP" +pci108d,13 "Olicom OC-2183/2185" +pci108d,14 "Olicom OC-2326" +pci104c,500 "Generic ThunderLAN TNETE100E" +EOF + + +DRV_NAME=tu +DRV_FMLY="DEC 2114x and compatible" +gen_script <<EOF +pci1317,9511 "ADMtek ADM9511" +pci1317,9513 "ADMtek ADM9513" +pci1317,985 "ADMtek AN983/AN983B" +pci1259,a120 "DEC 21x4x tulip-compat / Corega EtherPCI TM" +pci1282,9100 "Davicom DM9100" +pci1282,9102 "Davicom DM9102/9102A" +pci10d9,512 "Macronix MX98713" +pci10d9,531 "Macronix MX98715/25" +pci1011,9 "digital 21140/40A" +pci1011,19 "digital 21142/43" +pci14f1,1803 "Conexant RS7112" +pci11ad,2 "LLC82C168/LLC82C169 PNIC" +pci11ad,c115 "LC82C115 PNIC II" +EOF + + +DRV_NAME=vel +DRV_FMLY="VIA VT6122 GbE" +gen_script <<EOF +pci1106,3119 "velocity VT6122 / Kuroutoshikou GbE" +EOF Index: dlkit2/sv/offline-installer.sub diff -u /dev/null dlkit2/sv/offline-installer.sub:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/offline-installer.sub Sun Mar 12 14:18:57 2006 @@ -0,0 +1,178 @@ +#!/bin/sh +# -*- shell-script -*- + +trandir=cl.trandir +. $trandir/config.in +CL_ROOT=$SV_FIN_ROOT +PKG_DONE=$trandir/pkgs.done +LOGDIR=$CL_ROOT/var/sadm/install/logs +PKGDIR=$SV_PKGDIR + +backup_distfile() { + file=${1:?} + if [ ! -f "$file.dist" ]; then + #echo "$file: made backup" + cp -p "$file" "$file.dist" + fi +} + +get_package_name() { + pkg=${1:?} + grep '^NAME=' $PKGDIR/$pkg/pkginfo | sed 's/^NAME=//' +} + +install_pkgs() { + cat > .v.admin <<EOF +mail= +instance=overwrite +partial=nocheck +runlevel=nocheck +idepend=nocheck +rdepend=nocheck +space=nocheck +setuid=nocheck +conflict=nocheck +action=nocheck +basedir=default +EOF + mkdir -p $LOGDIR + set +e + total=`wc -l < $trandir/pkglist`; total=`expr $total + 0` + i=`ls -1 $PKG_DONE | wc -l`; i=`expr $i + 0` + set -e + while read pkg; do + if [ -f $PKG_DONE/$pkg ]; then continue; fi + + i=`expr $i + 1` + name=`get_package_name "$pkg"` + printf "Installing %s, %s [%d/%d]... " $pkg "$name" $i $total + if pkgadd -d $SV_PKGDIR -a .v.admin -R $SV_FIN_ROOT $pkg > $LOGDIR/fake.$pkg 2>&1; then + echo "done" + touch $PKG_DONE/$pkg + else + echo "**FAILED**" + failed="$failed $pkg" + fi + done < $trandir/pkglist + + echo "" + test ! -z "$failed" && echo "(Failed to install: $failed)" +} + +install_non_std_driver() { + for drv in $NON_STD_DRIVER; do + echo "Installing non-standard driver $drv..." + sh $trandir/cm.non-std-driver.$drv offline + done +} + +config_etc() { + echo "Installing directory under /etc..." + (cd $trandir/etc; find . -type d -print) | while read d; do + mkdir -p $CL_ROOT/etc/$d + done + + echo "Installing files under /etc..." + (cd $trandir/etc; find . -type f -print) | while read f; do + test -f $CL_ROOT/etc/$f || touch $CL_ROOT/etc/$f + backup_distfile $CL_ROOT/etc/$f + cp $trandir/etc/$f $CL_ROOT/etc/$f + done + + if [ -f $trandir/nsswitch.templ ]; then + backup_distfile $CL_ROOT/etc/nsswitch.conf + cp $CL_ROOT/etc/nsswitch.conf.`cat $trandir/nsswitch.templ` \ + $CL_ROOT/etc/nsswitch.conf + fi + + cp /etc/rtc_config $CL_ROOT/etc/rtc_config # copy host config + + backup_distfile $CL_ROOT/etc/default/init + cat $CL_ROOT/etc/default/init.dist | ( + if [ -z "$CL_TIMEZONE" ]; then cat; + else sed '/^TZ=/d'; echo "TZ=$CL_TIMEZONE"; fi + ) | ( + if [ -z "$CL_LANG" ]; then cat; + else sed '/^LANG=/d'; echo "LANG=$CL_LANG"; fi + ) | ( + sed '/^CMASK=/d'; echo "CMASK=022" + ) > $CL_ROOT/etc/default/init + + if [ ! -z "$CL_NFS_CLIENT_VERSION" ]; then + backup_distfile $CL_ROOT/etc/default/nfs + (cat $CL_ROOT/etc/default/nfs.dist + echo "" + echo "#Added by sv.offline-installer" + echo "NFS_CLIENT_VERSMAX=$CL_NFS_CLIENT_VERSION" + ) > $CL_ROOT/etc/default/nfs + fi +} + +config_vfstab() { + echo "Configuring /etc/vfstab..." + + backup_distfile $CL_ROOT/etc/vfstab + mkdir -p $CL_ROOT/$CL_SWAPFILE + + if [ -z "$CL_MOUNT_OPTION" ]; then + r_option="llock" + s_option="-" + else + r_option="llock,$CL_MOUNT_OPTION" + s_option="$CL_MOUNT_OPTION" + fi + + (cat $CL_ROOT/etc/vfstab.dist + echo "$SV_NAME:$SV_FIN_ROOT - / nfs - no $r_option" + echo "$SV_NAME:$SV_SWAPFILE - $CL_SWAPFILE nfs - no $s_option" + echo "$CL_SWAPFILE - - swap - no -" + ) > $CL_ROOT/etc/vfstab +} + +config_postinstall_env() { + echo "Configuring post-installation environment... " + + if [ ! -z "$CL_KEYBOARD" ]; then + backup_distfile $CL_ROOT/boot/solaris/bootenv.rc + (grep -v "^setprop kbd-type" $CL_ROOT/boot/solaris/bootenv.rc.dist + echo "setprop kbd-type '$CL_KEYBOARD'" + ) > $CL_ROOT/boot/solaris/bootenv.rc + fi + + if [ ! -z "$CL_FIN_BOOTFLAG" ]; then + echo "set rb_args '$CL_FIN_BOOTFLAG'" \ + > $CL_ROOT/boot/solaris/bootargs.rc + fi +} + +config_autofs() { + if [ ! -z "$CL_EXPORT_HOME_MODE" ]; then + echo "Setting mode and ownership for $CL_NAME:/export/home..." + mkdir -p $CL_ROOT/export/home + chmod "$CL_EXPORT_HOME_MODE" $CL_ROOT/export/home + chown root $CL_ROOT/export/home + chgrp root $CL_ROOT/export/home + fi +} + +#---------------------------------------------------------------------- + +set -e +case "$1" in + -nopkg) + install_non_std_driver + config_etc + config_vfstab + config_autofs + config_postinstall_env + ;; + + *) + install_pkgs + install_non_std_driver + config_etc + config_vfstab + config_autofs + config_postinstall_env + ;; +esac Index: dlkit2/sv/restart-dhcpd.sh diff -u /dev/null dlkit2/sv/restart-dhcpd.sh:1.1.2.1 --- /dev/null Sun Mar 12 14:18:57 2006 +++ dlkit2/sv/restart-dhcpd.sh Sun Mar 12 14:18:57 2006 @@ -0,0 +1,47 @@ +#!/bin/sh +# -*- shell-script -*- + +set -e + +echon() { + printf "%s" "$@" +} + +pref=${1:?"preference not specified"} +conf=pool/dhcpd.conf + +echo "Gathering DHCP configuration file..." +cat pool/dhcpd00.conf pool/*/dhcpd-client.conf pool/dhcpd99.conf > $conf + +case "$pref" in + isc_csw) + echon "Restarting DHCP server(ISC DHCP/CSW): " + /etc/init.d/cswdhcpd stop + cp "$conf" /opt/csw/etc/dhcpd.conf + /etc/init.d/cswdhcpd start + ;; + debian) + echon "Restarting DHCP server(ISC DHCP/Debian): " + /etc/init.d/dhcp3-server stop + backup_distfile /opt/csw/etc/dhcpd.conf + cp "$conf" /etc/dhcp3/dhcpd.conf + /etc/init.d/dhcp3-server start + ;; + isc_std) + echon "Restarting DHCP server(ISC DHCP): " + /etc/init.d/dhcpd stop + cp "$conf" /etc/dhcpd.conf + /etc/init.d/dhcpd start + ;; + none) + echo '== << Assertion >> ==================================================' + echo "Please restart DHCP server before client boot." + echo "Use $conf as dhcpd.conf" + echo '=====================================================================' + ;; + *) + echo "ERROR: preference $pref not supported" + exit 1 + ;; +esac +echo "done"