Saturday, June 18, 2016

 this is bigger than both of us, gracie:  
   
 on a freaking netapp where you don't have 
 freaking access to the freaking etc freaking volume...  
   
 exportfs -io rw,sec=sys,nosuid,anon=0,actual=/vol/cloudqa_system_u2_devel /u2/devel   

Tuesday, June 14, 2016

Monday, June 6, 2016

two interfaces two networks

 two interfaces two networks  
   
 We will assume that we have two interfaces: eth0 and eth1. The two networks that should be used 
 are 10.97.136.0/24 and 192.168.5.0/24 .  
 The first IP address in each respective network is he gateway. Here's how to set thing up in 
 ubuntu to use two interfaces on two networks:  
   
 ...  
   
 /etc/network/interfaces  
   
 # This file describes the network interfaces available on your system  
 # and how to activate them. For more information, see interfaces(5).  
   
 # The loopback network interface  
 auto lo  
 iface lo inet loopback  
   
 # The primary network interface  
 auto eth0  
 iface eth0 inet static  
     address 10.97.136.83  
     netmask 255.255.255.0  
     network 10.97.136.0  
     broadcast 10.97.136.255  
     gateway 10.97.136.1  
     # dns-* options are implemented by the resolvconf package, if installed  
     dns-nameservers 10.97.136.24 10.97.136.21  
     dns-search blah.com  
   
 auto eth1  
 iface eth1 inet static  
     address 192.168.5.55  
     netmask 255.255.255.0  
     network 192.168.5.0  
     
 ...  
     
 Add a second kernel routing table  
 To add a new routing table, edit the file, /etc/iproute2/rt_tables .   
 The eth1's routing table shall be “rt2” with preference to 1.   
   
 ...  
   
 /etc/iproute2/rt_tables  
   
 #  
 # reserved values  
 #  
 255   local  
 254   main  
 253   default  
 0    unspec  
 #  
 # local  
 #  
 #1   inr.ruhep  
 1 rt2  
   
 ...  
   
 Configure rt2 routing table  
   
 # ip route add 192.168.5.0/24 dev eth1 src 192.168.5.55 table rt2  
 # ip route add default via 192.168.5.1 dev eth1 table rt2  
   
 The first command says that the network, 192.168.5.0/24, can be reached through the eth1 interface.   
 The second command sets the default gateway (even if there is none).  
   
 Configure two rules  
   
 # ip rule add from 192.168.5.55/32 table rt2  
 # ip rule add to 192.168.5.55/32 table rt2  
   
 These rules say that both traffic from the IP address, 192.168.5.55, as well as traffic 
 directed to or through this IP address, should use the rt2 routing table.  
   
 Making the Configuration permanent  
   
 The ip rule and ip route commands will become invalid after a re-boot, for which reason they should become part of a script   
 (for example, /etc/rc.local) that will be executed once the network has been started after booting. In ubuntu, these commands   
 can also be written directly into the /etc/network/interfaces file :  
   
 ...  
   
 auto eth1  
 iface eth1 inet static  
     address 192.168.5.55  
     netmask 255.255.255.0  
     network 192.168.5.0  
     post-up ip route add 192.168.5.0/24 dev eth1 src 192.168.5.55 table rt2  
     post-up ip route add default via 192.168.5.1 dev eth1 table rt2  
     post-up ip rule add from 192.168.5.55/32 table rt2  
     post-up ip rule add to 192.168.5.55/32 table rt2  
   
 ...  
   
 If there are more than two networks, a routing table can be created for each additional network analogous to the 
 above, do a step of one number.  
   
 Testing the Configuration  
 The following commands can be used to ensure that the rules as well as the routing entries are working as expected.  
   
 # ip route list table rt2  
   
 default via 192.168.5.1 dev eth1   
 192.168.5.0/24 dev eth1 scope link src 192.168.5.55   
   
 # ip rule show  
   
 0:   from all lookup local   
 32764: from all to 192.168.5.55 lookup rt2   
 32765: from 192.168.5.55 lookup rt2   
 32766: from all lookup main   
 32767: from all lookup default  
   
 pip pip!  

time. it is all about time.

 w32tm /config /manualpeerlist:"time.server,0x1 time.server2,0x1"  
 net stop x32time && net start w32time  
 w32tm /query /status  
 w32tm /resync /nowait  

Wednesday, April 27, 2016

