Showing posts with label NIX administration. Show all posts
Showing posts with label NIX administration. Show all posts

Thursday, March 21, 2013

Creating an Ubuntu VMware player virtual machine for Java Development

Four major steps:

  1. Install Ubuntu
  2. Install Java
  3. Instal Maven (ugh)
  4. Install git
  5. Install Eclipse
Ok, let's get to it.

Ubuntu

Create a new VM in VMWare Player and choose the iso file you downloaded from Ubuntu.  
Set memory to 2gb or you'll live in a world of pain.

Now setup VMWare tools, which won't install correctly until you follow this:
http://askubuntu.com/questions/131351/how-to-install-vmware-tools

Basically, type
sudo apt-get install build-essential linux-headers-$(uname -r)

Then install vmware tools by typing
vmware-config-tools.pl

Accept all the defaults.

Java

Installing Java is well documented as the answer at this URL:

Maven

Maven is the philosophical opposite of Ubuntu so installing it feels a bit like taking a dump on an altar, but many Java projects use it anyway.  Luckily, the install is the least painful thing about Maven (well, as long as you're not using Windows).
sudo apt-get install maven

git

Just follow the bitbucket instructions.  Easy.

Eclipse

Installing the base Eclipse is easy except for the icon.  I won't get into all the plugins you actually need to do work and the hell which can come out of that...
Download Eclipse here.
Open a terminal (click the Ubuntu logo in the upper left and type term and then click the terminal application that appears)
cd ~/Downloads
tar -xvf eclipsefilenamegoeshere.tar.gz
./eclipse &

Eclipse will now launch and a blank icon will appear in the launcher.  If you'd like to fix this, follow these instructions.


Tuesday, March 05, 2013

Adding Modules to Alfresco 4.x

FYI I'm using the Bitnami AMI.

Download and move the module:

  1. cd ~/
  2. wget http://path/to/alfresco_amp_module
  3. sudo mv ~/module.amp /opt/bitnami/apps/alfresco/amps/
  4. sudo /opt/bitnami/ctlscript.sh stop
  5. cd /opt/bitnami/apps/alfresco

Install module: sudo ./apply_amps.sh
(accept the prompts)

Verify module is installed: sudo java -jar alfresco-mmt.jar list /opt/bitnami/apache-tomcat/webapps/alfresco.war

Start up Alfresco again:
sudo /opt/bitnami/ctlscript.sh start

Friday, January 25, 2013

Dynamic DNS on OpenWrt


  1. Search the download area for your version of OpenWrt's packages folder
  2. Then use your browser's find in page and look for "DDNS"
  3. There will be three hits; the first two start with:
    luci-ddns
    ddns-scripts
  4. SCP these files to the router (I use WinSCP).
  5. SSH to the router (I use Putty) and type:
    opkg install ddns{tab} luci-{tab}
  6. Now you can edit the DDNS settings either via the web browser (click the services tab) or
    vi /etc/config/ddns
  7. Make sure to click the "Enable" checkbox and set enabled equal to 1 in the config file!
  8. At this point you could stop and hope it works, but more likely than not it wont.
  9. Try to run the update script and see what happens:
    /usr/lib/ddns/dynamic_dns_updater.sh myddns
  10. This script uses BusyBox's wget to call the DDNS service.  However, whoever put the sed replacements together must use "1234" as their password because just about any special character gets escaped wrong and break DDNS updating.

    Even my email address did not work.

    Luckily with dyndns you can use a username as well-- I set mine to have no special characters.

    There are a number of fixes you can make to the script instead (see first 3 results).



Thursday, December 10, 2009

Installing and Configuring SSH Server on Ubuntu

Ubuntu does not come with any network services enabled, including SSH. Since most often you will want SSH, you've got to install and turn it on. Click here for a really good, succinct post on how to configure SSH and make it a bit more secure too.

Thursday, December 03, 2009

Installing SVN Serve on Ubuntu

Note: if you get an error about the subversion package not being available, change the Ubuntu package repository
[Change Package Repository]
Open System -> Administration -> Synaptic Package Manager -> Settings -> Repositories
Select from the drop down Main server
Click OK
Press the Reload Button and wait for the packages to download
close the Synaptic Package Manager

[Create an svn user]
vi /etc/group
add
svn:x:1000:
or use an available number if 1000 is used

vi /etc/passwd
add
svn:x:1000:GROUP_ID:svn,,,:/home/svn:/bin/bash
replace 1000 with an available user id if 1000 is used

[Install Subversion]
sudo apt-get install subversion
Answer Y to the prompts

[Create Repository Root]
sudo mkdir /var/svn

[Assign SVN ownership to SVN user]
sudo chown -R svn:svn /var/svn

[Start SVN Server]
svnserve -d -r /var/svn

[Create Repository]
svnadmin create /var/svn/YOUR_REPO_NAME

[Modify SVN Server Config]
vi /var/svn/YOUR_REPO_NAME/conf/svnserve.confuncomment the line specifying that username/passwords are stored in a file named passwduncomment the line containing anon-access and set it to none

[Edit list of users]
vi /var/svn/YOUR_REPOSITORY_NAME/conf/passwd
After the line that says [users] you can add users by adding lines in the format
username = password

(optional)[Make SVN start at boot]
[Make SVN start at boot]

Create start script
sudo vi /etc/init.d/svnserve

Paste the following:
svnserve -d -r /var/svn/YOUR_REPOSITORY_NAME
OR
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/svnserve
NAME=svnserve
DESC="SVN Repository Server Daemon"
test -x $DAEMON || exit 0
# Set your repository root here!
OPTIONS="-d -r /var/svn"
# Get lsb functions
#. /lib/lsb/init-functions
. /etc/default/rcS
start() {
echo "Starting $DESC... "
# echo "Starting $DESC: "
if ! start-stop-daemon --chuid svn --start --quiet --oknodo --exec $DAEMON -- $OPTIONS
>/dev/null 2>&1; then
status=$?
echo $status
return $status
fi
log_end_msg 0
return 0
}
case "$1" in
start)
start
;;
stop)
echo "Stopping $DESC: "
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
echo $?
;;
restart|force-reload)
$0 stop
sleep 1
start
#echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0


