Monday, July 29, 2013

slapit

some days you need to build a slap server from scratch on ubuntu 12.04 using an existing ldif.

it is a given that you've pre-pop'd all with the correct stuff in /etc/default/ldap and in /etc/ldap , too. i like to keep a copy of DB_CONFIG around, because it is nifty.
slapit.sh
#!/bin/bash

TIMESTAMP=$(date '+%Y%m%d%H%M')
BACKUPDIR=/nfs/export

/etc/init.d/slapd stop ;
mv /var/lib/ldap /var/lib/ldap-$TIMESTAMP ;
mkdir /var/lib/ldap ;
cp /etc/ldap/DB_CONFIG /var/lib/ldap ;
slapadd -c -l /tmp/$BACKUPDIR/backup.ldif ;
chown -R openldap.openldap /var/lib/ldap ;
/etc/init.d/slapd start
DB_CONFIG
set_cachesize 0 2097152 0
set_lk_max_objects 1500
set_lk_max_locks 1500
set_lk_max_lockers 1500

Monday, July 15, 2013

does a sun box have all the requisite stuff for a flar create?

maybe.

why not just check it out.  if not, then grap the binaries from elsewhere and plop them in the right place.  it works, really.
for those pesky sol 5.7 systems, issue flarcreate -H cause computehash doesn't work with them.

afterward, cp the binaries to the locations.  if in doubt run ldd -f ./binary

nb:
fdo requires a directory (if you have to mkdir -p you have bigger problems):
mkdir /usr/lib/flash/

freely lifted from flarcreate.

#!/bin/ksh 

# list of required utilities.  If you add any to this
# list, be sure to also add it to the $UTIL_LIST variable below!
AWK="/usr/bin/awk"
RM="/usr/bin/rm"
CPIO="/usr/bin/cpio"
COMPRESS="/usr/bin/compress"
UNCOMPRESS="/usr/bin/uncompress"
CAT="/usr/bin/cat"
ZCAT="/usr/bin/zcat"
FIND="/usr/bin/find"
TOUCH="/usr/bin/touch"
MT="/usr/bin/mt"
DD="/usr/bin/dd"
MKDIR="/usr/bin/mkdir"
FLAR="/usr/sbin/flar"
FLARCREATE="/usr/sbin/flarcreate"
COMPUTEHASH="/usr/sbin/computehash"
BPGETFILE="/usr/sbin/bpgetfile"
FDOLIB="/usr/lib/flash/fdo"

UTIL_LIST="$AWK $RM $CPIO $COMPRESS $UNCOMPRESS $CAT $ZCAT $FIND $TOUCH $MT $DD $MKDIR $FLAR $FLARCREATE $COM
PUTEHASH $BPGETFILE $FDOLIB"

##############################################################
# find binaries required to flarcreate.
##############################################################
{
    for i in $UTIL_LIST ; do
        if [ ! -x $i ] ; then
                "$(gettext "Required utility $i is not available.")" $i
        fi
    done
}

exit 0 

strip a sol8/9/10 system for golden image creation

here's a nice script to clean a system prior to making a golden image.

#!/bin/sh

cd `dirname "$0"`

rm -f /var/adm/messages.*
cp /dev/null /var/adm/messages
cp /dev/null /var/adm/wtmp
cp /dev/null /var/adm/sulog
cp /dev/null /var/adm/lastlog
cp /dev/null /var/cron/log
cp /dev/null /var/saf/zsmon/log
cp /dev/null /var/saf/_log
cp /dev/null /var/sadm/system/logs/install_log
cp /dev/null /home/admin/.history
rm -rf /var/sadm/patch/*
rm -f /var/spool/clientmqueue/*
rm -rf /var/tmp/*
rm -rf /var/preserve/*
rm -f /var/sadm/system/logs/sysidtool.log
rm -f /var/sadm/system/logs/begin.log*
rm -f /var/sadm/system/logs/finish.log*

cp -p /etc/shadow ./shadow.$$

echo "Type 'root' 2 times below!"
passwd root
rm -f /etc/oshadow
rm -f /etc/opasswd

./flarcreate \
 -c \
 -x /opt/whereever \
 -a golden \
 -e "a name $1" \
 -n "$1" \
 "$1.flar"


cp -p ./shadow.$$ /etc/shadow
rm ./shadow.$$