Shammer's Philosophy

My private adversaria

Enable VM tag vlan on ESXi

According to this site, ESXi supports 3 patterns vlan. 1st is Virtual Switch tagging, 2nd is External Switch tagging, 3rd is Virtual Guest tagging.

Virtual Switch tagging

In this environment, ESXi physical NIC sends out packets with vlan tagging. Then, GuestVMs receive a packet without vlan tagging from ESXi physical NIC. So,

  • GuestVMs don't require vlan tagging configuration on Guest OS layer
  • External Switch opposite of ESXi should be configure vlan tag

External Switch tagging

With this configuration, all physical interfaces are untagged on ESXi. ESXi physical NIC and GuestVMs receive a untagged packet only from external switch. External Switch should be configured to send untag packets to ESXi.

Virtual Guest tagging

Configuring vSwitch vlan ID as 4095 enables that GuestVMs can receive all tagged vlan packets. 4095 seems to mean as vlan tagging pass through. I have never tried this but I want to try in the future.

Japanese Locale Configuration

I wrote an article about Debian locale configuration at Debian Locale Configuration - 20180613 - Shammerism, this is based on LANG=C.
Here is a procedure how to configure Japanese locale.

  1. Edit /etc/locale.gen and remove comment of the line which you want to use
  2. Exec locale-gen
  3. export LANG=$LOCALE_YOU_WANT_TO_USE
  4. export LC_ALL=$LANG
  5. locale-gen --purge $LANG
  6. dpkg-reconfigure -f noninteractive locales
  7. update-locale LANG=$LANG LC_ALL=$LANG
  8. perl -v

If no locale errors happened when perl -v, it is okay.
Here is a sample of /etc/default/locale to use ja_JP.UTF-8 as locale.

LANG=ja_JP.UTF-8
LC_ALL=ja_JP.UTF-8

How to resolve package dependency errors after upgrade from wheezy to stretch?

I upgraded wheezy to stretch with apt-get like below.

  1. edit /etc/apt/sources.list, change distribution strings "wheezy" to "stable"
  2. apt-get upgrade
  3. apt-get dist-upgrade

New sources.list is below.

#deb http://ftp.jp.debian.org/debian/ wheezy main
deb http://ftp.jp.debian.org/debian/ stable main
#deb-src http://ftp.jp.debian.org/debian/ wheezy main
deb-src http://ftp.jp.debian.org/debian/ stable main

But, apt-get update always filed with the following messages after upgrade.

# apt-get update
ヒット http://ftp.jp.debian.org stable Release.gpg
ヒット http://ftp.jp.debian.org stable Release
ヒット http://ftp.jp.debian.org stable/main Sources
ヒット http://ftp.jp.debian.org stable/main amd64 Packages
ヒット http://ftp.jp.debian.org stable/main Translation-ja
ヒット http://ftp.jp.debian.org stable/main Translation-en
パッケージリストを読み込んでいます... 完了         
W: Ignoring Provides line with DepCompareOp for package libapt-inst
W: Ignoring Provides line with DepCompareOp for package libapt-pkg
W: Ignoring Provides line with DepCompareOp for package libespeak-dev
W: Ignoring Provides line with DepCompareOp for package libespeak1
W: Ignoring Provides line with DepCompareOp for package libgpgme11-dev
W: Ignoring Provides line with DepCompareOp for package kodi-api-guilib
W: Ignoring Provides line with DepCompareOp for package kodi-api-pvr
W: Ignoring Provides line with DepCompareOp for package libparse-cpan-meta-perl
W: Ignoring Provides line with DepCompareOp for package libjpeg62
W: Ignoring Provides line with DepCompareOp for package lsb
W: Ignoring Provides line with DepCompareOp for package lsb-core
W: Ignoring Provides line with DepCompareOp for package php-psr-log-implementation
W: Ignoring Provides line with DepCompareOp for package php-seclib
W: Ignoring Provides line with DepCompareOp for package php-sabre-http
W: Ignoring Provides line with DepCompareOp for package php-math-biginteger
W: Ignoring Provides line with DepCompareOp for package pkg-config
W: Ignoring Provides line with DepCompareOp for package pypy-cffi
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-min
W: Ignoring Provides line with DepCompareOp for package python-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package python-cffi-backend-api-min
W: Ignoring Provides line with DepCompareOp for package python3-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package python3-cffi-backend-api-min
W: Ignoring Provides line with DepCompareOp for package sagenb-export
W: Ignoring Provides line with DepCompareOp for package sagenb-export
W: これらの問題を解決するためには apt-get update を実行する必要があるかもしれません

