Friday, August 31, 2012

Custom JumpStart finish script

Assume that the setup is according to Custom JumpStart framework setup.
Finish scripts are useful for carrying out customizations at the end of the installation.
In fact some X86 require it ending by the reboot command.
  
The finish scripts are placed in the /jumpstart directory:
 
# cd /jumpstart
# ll
total 145
-r-xr-xr-x   1 root   root     63K Aug 21 15:04 check
drwxr-xr-x   3 root   root      13 Aug 31 11:11 extras
-rw-r--r--   1 root   root    3.2K Aug 31 12:47 finish_x86
-rw-r--r--   1 root   root     693 Aug 31 07:49 profile_x86
-rw-r--r--   1 root   root     277 Aug 29 14:06 rules
-rw-r--r--   1 root   root     112 Aug 31 09:39 rules.ok
 
   
A finish script is referenced in the rules file:
 
# cat rules
 
# keyword & value             begin  profile        finish
# --------------------------- ------ -------------- -----------
  karch i86pc                 -      profile_x86    finish_x86    
    
The following is a sample finish script designed on X86.
It references the extras subdirectory in an effort to complement or simplify the work.

# cat finish_x86
#!/bin/sh
  
BASE=/a
BIN=$BASE/usr/bin
SBIN=$BASE/usr/sbin
  
#.................................................................
# account templates
  
$BIN/cp ${SI_CONFIG_DIR}/extras/.profile $BASE/etc/skel/
$BIN/chown root:other $BASE/etc/skel/.profile
  
$BIN/cp ${SI_CONFIG_DIR}/extras/.bashrc $BASE/etc/skel/
$BIN/chown root:other $BASE/etc/skel/.bashrc
  
$BIN/cp ${SI_CONFIG_DIR}/extras/.inputrc $BASE/etc/skel/
$BIN/chown root:other $BASE/etc/skel/.inputrc
  
$BIN/cp ${SI_CONFIG_DIR}/extras/.screenrc $BASE/etc/skel/
$BIN/chown root:other $BASE/etc/skel/.screenrc
  
#.................................................................
# root customizations
  
$BIN/mkdir $BASE/root
$BIN/cp $BASE/etc/skel/.* $BASE/root/ > /dev/null 2>&1
$BIN/touch $BASE/root/.hushlogin
 
$BIN/ed -s $BASE/etc/passwd <<EOF
,s"\(root:x:0:0:Super-User:\).*"\1/root:/usr/bin/bash"
w
q
EOF
  
$BIN/ed -s $BASE/etc/user_attr <<EOF
,s/root::::/&type=role;/
w
q
EOF
  
#.................................................................
# prime account
   
$BIN/ed -s $BASE/etc/passwd <<EOF
a
prime:x:100:10:Prime Administrator:/home/prime:/usr/bin/bash
.
w
q
EOF
  
$BIN/ed -s $BASE/etc/shadow <<EOF
g/root:/t$
s/root:\([^:]*\):[^:]*:\(.*\)/prime:\1:0:\2/
w
q
EOF
  
$BIN/ed -s $BASE/etc/user_attr <<EOF
a
prime::::type=normal;roles=root;defaultpriv=basic
.
w
q
EOF
  
HOME_BASE_DS=`$SBIN/zfs list -H -o name $BASE/export/home`
$SBIN/zfs create $HOME_BASE_DS/prime > /dev/null 2>&1
  
$BIN/cp $BASE/etc/skel/.* $BASE/export/home/prime/ > /dev/null 2>&1
$BIN/touch $BASE/export/home/prime/.hushlogin
$BIN/chown -R 100:10 $BASE/export/home/prime
  
#.................................................................
# security
  
$BIN/cp ${SI_CONFIG_DIR}/extras/issue $BASE/etc/
$BIN/chown root:sys $BASE/etc/issue
 
$BIN/ed -s $BASE/etc/ssh/sshd_config <<EOF
,s/#Banner/Banner/
w
q
EOF
  
$BIN/ed -s $BASE/etc/security/policy.conf <<EOF
g/CRYPT_DEFAULT=__unix__/t.
s/__unix__/5/
-1,s/CRYPT_DEFAULT=__unix__/#&/
+1,a
  
.
g/#PRIV_DEFAULT=basic/t.
s/#\(.*\)/\1,!proc_info/
w
q
EOF
  
#.................................................................
# automounter customization
  
$BIN/ed -s $BASE/etc/auto_home <<EOF
a
#
# Home directory local entries for automounter
#
*    \$HOST:/export/home/&
#
.
w
q
EOF
   
#.................................................................
# /etc/host customization (?)
  
# RESOLVER=$BASE/etc/resolv.conf
# [ -f $RESOLVER ] && \ 
# DOMAIN=`$BIN/egrep -e domain $RESOLVER | $BIN/cut -d' ' -f2`
# DOMAIN=${DOMAIN:-local}
  
#.................................................................
# other system customization
   
$BIN/cp ${SI_CONFIG_DIR}/extras/syslog.conf $BASE/etc/   
$BIN/cp ${SI_CONFIG_DIR}/extras/pam.conf $BASE/etc/
   
$BIN/cp ${SI_CONFIG_DIR}/extras/user.allow $BASE/etc/
$BIN/chmod 640 $BASE/etc/user.allow
$BIN/chown root:sys $BASE/etc/user.allow
    
$BIN/cp ${SI_CONFIG_DIR}/extras/site.xml $BASE/var/svc/profile/
$BIN/chown root:sys $BASE/var/svc/profile/site.xml
      
#.................................................................
# additional tools
  
${SI_CONFIG_DIR}/extras/install_stb.sh -runmode auto -verbose
  
#.................................................................
# X86 fix - When the boot device isn't where Solaris was installed
  
$BIN/sync
$SBIN/reboot