Wednesday, October 23, 2013

Ubuntu start Tomcat on boot

Automatic Starting

To make tomcat automatically start when we boot up the computer, you can
add a script to make it auto-start and shutdown.

sudo vi /etc/init.d/tomcat

Now paste the following content:

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/lib/jvm/java-6-sun

case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0
You'll need to make the script executable by running the chmod command:

sudo chmod 755 /etc/init.d/tomcat

The last step is actually linking this script to the startup folders
with a symbolic link. Execute these two commands and we should be on our
way.

sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat

sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Tuesday, October 15, 2013

Install webmin on Ubuntu

1. Download from http://www.webmin.com
2. sudo dpkg -i webmin_x.xxxx_all.deb  (with error)
3. sudo apt-get install -f (will fix the error)
4. https://xxx.xxx:1000
DONE

Tuesday, October 8, 2013

diagnostic cap deploy permission denied public key

Problem:

xxxxx@xxxxx:~/RubyProjects/xxxxx$ bundle exec cap xxxxx deploy:migrations
/usr/local/rvm/gems/ree-1.8.7-2012.02@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:211: warning: Insecure world writable dir /usr/local/rvm/gems in PATH, mode 042777
/usr/local/rvm/gems/ree-1.8.7-2012.02@global/gems/bundler-1.1.4/lib/bundler/runtime.rb:211: warning: Insecure world writable dir /usr/local/rvm/gems in PATH, mode 042777
  * executing `xxxxx'
    triggering start callbacks for `deploy:migrations'
  * executing `multistage:ensure'
  * executing `eighties_bands:ensure'
  * executing `deploy:migrations'
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@xxxxx.unfuddle.com:xxx/xxxxx.git xxxxx-4"
    command finished in 4746ms
  * executing "if [ -d /home/xxxxx/deploy/shared/cached-copy ]; then cd /home/xxxxx/deploy/shared/cached-copy && git fetch -q origin && git reset -q --hard b40a43e351c2107de5c6bc8dae0c70de86465305 && git clean -q -d -x -f; else git clone -q  git@xxx.unfuddle.com:xxx/xxxxx.git /home/xxxxx/deploy/shared/cached-copy && cd /home/xxxxx/deploy/shared/cached-copy && git checkout -q -b deploy b40a43e351c2107de5c6bc8dae0c70de86465305; fi"
    servers: ["115.160.152.28"]
    [115.160.152.28] executing command
 ** [115.160.152.28 :: err] Permission denied (publickey).
 ** [115.160.152.28 :: err] fatal: The remote end hung up unexpectedly
    command finished in 13024ms
failed: "sh -c 'if [ -d /home/xxxxx/deploy/shared/cached-copy ]; then cd /home/xxxxx/deploy/shared/cached-copy && git fetch -q origin && git reset -q --hard b40a43e351c2107de5c6bc8dae0c70de86465305 && git clean -q -d -x -f; else git clone -q  git@xxx.unfuddle.com:xxx/xxxxx.git /home/xxxxx/deploy/shared/cached-copy && cd /home/xxxxx/deploy/shared/cached-copy && git checkout -q -b deploy b40a43e351c2107de5c6bc8dae0c70de86465305; fi'" on 115.160.152.28

Reason:
  git login failed on target machine.

Checkings:
ssh -v git@xxx.unfuddle.com
  • Check this on deployment machine and target server
  • If success, should see this: Authentication succeded (publickey).
  • If denied, will see this: debug1: Authentications that can continue: publickey
    • This means the connection to git server is denied.
Solution:
On deployment machine,

  • ForwardAgent yes (.ssh/config)
  • Check if ssh-agent is running
    • ps aux | grep ssh
  • Add key to ssh:
    • ssh-add ~/.ssh/id_rsa
  • Check key:
    • ssh-add -l
  • Done