Make the script executable:
sudo chmod +x /etc/init.d/svnserve

Add the script to the boot sequence:
sudo update-rc.d svnserve defaults

Key thing in the script is to make sure the svn serve user and group is correct or when svnserve runs it will not have permission to modify the repository

(optional) [Perform Initial Import]
sudo svn import /PATH/TO/FOLDER/TO/IMPORT file:///var/svn/YOUR_REPO_NAME -m "Initial Import"

(random) [Restart SVN Server]
sudo pkill -9 svnserve
sudo restart svnserve

You can access the SVN repository at
[Connect To Repository]
URL: svn://YOUR_HOSTNAME_OR_IP/YOUR_REPO_NAME

See http://svnbook.red-bean.com/en/1.1/ch05s02.html for more svnadmin create options

[User permissions]
Edit Users -> must be specified in svnserve.confvi /var/svn/YOUR_REPO_NAME/conf/passwd
Edit permissions -> must be enabled in svnserve.conf
vi /var/svn/YOUR_REPO_NAME/conf/authz

Friday, October 16, 2009

Run a Script as Another User

su - USER_NAME_HERE -c "/path/to/script.sh"

Tuesday, September 08, 2009

Quickly Tuning Tomcat JVM Options

Tomcat runs decently with default settings, but it's performance can be improved by tuning the CATALINA_OPTS string in Tomcat's startup file.

The parameters you'll want to play with most are -Xms and -Xmx which set the Java memory usage bounds. These can be tuned by starting the server and observing whether the Tomcat Java processes cause the server to access swap space. Tune –Xms and –Xmx to maximize the memory given to Tomcat without using swap space.

The -Dserver options hints to Tomcat that the machine is a server that won't be used as a desktop machine.

--XX:PermSize sets the size of the perm gen heap. I have found that this heap reaches some steady state. If the size is too small, when JSPs compile you'll get a PermGen space error. 100M-120M has worked well for the various applications I have worked on.

There are far more in depth tuning resources available if you Google around, but the above should get your started.

Here is a sample Catalina Opts string:

CATALINA_OPTS="-Dserver -Xms2048M -Xmx2048M -XX:PermSize=100M -XX:MaxGCPauseMillis=1000 -XX:GCTimeRatio=8 -DXlp -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=25 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1612 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.snmp.port=16666 -Dcom.sun.management.snmp.acl=true"

Friday, April 10, 2009

Tomcat's Catalina base and Catalina home

Sometimes you see references to tomcat/catalina home and tomcat/catalina base.  What's the difference.  The answer comes from Alessandro A. Garbagnati who writes:

"The first properties (catalina.home) points to the location of the common information, while the other property (catalina.base) points to the directory where all the instance specific information are held."

Basically, this way you can keep one copy of the Tomcat binaries yet use a different configuration by changing the directory to which base points (this directory must contain conf, logs, webapps, work, and temp).

Monday, October 27, 2008

Watchdog Script for a Process