Tried apt-get -f install, but I couldn't get out this loop and couldn't find the way to resolve with apt-get.
At last, I resolved this with doing "aptitude safe-upgrade" repeatedly. The time might come to migrate aptitude from apt-get.

SSH access failure with "Too many authentication failures for $USER"

I don't remember since when correctly, but I faced with the problem ssh access failure with the message "Too many authentication failures for $USER". There is no problem if trying ssh access from other host, it is the problem only my main Mac.

I found the debug option of ssh, using -v, then this determination would be done after the public key authentication failure, but I don't want public key authentication to this site. Here is a part of ssh debug output when do "ssh -v user01@X.X.X.X".

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/user01/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering DSA public key: /Users/user01/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /Users/user01/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /Users/user01/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /Users/user01/.ssh/id_ecdsa
debug1: Trying private key: /Users/user01/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Received disconnect from X.X.X.X: 2: Too many authentication failures for admin

I want to do public key authentication against specific hosts, but not all. This server is not my target of public key authentication. In this case, disabling public key authentication with the ssh command line option. The command line parameter "-o PubkeyAuthentication=no" should be used.

Accessing tomcat8 application but received Unsupported major.minor version 52.0

I build war application first time in age, but response is not expected the one, but UnsupportedClassVersionError.

$ curl http://10.255.230.2:8080/myapp/defaultServlet
<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.14 (Debian) - Error report</title><style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style> </head><body><h1>HTTP Status 500 - jp/me/MyServlet : Unsupported major.minor version 52.0 (unable to load class jp.me.MyServlet)</h1><div class="line"></div><p><b>type</b> Exception report</p><p><b>message</b> <u>jp/me/MyServlet : Unsupported major.minor version 52.0 (unable to load class jp.me.MyServlet)</u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b></p><pre>java.lang.UnsupportedClassVersionError: jp/me/MyServlet : Unsupported major.minor version 52.0 (unable to load class jp.me.MyServlet)
	org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2476)
	org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:853)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1263)
	org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1146)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
	org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1580)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1537)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:748)
</pre><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/8.0.14 (Debian) logs.</u></p><hr class="line"><h3>Apache Tomcat/8.0.14 (Debian)</h3></body></html>

This is caused by java version difference, the version of JavaVM running as tomcat8 on my DebianVM is 1.7.0_151, but the version of JavaVM on my Mac that is build environment is 1.8.0_144.

This can be resolved using --target and --source option of javac. I change my ant task like below.

  <target name="compile" depends="cleanup">
    <javac srcdir="${dir.src}" destdir="${dir.classes}" executable="${compiler}" includeantruntime="false" target="7" source="7">
      <classpath refid="classpath.tomcat" />
    </javac>
  </target>

Added target attribute and source attribute.

git pull automation on High Sierra

This is required 2 files at least, one is the script to run git pull, and the other is the plist file to invoke the script. Procedure is below.

  1. Generate the script
  2. Generate the plist file in $HOME/Library/LaunchAgent

script sample

#!/bin/bash
while true;
do
    GW_CHECK=`netstat -rn -f inet | grep default | wc -l`;
    if [ 1 -eq $GW_CHECK ];then
	break;
    else
	sleep 1;
    fi
done

ping -c 1 bitbucket.org > /dev/null
if [ $? -eq 0 ];then
    ST="$HOME/Sites";
    WK="$HOME/Workspace";
    array=("$ST/repo1" "$ST/repo2" "$ST/repo3" "$WK/repo1" "$WK/repo2" "$WK/repo3" "$WK/repo4" "$WK/repo5" "$WK/repo6");
    for repository in ${array[@]};
    do
	cd $repository;
	echo "git pull in $repository...";
	git pull;
    done
    exit 0;
else
    echo "ping to bitbucket.org failed."
    exit 1;
fi

There is a possibility that Wifi setup wouldn't be completed at the time above script invoked from Launch Agent, so I add an operation to check network reachability.

plist sample

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTDPLIST1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
  <dict> 
    <key>Label</key> 
    <string>pull.from.bitbucket</string> 
    <key>UserName</key> 
    <string>aaa</string> 
    <key>GroupName</key> 
    <string>staff</string> 
    <key>ProgramArguments</key> 
    <array> 
      <string>/Users/aaa/bin/pull-from-bitbucket.sh</string> 
    </array> 
    <key>StandardOutPath</key> 
    <string>/Users/aaa/pull-from-bitbucket.stdout</string> 
    <key>StandardErrorPath</key> 
    <string>/Users/aaa/pull-from-bitbucket.stderr</string> 
    <key>RunAtLoad</key> 
    <true/> 
  </dict> 
</plist>