pids and cronjobs and scripts stomping on each other

 i am backing up a whole lot of data via a cronjob.   
 sometimes it takes a really long time. like so long   
 to bleeds over to the next backup cycle. this will   
 help me not run stuff in parallel. yuck. processes   
 stomping all over themselves is no fun.  
   
 this script sets the PID (process id) in a standard place.  
 if the PID is present, the script halts.  
 if the PID is not there, the script creates the PID file.  
 and continues along working.  
 but, if it cannot create, the script dies.  
   
 if the PID isn't present, the script creates the PID file.  
 and continues along working.  
 but, if it cannot create, the script dies.  
   
   
   
    
 PIDFILE=/var/run/script_name.pid  
   
 if [ -f $PIDFILE ]  
 then  
  PID=$(cat $PIDFILE)  
  ps -p $PID > /dev/null 2>&1  
  if [ $? -eq 0 ]  
  then  
   echo "process already running"   
   echo "process already running" | mail -s me@here.org   
   exit 1  
  else  
   echo $$ > $PIDFILE  
   if [ $? -ne 0 ]  
   then  
    echo "could not create PID file"  
    exit 1  
   fi  
  fi  
 else  
  echo $$ > $PIDFILE  
  if [ $? -ne 0 ]  
  then  
   echo "could not create PID file"  
   exit 1  
  fi  
 fi  
   
 work work work  
   
 # remove PID file  
 rm -f $PIDFILE  
     
   

Monday, April 11, 2016

solaris 11 studio 12.3 is a pain to install on zones

 like for serious.  
   
 sol studio needs a cert. 30 days  
 pkg set-publisher -k /root/certs/pkg.oracle.com.key.pem -c /root/certs/pkg.oracle.com.certificate.pem -G "*" -g https://pkg.oracle.com/solarisstudio/release solarisstudio  
   
   
 well. sharing sunstudio12.3 between the host and paravirtualized system is a no go. awesome.  
   
 /etc/zones/zone1.xml has:  
 filesystem special="/opt/solarisstudio12.3" directory="/opt/solarisstudio12.3" type="lofs"/  
   
 let's get rid of it:  
 # zonecfg -z zone1 remove fs dir=/opt/solarisstudio12.3  
   

Tuesday, February 23, 2016