Many long running processes like to just disappear at random intervals, especially late in the day on Friday so that a client calls you at 5pm to fix it. While the following script doesn't solve the root cause of why your program is dying, sometimes there is no reasonable way to fix the root cause and a watchdog timer script will do the job.

Watchdog Script

I've written this with the intention of restarting a Tomcat based service, but if you fiddle with the arguments to FIND_PROC, you can find whatever you want. Just ONE BIG caveat: don't name your watchdog script so that the watchdog finds itself.

The first version of this script works on Solaris:
#!/bin/sh

# Find the pid of the process (PPID will be the shell that started it
) remember no spaces allowed between varnames, just equals sign, and the value
FIND_PROC=`pgrep myprocess`
#FIND_PROC='pgrep testscript`
# if FIND_PROC is empty, the process has died; restart it

if [ -z "${FIND_PROC}" ]; then
echo myprocess failed at `date`
nohup /export/home/path/to/your/process.sh
#nohup /export/home/admin/testscript.sh
fi

exit 0


If you can't use pgrep, there's another way to do this. You can use grep and awk.
FIND_PROC=`ps -ef |grep myprocess | awk '{if ($8 !~ /grep/) print $2}'`

ps picks up the grep process, so the awk script removes this from the listing. The column numbers will likely need adjusting-- just change "print $2" to "print" and run the command from the command line and you will see the whole like. Determine which column holds the PID.

You can read more about awk here.

You might also need to make the ps listing wider than the default 80 characters to avoid having the process name cut off. In this case, your ps may support the --columns argument.

Cron Entry

