zhao-sun.com

April 9, 2004

Setup cvs server

Filed under: Computer — blogadmin @ 10:59 pm


  • as root, create the source direcory, and run “cvs init”. This will create CVSROOT directory.

  • set the correct value to CVSROOT inside your login batch
    file, such as in my .cshrc, I say “setenv CVSROOT /src/master”.

  • for importing into the source repository, first go the directory with the sources, and run “cvs import test yoyo start”.

  • for checking out, after set correct CVSROOT, do “cvs update -d” or “cvs co [source module name]”.

  • for create a personal branch, do “cvs rtag -b [branch name] [souecr module name]”, and then run “cvs update -r [branch name]”.

    Or you can go to cvs document page to take a look.

Tag and Create a new branch


    When your mainline is ready to ship, tag it. You have to do this anyway to remember what you shipped.

  • cd an_up_to_date_working_copy
  • cvs tag main_1_0

    Create a branch and put the working copy on it.

  • cvs tag -r main_1_0 -b B_1_0_branch
  • cvs update -r B_1_0_branch

    Make the changes for customer B, and commit them as you go. Because your working copy has a sticky tag from the “update -r B_1_0_branch”, your commits go to that branch instead of the trunk.

    When your branch is good, tag it too.

  • cvs tag B_1_0

    You can now go to a clean directory and export revisions main_1_0 and B_1_0 for shipping.

    Return to your working copy and put it back on the trunk.

  • cvs update -A

    All your “B” changes are gone, you are back to the mainline. Proceed with normal development. When your mainline is ready to ship again, tag it.

  • cvs tag main_1_1

    Now the fun part: you create a new branch for customer B and recreate all the changes you made the first time.

  • cvs tag -r main_1_1 -b B_1_1_branch
  • cvs update -r B_1_1_branch
  • cvs update -j main_1_0 -j B_1_0
  • # fix conflicts
  • cvs commit

    The “update -j -j” does most of the work for you, but it’s not foolproof so you have to manually inspect and test your sources. You’ll be surprised how little damage you have to fix. When you’re happy, tag the tip of your new B branch.

  • cvs tag B_1_1
  • cvs update -A

    The process repeats after the second release. Tag, create new branch, merge the previous branch to it. You have to be very clear about the use of those branches: all development happens on the trunk, the “B” branches are *only* for customer-specific variants. You never merge these branches back to the trunk.

    (In truth, you should also have bugfix branches for the normal code you ship, but that’s an easier pattern to master than the stepladder of branches I just described. Stick to the hard stuff for now… 🙂

Setup DHCP server

Filed under: Computer — blogadmin @ 10:58 pm


  • on Linux DHCP client machine, run “dhcpcd -k” to send DHCP_RELEASE signal. run “dhcpcd” or “dhcpcd -h hostname” to get an ip from DHCP server

  • on Linux DHCP server machine, run “cp /usr/share/doc/dhcp-/dhcpd.conf.sample /etc/dhcpd.conf”

  • “edit /etc/dhcpd.conf”

  • “touch /var/lib/dhcp/dhcpd.leases”

  • “/usr/sbin/dhcpd eth1”

  • for more detailed information, try DHCP Server Help

Setup NFS

Filed under: Computer — blogadmin @ 10:58 pm


  • on the Linux server machine, edit /etc/exports, adding a line “/vol shanghai(rw) chuangchun(rw)” at the end; and run “/etc/init.d/nfs restart”

  • or on the Linux server machine, following the steps as stated here – NFS Howto

  • on the client machine, (can be a Unix or a Linux system), run “mount (SERVER_IP_ADDRESS):(SHARE_DIRECTORY) (LOCAL_SHARE_DIRECTORY)”; or on the Linux client machine, to mount file systems at boot time, edit /etc/fstab, adding a line “wenji:/opt
    /mnt/shared/opt nfs rw 0 0” at
    the end.

Setup Samba

Filed under: Computer — blogadmin @ 10:56 pm


    I am running samba on redhat linux 6.0. Then I tried to use samba to talk to another computer running both Windows 2000 and Windows 98.
  • go http://www.samba.org,
    and download the most updated stable version of samba for my redhat linux 6.0 system

  • untar the download file. If it is in rpm format, use “rpm –install” or “rpm –upgrade” to install the samba package.

  • create a file, called /sbin/startsmb, and make it executable

    #!/bin/sh

    /usr/sbin/smbd -D

    /usr/sbin/nmbd -D -G SIEGE

    (the last word “SIEGE” is your Workgroup name. and if you want to start samba automatically at boot time, create two soft links under /etc/rc.d/init.d and under /etc/rc.d/rc5.d)

  • configure the /etc/smb.conf file.

  • run /sbin/startsmb, that’s almost it on linux side

  • On Both Windows 2000 and Windows 98 systems, set the computer name and workgroup name.

  • I also installed NetBEUI Protocol on the network card talking to my linux box. I know that’s a must for Windows 98, but not sure for Windows 2000

  • On Windows 2000, go Control Panel –> Users and Passwords –> Advanced –> Advanced –> Users –> Guest –> Properties –> unset “Account is disabled”, which make guest accout enabled

  • on Windows 2000, I have also added a Windows component, Internet Information Services (IIS). Again, I don’t know whether this is a must or not. However, after installing IIS, I can ftp to my Windows 2000 now.

  • So, that’s it. Now, from my linux box, I can see all the shared files and use shared printer on my Windows system. From my Windows system, I can see all the shared files defined in /etc/smb.conf. I can just click the files and edit them or winzip them directly on Windows. People won’t notice the files are on another computer. Is that beauty? ENJOY!

Setup display remotely on X server

Filed under: Computer — blogadmin @ 10:51 pm


  • on the server machine, run “xhost +(CLIENT_IP_ADDRESS)”.

  • on the client machine, run “setenv DISPLAY (SERVER_IP_ADDRESS):0”.

  • on the client machine, run the program.

Some useful commands

Filed under: Computer — blogadmin @ 10:51 pm


    Setup port forward
  • ssh -v -g -l user_name -L local_port:remote_ip:remote_port remote_ip

    Check for disk space

  • df -kl

  • du -sk *
  • translating a Java source file into a native executable using the GNU GCJ compiler

  • gcj –classpath . -g0 –main=HelloWorld -o HelloWorld.exe HelloWorld.java
  • DNS lookup utility

  • dig -mx yahoo.com
  • Network exploration tool and security scanner

  • nmap -sT 127.0.0.1
  • UNIX system error.h

  • /usr/include/sys/errno.h
  • returns the HTTP response headers from the named site

  • HEAD http://yad2yad.huji.ac.il/

  • Result:
    200 OK
    Cache-Control: max-age=0
    Connection: close
    Date: Tue, 10 Dec 2002 08:38:37 GMT
    Server: AOLserver/3.3.1+ad13
    Content-Type: text/html; charset=utf-8

Setup xemacs

Filed under: Computer — blogadmin @ 10:50 pm


  • Go to download 3 xemacs packages:  “xemacs-21.1.9.tar.gz”, “xemacs-21.1.9-elc.tar.gz”, and “xemacs-21.1.9-info.tar.gz”.

  • Expand the above files into the directory used for compiling, e.g. gzip -dc xemacs-21.1.*.tar.gz | tar xf -.

  • Change to the directory where you expanded the files, e.g. cd /usr/src/xemacs-21.1.9.

  • Type ./configure ; make.

  • After the compile finishes, switch to the root account and type make install.

  • Go to download another xemacs packages:  “xemacs-sumo.tar.gz”.

  • Expand the above files into /usr/local/lib/xemacs/xemacs-packages/. If you would prefer to install these in a different location, set the EMACSPACKAGEPATH environment variable to your preferred location, and then expand the files in the directory in the variable. Don’t forget to export the variable, and to add it to the appropriate startup script!

  • Start XEmacs by typing xemacs.

    Or you can go to this official insallation help page  . There is
    a little bit difference from what I said above. Combining them together probably is the best choice.

    GOOD LUCK!

Change Prompt in bash or tcsh

Filed under: Computer — blogadmin @ 10:49 pm


  • for bashrc

    # .bashrc

    # very basic

    #export PS1=”\w: ”



    # basic with time

    export PS1=”[\@ \u] \w: ”



    # blue background

    #export PS1=”\[33[44m\](\@) \w: \[33[44m\]”



    # basic yellow

    #export PS1=’\[33[0;33m\](\n\@) \w :33[0m\]’



    # yellow

    #export PS1=”[33[0;33m\]\u@\h \w]\\$ ”



    # WHITE=”\[33[1;37m\]”

    #export PS1=”[33[1;37m\]\u@\h \w]\\$ ”



    #Black=

    #export PS1=”[33[0;30m\]\u@\h \w]\\$ ”



    #Blue

    #export PS1=”[33[0;34m\]\u@\h \w]\\$ ”



    #Green

    #export PS1=”[33[0;32m\]\u@\h \w]\\$ ”



    #Cyan

    #export PS1=”[33[0;36m\]\u@\h \w]\\$ ”



    #Red

    #export PS1=”[33[0;31m\]\u@\h \w]\\$ ”



    #Purple

    #export PS1=”[33[0;35m\]\u@\h \w]\\$ ”



    #Brown

    #export PS1=”[33[0;33m\]\u@\h \w]\\$ ”




    #Gray

    #export PS1=”[33[0;37m\]\u@\h \w]\\$ ”



    #DarkGray

    #export PS1=”[33[1;30m\]\u@\h \w]\\$ ”



    #LightBlue

    #export PS1=”[33[1;34m\]\u@\h \w]\\$ ”



    #LightGreen

    #export PS1=”[33[1;32m\]\u@\h \w]\\$ ”



    #LightCyan

    #export PS1=”[33[1;36m\]\u@\h \w]\\$ ”



    #LightRed

    #export PS1=”[33[1;31m\]\u@\h \w]\\$ ”



    #Yellow

    #export PS1=”[33[0;33m\]\u@\h \w]\\$ ”



    #White

    #export PS1=”[33[1;37m\]\u@\h \w]\\$ ”

  • For cshrc on unix, using

    set prompt=\[`/usr/xpg4/bin/id -nu`@`hostname`’ %~’\]\$’ ‘

Setup Mail Server

Filed under: Computer — blogadmin @ 10:47 pm

  • on the mail host server machine, edit the file /etc/hosts. Add a CNAME record to your DNS that contains the name of your sendmail server. One example is “172.16.0.1 www.sunny-solutions.com sunny-solutions”.

  • modify /etc/sysconfig/network, edit your HOSTNAME. One example is “HOSTNAME=www.sunny-solutions.com”.

  • if you have aliases for your mail server name, modify /etc/mail/local-host-names. One eample is “www.sunny-solutions.com”. Make sure that “yourdomain.com” is there otherwise you will get an error as “553 5.3.5 65.49.122.83. config error: mail loops back to me (MX problem?)
    554 5.3.5 Local configuration error”

  • run “echo ‘$=w’ | sendmail -bt -d0.4”, make sure that there is no error messages.

  • in the /etc/sysconfig/ipchains file, make sure that smtp
    port 25 is open.

  • in /etc/mail/sendmail.mc file, change default line, “DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)” to “DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA’)”. (Or change origal line to “dn1 DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)”.

  • run “m4 /etc/mail/sendmail.mc > /etc/sendmail.cf”. /etc/sendmail.cf is the mail config file. After running this command,
    the change in sendmail.mc will be updated in sendmail.cf as well.

  • restart sendmail daemon by “/etc/rc.d/init.d/sendmail restart”. After running this command, not only localhost(127.0.0.1), but also all the other allow hosts can telnet to port 25 of the host where mail server is running. In other words, it will allow sendmail to accept network connections from any host other than the local computer.

  • adding a line “sendmail:ALL” in /etc/hosts.allow to allow that all the mail client can telnet to mail host port 25.

  • Mail server should run fine now.

  • To allow relay messages for all machines inside your host, follow these steps.

  • edit /etc/mail/access file,
    172.16. RELAY
    # North Korea
    co.kr REJECT ” co.kr domains disallowed ”
    # Russia
    mail.ru REJECT ” mail.ru disallowed ”
    # Taiwan
    com.tw REJECT ” com.tw domains disallowed ”
    net.tw REJECT ” net.tw domains disallowed ”
    ….

  • in the directory “/etc/mail”, run “makemap hash /etc/mail/access.db
  • restart the xinetd daemon by “/etc/init.d/xinetd restart”

  • to test whether the smtp port 25 is configured correctly, run “netstat -nl” command. It will show that tcp port 25 is listening. And run “lsof -i” command checking whether sendmail is doing the smtp listen.

  • to check for mail log file, go to /etc/syslog.conf file.
    It should have a line like “mail.* /var/log/maillog”.

  • run “nslookup $domain” or “dig $domain” to check for mail mx setup.

  • run “telnet relay-test.mail-abuse.org” to check for the site is open relay site or not

  • PS: http://groups.google.com/groups?q=/etc/hosts.allow+smtp&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3E526023.1020406%40mis.com&rnum=6 is a very nice message to describe almost the same steps here.

  • PS: To authroize other machines to send mail through this sendmail server, need to modify /etc/mail/access first by adding the the authorized users. Then “cd /etc/mail”, and run “makemap hash access.db

    Setup IMAP and POP3 servers


    • By default, Fedora core 3 comes with Cyrus IMAP. The difference between Cyrus IMAP vs. Washington IMAP is: “Cyrus has its own mailbox database which is standalone and increases performance, whereas Washington uses the stanard UNIX mailbox format, which was designed for a smaller set of users. Washington is portable to more UNIX and non-UNIX systems than Cyrus. The main difference is that with Cyrus, you don’t have to add new users to your linux box (i.e. in /etc/passwd) to add new mail users, and with Washington, you do.”
    • URL to Cyrus IMAP HOWTO
    • On Fedora disk 3, run rpm -Uvh cyrus-imapd-2.2.6-2.FC3.6.i386.rpm, cyrus-sasl-devel-2.1.19-3.i386.rpm, and cyrus-imapd-utils-2.2.6-2.FC3.6.i386.rpm. After installation, by default, “sasl_pwcheck_method: saslauthd” in /etc/imapd.conf.
    • Create a default user cyrus. As root, run “/etc/rc.d/init.d/cyrus-imapd start” and “/etc/rc.d/init.d/saslauthd start”. As cyrus, run “/usr/lib/cyrus-imapd/cyradm localhost” to create user and set quota …
    • For my case, I need to use the stanard UNIX mailbox format. Go to UW IMAP Information Center to download imap.tar.Z. After unzip the tar file, go under the directory imap-2004a and run “make lrh SSLTYPE=unix”. With SSLTYPE=unix, it will build with SSL but allow plaintext passwords in insecure sessions. Without SSLTYPE=unix, by default, plaintext passwords is not allowed and you will get LOGINDISABLED error.
    • After build finishes successfully, copy imapd/imapd, ipopd/ipop3d and ipopd/ipop2d to /usr/sbin.
    • Under /etc/xinetd.d, create imap, ipop3, and ipop2. One example of imap file is:
      # default: off
      # description: The IMAP service allows remote users to access their mail using \
      # an IMAP client such as Mutt, Pine, fetchmail, or Netscape \
      # Communicator.
      service imap
      {
      socket_type = stream
      wait = no
      user = root
      server = /usr/sbin/imapd
      log_on_success += HOST DURATION
      log_on_failure += HOST
      disable = no
      }
    • Run “/etc/rc.d/init.d/xinetd restart” to start imap and pop3 server
    • Test imapd process by telnet
      >telnet yyyy 143
      a0001 login
      a0002 select inbox
      a0003 fetch 1 full
      a0004 logout

