Shutdown CUCM together with ESXi

SOURCE:
-import APC PCNS 4.1 ova into your ESX
NOTE:
-I use APC PCNS for Linux only. I didn’t use its PCNS because I don’t have APC UPS with NMC.
If I have NMC, I’ll use PCNS instead of apcupsd or still using apcupsd with pcnet settings
If someone want to donate me APC NMC, I’ll glad to test for them

-login as root to pcns and install apcupsd

# yum -y install epel-release
# yum -y install apcupsd
# yum -y install putty

-for linux based apt-get use these commands
# apt-get install apcupsd
# apt-get putty-tools

# yum -y install openssh-clients

-test ssh using admin account

# ssh admin@<CUCM IP>
install pexpect using either these commands
# yum -y install pexpect.noarch
or
# apt-get install python-pexpect

# cat /root/shutcucm.py

import pexpect
import sys
server_ip = “<CUCM IP>”
server_user = “<platform user>”
server_pass = “<platform pass>”
child = pexpect.spawn(‘ssh %s@%s’ % (server_user, server_ip))
child.logfile = sys.stdout
child.timeout = 60
child.expect(‘password:’)
child.sendline(server_pass)
child.expect(‘admin:’)
child.sendline(‘utils system shutdown’)
child.expect(‘Enter (yes/no)?’)
child.sendline(‘yes’)
child.expect(‘ Appliance is being Powered – Off …’)
print ‘Shutdown command successfully sent.’

-connect usb cable from pc to esxi

# cat /etc/apcupsd/apccontrol

#!/bin/sh
prefix=/usr
exec_prefix=/usr
APCPID=/var/run/apcupsd.pid
APCUPSD=/usr/sbin/apcupsd
SHUTDOWN=/sbin/shutdown
SCRIPTSHELL=/bin/sh
SCRIPTDIR=/etc/apcupsd
WALL=wall
if [ -f ${SCRIPTDIR}/${1} -a -x ${SCRIPTDIR}/${1} ]
then
    ${SCRIPTDIR}/${1} ${2} ${3} ${4}
    # exit code 99 means he does not want us to do default action
    if [ $? = 99 ] ; then
        exit 0
    fi
fi
case “$1” in
    killpower)
        echo “Apccontrol doing: ${APCUPSD} –killpower on UPS ${2}” | ${WALL}
        sleep 10
        ${APCUPSD} –killpower
        echo “Apccontrol has done: ${APCUPSD} –killpower on UPS ${2}” | ${WALL}
    ;;
    commfailure)
        echo “Warning communications lost with UPS ${2}” | ${WALL}
    ;;
    commok)
        echo “Communications restored with UPS ${2}” | ${WALL}
    ;;
    powerout)
    ;;
    onbattery)
        echo “Power failure on UPS ${2}. Running on batteries.” | ${WALL}
    ;;
    offbattery)
        echo “Power has returned on UPS ${2}…” | ${WALL}
    ;;
    mainsback)
        if [ -f /etc/apcupsd/powerfail ] ; then
           printf “Continuing with shutdown.”  | ${WALL}
        fi
    ;;
    failing)
        echo “Battery power exhaused on UPS ${2}. Doing shutdown.” | ${WALL}
    ;;
    timeout)
        echo “Battery time limit exceeded on UPS ${2}. Doing shutdown.” | ${WALL}
    ;;
    loadlimit)
        echo “Remaining battery charge below limit on UPS ${2}. Doing shutdown.” | ${WALL}
    ;;
    runlimit)
        echo “Remaining battery runtime below limit on UPS ${2}. Doing shutdown.” | ${WALL}
    ;;
    doreboot)
        echo “UPS ${2} initiating Reboot Sequence” | ${WALL}
        ${SHUTDOWN} -r now “apcupsd UPS ${2} initiated reboot”
    ;;
    doshutdown)
        echo “UPS ${2} initiated Shutdown Sequence” | ${WALL}
        ${SHUTDOWN} -h now “apcupsd UPS ${2} initiated shutdown”
        python /root/shutcucm.py
        echo “****** Executing ESXi Shutdown Command ******” | ${WALL}
        plink -ssh -2 -pw password root@10.0.100.200 “/sbin/shutdown.sh && /sbin/poweroff”
    ;;
    annoyme)
        echo “Power problems with UPS ${2}. Please logoff.” | ${WALL}
    ;;
    emergency)
        echo “Emergency Shutdown. Possible battery failure on UPS ${2}.” | ${WALL}
    ;;
    changeme)
        echo “Emergency! Batteries have failed on UPS ${2}. Change them NOW” | ${WALL}
    ;;
    remotedown)
        echo “Remote Shutdown. Beginning Shutdown Sequence.” | ${WALL}
    ;;
    startselftest)
    ;;
    endselftest)
    ;;
    battdetach)
    ;;
    battattach)
    ;;
    *)  echo “Usage: ${0##*/} command”
        echo ”       warning: this script is intended to be launched by”
        echo ”       apcupsd and should never be launched by users.”
        exit 1
    ;;
esac
Advertisements

Converting swf to pdf

In my case using Ubuntu

# apt-get install libjpeg62-dev libgif-dev libpng12-dev git g++ libfontconfig1-dev libfftw3-dev libpoppler-dev ghostscript imagemagick
# apt-get install libzzip-dev
# wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-7.0.5p3.tar.gz
# tar zxf PDFlib-Lite-7.0.5p3.tar.gz
# cd PDFlib-Lite-7.0.5p3/
# ./configure;make;make install
# cd ..
# git clone git://github.com/matthiaskramm/swftools
# cd swftools
# ./configure;make;make install
# cd ..

-check swf location
open FireFox
download and install “Flash and Video” FireFox plugin from http://www.fnvfox.com/downloads.html
go to http://company.com/ccie-lab-manual/
check total pages
go to page1

Image

# cat wget.sh
#!/bin/sh
if [ $# -lt 3 ]; then
echo “Usage: $0 url_format seq_start seq_end [wget_args]”
exit
fi
url_format=$1
seq_start=$2
seq_end=$3
shift 3
printf “$url_format\\n” `seq $seq_start $seq_end` | wget -i- “$@”

# chmod 755 wget.sh

# cat swf2png.sh
#!/bin/bash
for x in *.swf; do
swfrender ${x} -o ${x%.swf}.png
done

# chmod 755 swf2png.sh

# mkdir CCIEslide
# cd CCIEslide
# ./wget.sh http://company.com/ccie-slides-ppt/content/vector/page%d.swf 1 291
# ./swf2png.sh
# cd ..

download and install CutePDF
using winscp, copy all .png to your pc
open Word and insert all png
print to CutePDF from Word

Converting Non-Bootable iso to Bootable iso

SOURCE: http://htluo.blogspot.com/2010/04/how-to-make-non-bootable-iso-image.html

1. Download and install latest UltraISO from http://www.ezbsystems.com/ultraiso/download.htm
2. Download latest CUCM for example UCSInstall_UCOS_10.5.2.12901-1.sgn.iso from Cisco
3. Open UltraISO
click menu File/Open and open  UCSInstall_UCOS_10.5.2.12901-1.sgn.iso
extract /isolinux/isolinux.bin into desktop
click menu Bootable/Generate Bootinfotable
click menu Bootable/Load Boot File and open isolinux.bin in the desktop
click File/Save As/Bootable_UCSInstall_UCOS_10.5.2.12901-1.sgn.iso