To edit the cron file, you may first need to set the correct editor. I am assuming this is vi (Solaris likes you to use the absolutely atrocious "ed" by default-- even now in 2008... as if vi isn't archaic enough). If you get stuck inside ed, just type "quit".
export EDITOR="vi"
Then run the crontab program
crontab -e
It may very well be empty if you haven't set up an cron jobs. The format is a columns separated by spaces. Minute, hour, day of month, month, day of week, command to execute. You can either put a number for the time columns, a list of numbers (separated by commas), a range (using a dash) or an asterisk (*) to specify all.

I used the following line for my watchdog script (which logs normal and error output to watchdog.log):
0,10,20,30,40,50 * * * * /export/home/admin/watchdog.sh >> /export/home/admin/wa
tchdog.log 2>&1

(note, I couldn't paste the above line into crontab -e, but I could retype it no problem... go figure)

Wednesday, December 20, 2006

Starting Sun Appserver 8.1 without Typing in a Password

Since the Appserver tends to die quite often, this is good for adding a cronjob to cycle the thing every day.


Edit

/opt/SUNWappserver/sbin/passwordfile



Add the following:

AS_ADMIN_password=XXXXX



then start asadmin like so:

/opt/SUNWappserver/sbin/asadmin start-domain --user admin --passwordfile 
/opt/SUNWappserver/sbin/passwordfile domain1

(note that there should be no line wrap above)

Sunday, November 13, 2005

Transfering Windows 2000 to another drive

This is nice and convoluted-- yay to Microsoft.

Pop in the new hd.

Partition it to have partitions of equal or greater size than the current one.

Open regedit, go to HKEY_LOCAL_MACHINE/system/MountedDevices

If you had the partitions C: and D:, the new ones will be E: and F:. At the bottom of the list in MountedDevices, you will see these drives. Swap them.

Launch Ghost interactively.

Copy each old partition to the new drive.

Turn the machine off.

Disconnect the old drive.

Boot, and hopefully it will all work.


This sequence should skip all the madness I went through with the paging file being on the wrong disk (if you copy C: to E:, windows will know that the new partition is E:, but will look for a page file on C:, which isn't present if you have removed the old drive). Another solution to this problem is to reboot from a win98 floppy and do fdisk /mbr, but I dont have a floppy drive or a win98 boot disk. I suppose ideally you could clone the entire drive, but I had already installed linux on the new drive.

Wednesday, September 28, 2005

Searching directories and subdirectories for a text string

This seems like a basic operation, yet I could not find documentation on it. It's plagued me for years, and I'm proud to tell you, here is the solution:

find path -name "file pattern" -print -exec grep "Regular Expression" {} \;

Note the space between {} and \; if you don't have it, you'll get an "Incomplete Statement" error. Always great when whitespace has meaning...

Tack on &> filename to output to a file. Here's an example:

find . -name "*.doc" -print -exec grep "secrets" {} \; &> FINDOUTPUT.txt

Thursday, August 11, 2005

Export/Import Oracle Database

  • Change to the Oracle user
  • exp username/password@SID file=filename.dmp tables=(table1,table2,...)
    You can leave 'tables' off and the whole database will be exported.
  • Copy the file to the machine you wish to import on
  • imp username/password@SID
  • You will be asked some questions. Use defaults EXCEPT for 'Import entire export file? (no)' type yes instead
  • Ignore errors if you are overwriting data
That's it!

Thursday, July 14, 2005

Installing Apache, PHP, and MySQL on Solaris

Apache

For Solaris:
  • Make sure gcc is installed along with the Sun developer packages and /usr/ccs/bin and /usr/local/bin are in the path.
  • To check whether the developer packages are installed, try 'pkginfo SUNWhea'. If it says package information not found, the packages are not installed.
If gcc is not installed:
  • Download the appropriate gcc package for your machine from sunfreeware.com.
  • Also download libiconv from sunfreeware.com
  • gunzip both
  • pkgadd -d filename for both gcc and libiconv - if you get an error about no space left on the device or unable to unpack datastream, scroll down further for a resolution.
  • pkginfo SUNWhea
    (This is one of the developer packages)
  • The Sun developer packages need to be installed and
    /usr/ccs/bin and /usr/local/bin must be in the path.
    # export PATH=$PATH:/usr/ccs/bin:/usr/local/bin

  • Links:
    http://www-uxsup.csx.cam.ac.uk/install/solaris/pkginst.html

    http://people.arsc.edu/~clark/sun/PkgAnalyze.html

  • If the developer packages are not installed, put the Solaris 9 cd in. Go to /cdrom and navigate the mess until you find the directory Product. Then type the following:

    # pkgadd -d . SUNWhea
  • Remember, you can check whether a package is installed by typing pkginfo pkgname

  • For gcc, install SUNWhea, SUNWsprot, SUNWlibm, SUNWbtool, SUNWarc (but I'm not sure if you need the last one).

If pkgadd fails with "unable to unpack datastream" and "No space left on device"
  • pkgadd -d gcc... fails with the following:

The following packages are available:
1 SMCgcc342 gcc
(sparc) 3.4.2

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: 1

Processing package instance from

gcc
(sparc) 3.4.2
cpio: Cannot write "reloc/include/c++/3.4.2/sparc-sun-solaris2.9/bits/stdc++.h.g
ch/O2g", errno 28, No space left on device

...

pkgadd: ERROR: attempt to process datastream failed
- process failed, exit code 24
pkgadd: ERROR: unable to unpack datastream

Installation of failed (internal error).
No changes were made to the system.

  • A df -k shows enough free space on the destination slice.
  • This means that /var is being filled up as pkgadd extracts into /var/tmp. The following page details this:
Links:
http://www.brandonhutchinson.com/No_space_left_on_device_when_installing_packages.html

  • The steps to take are as follows:
  • # pkgtrans packagename /path/to/large/file/system
  • # pkgadd -d /path/to/large/file/system
  • If it prompts you to install the package again after "Installation successful", just CTRL-C back to the prompt.
  • Then
    # rm -rf /path/to/large/file/system/$PGKNAME where pkgname=SMCgcc342 in this example

For SuSE:
I ran into a problem with some library missing but I forget which. I found an RPM however.

  • Unzip/untar tar zxvf httpd-* and cd http-*
  • ./configure --enable-so --enable-cgi --enable-ssl
Hopefully this works.

Links:
http://dan.drydog.com/apache2php.html


More Apache

  • make
  • make install
  • edit httpd.conf and set the servername
  • for solaris 9, set Group to nobody!

  • # Make sure there's only **1** line with this directive:
    LoadModule php4_module modules/libphp4.so

  • # Add index.php to your DirectoryIndex line:
    DirectoryIndex index.html index.php

# Uncomment one of the following (but not both)
# Use for PHP 4.x:
AddHandler php-script php
# Use for PHP 5.x:
#AddHandler php5-script php

AddType text/html php

# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps

PHP

  • gunzip php
  • ./configure --with-apxs2=/usr/local/apache2/bin/apxs --prefix=/usr/local/apache2/php --disable-cgi --with-mysql
if you get an error about libgcc_s.so.1
export LD_LIBRARY_PATH=/usr/local/lib

or whatever the path you have on your machine
  • # cp -p php.ini-recommended /usr/local/apache/php/php.ini

MySQL

Initialize the database:
  • copy over your database

    -or-
  • if you are not importing an existing database, the database needs to be initiliazed using the configure script or mysql_install_db in $mySQL/bin
  • groupadd mysql
  • useradd -c "MySQL Server" -d /dev/null -g mysql -s /bin/false mysql
  • chown -R mysql:mysql /usr/local/mysql
  • run using /mysqld --user=mysql &

Dumping an Existing MySQL database
mysqldump --user=blar --password=barf DBNAME > DBDUMP.sql

Loading the dump into MySQL
mysql --user=blar --password=barf < DBDUMP.sql

Dump the mysql database if you want user information to be transferred as well.

XRMS and phpMyAdmin

Set of both of these is fairly straight forward. Just untar xrms and phpmyadmin inside apache's document root, in this case in /usr/local/apache2/htdocs.

Modify vars.php for XRMS.

phpMyAdmin also has an ini file in its directory, which is commented well.

Friday, June 03, 2005

Quick script to search files in unix

for i in `find /opt/procmgr65`
do
echo $i
grep Nobody $i
done

Just replace /opt/procmgr65 with the directory you want to search. You can put this all on one line too.

Wednesday, April 13, 2005

Changing the Network Configuration on a UNIX OS

One Time Only

Set the ip address and netmask:
ipconfig $INTERFACE $IP netmask $NETMASK

Add a gateway:
route flush
route add default $GATEWAY

Add nameservers/DNS servers:
Edit to /etc/resolv.conf
The format is nameserver [tab] ip_address_of_name_server

Permanent Changes
Depends on the OS.

FreeBSD:
Edit /etc/rc.conf or use /stand/sysinstall, configure, network interface

Solaris:

/etc/hostname.$INTERFACENAME
/etc/hostnames
/etc/hosts
/etc/netmasks
/etc/defaultrouter <-- have the ip of the gateway, without this, your machine can't talk to outside networks, and you won't be able to ssh in except from the local network
Solaris 10: /etc/inet/ipaddrse1.conf
Solaris 10: /etc/inet/ipnodes --> see http://forum.sun.com/thread.jspa?threadID=18953&messageID=50817
You must add {ipaddress} {hostname} loghost to the end of ipnodes, or dtlogin will act funny, taking a long time to start and other problems.
-or-
Use sys-unconfig before moving to another network
On the next boot, the OS will ask you for the network configuration
The only parts that might be confusing: the default name service is NIS+. You want to use DNS instead.
If it asks what adapter to use, on the SuperSparcs I'm using its either le0 or hme0. le0 is the onboard NIC, hme0 is an sbus card.

Slackware:
/etc/rc.d/rc.inet$INTERFACENUMBERinKERNEL.conf

RedHat:
/etc/sysconfig/network-scripts/ifcfg-$INTERFACENAME

Wednesday, April 06, 2005

Setting up CVS

  • Create a CVS group in /etc/group
  • Set the members
  • Install the CVS package, using rpm, pkgadd, whatever.
  • Create a directory to use as CVSROOT. For example, /usr/cvsroot
  • Add this line to /etc/services
    cvspserver 2401/tcp
  • Add this line to /etc/services
    cvspserver stream tcp nowait root /usr/local/bin/cvs cvs --allow-root=[my repository] pserver
  • Restart inetd
    pkill -HUP inetd
  • Either copy over an old repository to your directory or create a new one.
    cvs -d /my/repository/path init
  • Before you finish, don't forget to set permissions like so:
    chown -R cvs:cvs /my/repository/path

    chmod 775 /my/repository/path
  • Do "cvs -d :pserver:username@accelere02.acceleresystems.com:2401/ login"
  • If you get an error like "cvs login: warning: failed to open /home/piter/.cvspass for reading: No such file or directory", just touch .cvspass
  • There is a limit in inetd to how many arguments can be put on one line. If you need more than a few repositories (each repository needs its own --allow-root) use a shell script.

Friday, April 01, 2005

Creating a New File System on Solaris

Type 'format' at the prompt
$ format
You will see a list of disks, numbered on the left. Enter the disk number, for example 0,1, or 2.

type "partition"
type "print"
This will show you the partition on the physical disk. Note the slice number (partition) you want to create the fs on (slice 0, 1 ,etc).

Now you should know the partition that you want to create a filesystem on, like "c1t1d0s0"

Type "quit" twice.

Use newfs to create a ufs file system.

$ newfs /dev/rdsk/c1t1d0s0

Note:
rdsk is raw access
dsk is block access

Using ufsdump to backup a partition/slice

First,
$ df -k
to find the partition you want to back up

For example:
/dev/dsk/c1t0d0s0

Now simply type something like the following:
$ ufsdump 0f /backup/0_c1t1d0s0 /dev/dsk/c1t1d0s0

0 is the dump level
f means dump to file (default is stdout)
of course the file must not be on the partition you are backing up

Labels

Blog Archive

Contributors