JNI Example

Filed under: Computer — blogadmin @ 10:45 pm


  • Write the Java Code

    The following Javacode segment defines a class named HelloWorld. This class declares one native method, implements a main method, and has a static code segment.


    class HelloWorld {

    public native void displayHelloWorld();

    static {

    System.loadLibrary(“hello”);

    }

    public static void main(String[] args) {

    new HelloWorld().displayHelloWorld();

    }

    }

  • Compile the Java Code

    Use the Java compiler to compile the class that you created
    in the previous step. Here’s the command to use:

        javac HelloWorld.java

  • Create the .h File

    Running javah :

    UNIX & LINUX

    % javah -jni HelloWorld


    DOS shell (Windows 95/NT)

    C:\> javah -jni HelloWorld


    MacOS

    Drag the HelloWorld.class file onto the JavaH icon. This creates a file called HelloWorld.h in the same folder as JavaH. Move the file into your working folder.

  • Write the Native Method Implementation

    This implementation is in the file named HelloWorldImp.c.

    #include

    #include “HelloWorld.h”

    #include



    JNIEXPORT void JNICALL

    Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)

    {

    printf(“Hello world!\n”);

    return;

    }

  • Create a Shared Library

    UNIX

    cc -G -I/usr/local/java/include -I/usr/local/java/include/solaris HelloWorldImp.c -o libhello.so


    LINUX

    cc -shared -I/usr/local/java/include -I/usr/local/java/include/solaris HelloWorldImp.c -o libhello.so


    DOS shell (Windows 95/NT)

    cl -Ic:\java\include -Ic:\java\include\win32 -LD HelloWorldImp.c -Fehello.dll

    Of course, you need to specify the include path that corresponds to the setup on your own machine.

  • Run the Program

    Now run the Java application (the HelloWorld class) with the Java interpreter, as follows:

    java HelloWorld


    You should see the following output:

    Hello World!

  • PS: Set Your Library Path

    UNIX

    % setenv LD_LIBRARY_PATH mylibrarypath


    where mylibrarypath is the name of the directory that contains libhello.so.

    DOS shell (Windows 95/NT)

    On Windows 95/NT, the loadLibrary()
    method searches for DLLs in the same manner as other language environments do.

    In c:\autoexec.bat file:

    SET INCLUDE=path to find .h files


    SET LIB=path to find .lib files


    MacOS

    The Java runtime searches the JavaSoft Folder in the Extensions folder in the System Folder for shared libraries. Create an alias to your shared library in the JavaSoft Folder.

« Newer PostsOlder Posts »

Powered by WordPress