Archives for: April 2012

30/04/12

Permalink 03:10:48 pm, by Greg, 188 words, 254 views   English (CA)
Categories: Announcements; Mins. worked: 0

Tomcat launcher

I wrote a quick bash script that lets me start or stop a local instance of tomcat with a single click. If you ONLY intend to ever run one tomcat at a time this will work pretty well.

It uses catalina.sh instead of startup.sh, and sets the CATALINA_PID variable to write a file containing the pid of the launched tomcat.

It first checks to see if there is a pid file at the location set by CATALINA_PID. If there is, the script reads the file and, making the assumption that you want to stop the running tomcat, calls 'catalina.sh stop', waits a few seconds and checks for the pid file again. If the file still exists it runs kill -9 on the pid, hopefully *really* stopping tomcat.

If there is no pid file we assume that tomcat is not running, and run the launch command. In my case I set the java version first, then provide a path for the PID variable, then run 'catalina.sh start'

More details in the code comments.

UPDATED FOR MAC OS: added OS X-specific alerts.

Script attached

26/04/12

Permalink 09:44:40 am, by Greg, 90 words, 162 views   English (CA)
Categories: R & D; Mins. worked: 0

CLI tricks - sudo permission denied

Bash commands using sudo AND redirect can fail on the redirect because sudo permissions are not passed on to the next stage in your command.

For example, the following failed for me with a permission denied error:
sudo echo "something important" >> /etc/apt//mirror.list

It failed because the bit after the final double-quote is a redirect apparently, and not part of the original echo command. The solution is to wrap the whole thing up thusly:
sudo bash -c "echo \"something important\" >> /etc/apt//mirror.list"

25/04/12

Permalink 04:08:53 pm, by Greg, 32 words, 56 views   English (CA)
Categories: Servers; Mins. worked: 90

Repo tweak

Wrote a little script that makes it easier to add a repo to a live apt-mirror and added it to the apt machine admin user's home directory - it's called add-mirror.sh

17/04/12

Permalink 01:04:35 pm, by Greg, 74 words, 64 views   English (CA)
Categories: R & D; Mins. worked: 0

Covert symlinks to files

Had a directory with millions of symlinks. I needed to move the directory without the dependencies imposed by the symlinks. What I wanted was to 'convert' the symlinks to actual files - that is, replace the symlink with a copy of its target file. Found this, which worked a treat. Here's the actual code:

#!/bin/bash
for file in *;
do
link=$(readlink "${file}");
if [ "${link}" ]
then
rm "${file}";
cp -v "${link}" "${file}";
fi;
done;

Maintenance

This blog is the location for all work involving software and hardware maintenance, updates, installs, etc., both routine and urgent, in the server room, the labs and the R&D rooms.

Reports

Categories

April 2012
Sun Mon Tue Wed Thu Fri Sat
 << < Current> >>
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          

XML Feeds