tomcat7 startup for pwm

 /etc/init.d/tomcat7   
   
 #!/bin/sh  
 #  
 # /etc/init.d/tomcat7 -- startup script for the Tomcat 6 servlet engine  
 #  
 # Written by Miquel van Smoorenburg <miquels@cistron.nl>.  
 # Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.  
 # Modified for Tomcat by Stefan Gybas <sgybas@debian.org>.  
 # Modified for Tomcat6 by Thierry Carrez <thierry.carrez@ubuntu.com>.  
 # Modified for Tomcat7 by Ernesto Hernandez-Novich <emhn@itverx.com.ve>.  
 # Additional improvements by Jason Brittain <jason.brittain@mulesoft.com>.  
 #  
 ### BEGIN INIT INFO  
 # Provides:     tomcat7  
 # Required-Start:  $local_fs $remote_fs $network  
 # Required-Stop:   $local_fs $remote_fs $network  
 # Should-Start:   $named  
 # Should-Stop:    $named  
 # Default-Start:   2 3 4 5  
 # Default-Stop:   0 1 6  
 # Short-Description: Start Tomcat.  
 # Description:    Start the Tomcat servlet engine.  
 ### END INIT INFO  
   
 set -e  
   
 PATH=/bin:/usr/bin:/sbin:/usr/sbin  
 NAME=tomcat7  
 DESC="Tomcat servlet engine"  
 DEFAULT=/etc/default/$NAME  
 JVM_TMP=/tmp/tomcat7-$NAME-tmp  
   
 if [ `id -u` -ne 0 ]; then  
     echo "You need root privileges to run this script"  
     exit 1  
 fi  
    
 # Make sure tomcat is started with system locale  
 if [ -r /etc/default/locale ]; then  
     . /etc/default/locale  
     export LANG  
 fi  
   
 . /lib/lsb/init-functions  
   
 if [ -r /etc/default/rcS ]; then  
     . /etc/default/rcS  
 fi  
   
   
 # The following variables can be overwritten in $DEFAULT  
   
 # Run Tomcat 7 as this user ID and group ID  
 TOMCAT7_USER=tomcat7  
 TOMCAT7_GROUP=tomcat7  
   
 # this is a work-around until there is a suitable runtime replacement   
 # for dpkg-architecture for arch:all packages  
 # this function sets the variable OPENJDKS  
 find_openjdks()  
 {  
     for jvmdir in /usr/lib/jvm/java-7-openjdk-*  
     do  
         if [ -d "${jvmdir}" -a "${jvmdir}" != "/usr/lib/jvm/java-7-openjdk-common" ]  
         then  
             OPENJDKS=$jvmdir  
         fi  
     done  
     for jvmdir in /usr/lib/jvm/java-6-openjdk-*  
     do  
         if [ -d "${jvmdir}" -a "${jvmdir}" != "/usr/lib/jvm/java-6-openjdk-common" ]  
         then  
             OPENJDKS="${OPENJDKS} ${jvmdir}"  
         fi  
     done  
 }  
   
 OPENJDKS=""  
 find_openjdks  
 # The first existing directory is used for JAVA_HOME (if JAVA_HOME is not  
 # defined in $DEFAULT)  
 JDK_DIRS="/usr/lib/jvm/default-java ${OPENJDKS} /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun"  
   
 # Look for the right JVM to use  
 for jdir in $JDK_DIRS; do  
   if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then  
     JAVA_HOME="$jdir"  
   fi  
 done  
 export JAVA_HOME  
   
 # Directory where the Tomcat 6 binary distribution resides  
 CATALINA_HOME=/usr/share/$NAME  
   
 # Directory for per-instance configuration files and webapps  
 CATALINA_BASE=/var/lib/$NAME  
   
 # Use the Java security manager? (yes/no)  
 TOMCAT7_SECURITY=no  
   
 # Default Java options  
 # Set java.awt.headless=true if JAVA_OPTS is not set so the  
 # Xalan XSL transformer can work without X11 display on JDK 1.4+  
 # It also looks like the default heap size of 64M is not enough for most cases  
 # so the maximum heap size is set to 128M  
 if [ -z "$JAVA_OPTS" ]; then  
     JAVA_OPTS="-Djava.awt.headless=true -Xmx128M"  
 fi  
   
 # End of variables that can be overwritten in $DEFAULT  
   
 # overwrite settings from default file  
 if [ -f "$DEFAULT" ]; then  
     . "$DEFAULT"  
 fi  
   
 if [ ! -f "$CATALINA_HOME/bin/bootstrap.jar" ]; then  
     log_failure_msg "$NAME is not installed"  
     exit 1  
 fi  
   
 POLICY_CACHE="$CATALINA_BASE/work/catalina.policy"  
   
 if [ -z "$CATALINA_TMPDIR" ]; then  
     CATALINA_TMPDIR="$JVM_TMP"  
 fi  
   
 # Set the JSP compiler if set in the tomcat7.default file  
 if [ -n "$JSP_COMPILER" ]; then  
     JAVA_OPTS="$JAVA_OPTS -Dbuild.compiler=\"$JSP_COMPILER\""  
 fi  
   
 SECURITY=""  
 if [ "$TOMCAT7_SECURITY" = "yes" ]; then  
     SECURITY="-security"  
 fi  
   
 # Define other required variables  
 CATALINA_PID="/var/run/$NAME.pid"  
 CATALINA_SH="$CATALINA_HOME/bin/catalina.sh"  
   
 # Look for Java Secure Sockets Extension (JSSE) JARs  
 if [ -z "${JSSE_HOME}" -a -r "${JAVA_HOME}/jre/lib/jsse.jar" ]; then  
   JSSE_HOME="${JAVA_HOME}/jre/"  
 fi  
   
 catalina_sh() {  
     # Escape any double quotes in the value of JAVA_OPTS  
     JAVA_OPTS="$(echo $JAVA_OPTS | sed 's/\"/\\\"/g')"  
   
     AUTHBIND_COMMAND=""  
     if [ "$AUTHBIND" = "yes" -a "$1" = "start" ]; then  
         JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"  
         AUTHBIND_COMMAND="/usr/bin/authbind --deep /bin/bash -c "  
     fi  
   
     # Define the command to run Tomcat's catalina.sh as a daemon  
     # set -a tells sh to export assigned variables to spawned shells.  
     TOMCAT_SH="set -a; JAVA_HOME=\"$JAVA_HOME\"; source \"$DEFAULT\"; \  
         CATALINA_HOME=\"$CATALINA_HOME\"; \  
         CATALINA_BASE=\"$CATALINA_BASE\"; \  
         JAVA_OPTS=\"$JAVA_OPTS\"; \  
         CATALINA_PID=\"$CATALINA_PID\"; \  
         CATALINA_TMPDIR=\"$CATALINA_TMPDIR\"; \  
         LANG=\"$LANG\"; JSSE_HOME=\"$JSSE_HOME\"; \  
         cd \"$CATALINA_BASE\"; \  
         \"$CATALINA_SH\" $@"  
   
     if [ "$AUTHBIND" = "yes" -a "$1" = "start" ]; then  
         TOMCAT_SH="'$TOMCAT_SH'"  
     fi  
   
     # Run the catalina.sh script as a daemon  
     set +e  
     touch "$CATALINA_PID" "$CATALINA_BASE"/logs/catalina.out  
     chown $TOMCAT7_USER "$CATALINA_PID" "$CATALINA_BASE"/logs/catalina.out  
     start-stop-daemon --start -b -u "$TOMCAT7_USER" -g "$TOMCAT7_GROUP" \  
         -c "$TOMCAT7_USER" -d "$CATALINA_TMPDIR" -p "$CATALINA_PID" \  
         -x /bin/bash -- -c "$AUTHBIND_COMMAND $TOMCAT_SH"  
     status="$?"  
     set +a -e  
     return $status  
 }  
   
 case "$1" in  
  start)  
     if [ -z "$JAVA_HOME" ]; then  
         log_failure_msg "no JDK found - please set JAVA_HOME"  
         exit 1  
     fi  
   
     if [ ! -d "$CATALINA_BASE/conf" ]; then  
         log_failure_msg "invalid CATALINA_BASE: $CATALINA_BASE"  
         exit 1  
     fi  
   
     log_daemon_msg "Starting $DESC" "$NAME"  
     if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \  
         --user $TOMCAT7_USER --exec "$JAVA_HOME/bin/java" \  
         >/dev/null; then  
   
         # Regenerate POLICY_CACHE file  
         umask 022  
         echo "// AUTO-GENERATED FILE from /etc/tomcat7/policy.d/" \  
             > "$POLICY_CACHE"  
         echo "" >> "$POLICY_CACHE"  
         cat $CATALINA_BASE/conf/policy.d/*.policy \  
             >> "$POLICY_CACHE"  
   
         # Remove / recreate JVM_TMP directory  
         rm -rf "$JVM_TMP"  
         mkdir -p "$JVM_TMP" || {  
             log_failure_msg "could not create JVM temporary directory"  
             exit 1  
         }  
         chown $TOMCAT7_USER "$JVM_TMP"  
   
         catalina_sh start $SECURITY  
         sleep 5  
         if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \  
             --user $TOMCAT7_USER --exec "$JAVA_HOME/bin/java" \  
             >/dev/null; then  
             if [ -f "$CATALINA_PID" ]; then  
                 rm -f "$CATALINA_PID"  
             fi  
             log_end_msg 1  
         else  
             log_end_msg 0  
         fi  
     else  
         log_progress_msg "(already running)"  
         log_end_msg 0  
     fi  
     ;;  
  stop)  
     log_daemon_msg "Stopping $DESC" "$NAME"  
   
     set +e  
     if [ -f "$CATALINA_PID" ]; then   
         start-stop-daemon --stop --pidfile "$CATALINA_PID" \  
             --user "$TOMCAT7_USER" \  
             --retry=TERM/20/KILL/5 >/dev/null  
         if [ $? -eq 1 ]; then  
             log_progress_msg "$DESC is not running but pid file exists, cleaning up"  
         elif [ $? -eq 3 ]; then  
             PID="`cat $CATALINA_PID`"  
             log_failure_msg "Failed to stop $NAME (pid $PID)"  
             exit 1  
         fi  
         rm -f "$CATALINA_PID"  
         rm -rf "$JVM_TMP"  
     else  
         log_progress_msg "(not running)"  
     fi  
     log_end_msg 0  
     set -e  
     ;;  
   status)  
     set +e  
     start-stop-daemon --test --start --pidfile "$CATALINA_PID" \  
         --user $TOMCAT7_USER --exec "$JAVA_HOME/bin/java" \  
         >/dev/null 2>&1  
     if [ "$?" = "0" ]; then  
   
         if [ -f "$CATALINA_PID" ]; then  
           log_success_msg "$DESC is not running, but pid file exists."  
             exit 1  
         else  
           log_success_msg "$DESC is not running."  
             exit 3  
         fi  
     else  
         log_success_msg "$DESC is running with pid `cat $CATALINA_PID`"  
     fi  
     set -e  
     ;;  
  restart|force-reload)  
     if [ -f "$CATALINA_PID" ]; then  
         $0 stop  
         sleep 1  
     fi  
     $0 start  
     ;;  
  try-restart)  
     if start-stop-daemon --test --start --pidfile "$CATALINA_PID" \  
         --user $TOMCAT7_USER --exec "$JAVA_HOME/bin/java" \  
         >/dev/null; then  
         $0 start  
     fi  
     ;;  
  *)  
     log_success_msg "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"  
     exit 1  
     ;;  
 esac  
   
 exit 0