Thursday, December 15, 2011

SCM-Manager

SCM-Manager is a cool Jetty based HTTP-server for managing your source code repositories. Just one single mangement instance for dealing with various SCMs which makes it a lot easier to maintain your projects.

SCM-Manager supports Mercurial, Git, and Subversion. You can manage all your users and their permissions very easily.  Of course SCM-Manager also provides bridges for different kinds of authentication like PAM, LDAP and Active Direcotry.

With a bunch of plugins  and the possibilty to write your own plugins there are basically no limitations with this great software. Highly recommended is the Jenkins plugin which allows to inform your CI whenever there are changes on your repo so there is no need for dump polling.

Installation on Debian / Ubuntu:
  •     download latest release of scm-server
  •     unpack to /opt/scm-server
  •     add the script below to /etc/init.d/scmserver
  •     add a user scmserver
  •     run update-rc.d-insserv scmserver defaults
  •     /etc/init.d/scmserver start

#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          scmserver
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start scmserver at boot time
# Description:       Control Repositories
### END INIT INFO

# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

# Check for and source configuration file otherwise set defaults
RETVAL=0

appname=ScmServerDaemon

# See how we were called.
start() {
    # Call the scm-server script as our user
    /bin/su - scmserver -c "/opt/scm-server/bin/scm-server start >> /opt/scm-home/logs/scm-manager-output.log 2>&1 & "

}

stop() {
    if [ ! status = 0 ]
    then
          SCM_PID=$( ps auxwww | grep  java | grep ${appname} | awk '{print $2 }' )
          kill -9 $SCM_PID
    else
      echo "SCM is not running"
    fi

}

status() {
    ps auxwww | grep  java | grep ${appname} || echo "SCM is not running"

}

restart() {
    stop
    SECONDS=0
    STAT=$( ps auxwww | grep  java | grep ${appname} |  wc -l )
    while [ $STAT -ne 0 ]
    do
      sleep 3
        if [ $SECONDS -gt 300 ]
        then
          SCM_PID=$( ps auxwww | grep  java | grep ${appname} | awk '{ print$2 }' )
          kill -9 $SCM_PID
        fi
      STAT=$( ps auxwww | grep  java | grep ${appname} |  wc -l )
    done
    start

}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        status
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $RETVAL

6 comments:

  1. I can't seem to get the startup script working. I have scm-manager installed at `/opt/scm-manager` and can start it manually running the command `/opt/bin/scm-manager start`. At first I couldn't run it manually because my Java path wasn't set in $PATH but I fixed that by adding the Java path in /etc/profile (for all users). I added the following to the end of /etc/profile:
    export JAVA_HOME=/usr/lib/jvm/default-java
    export PATH=$PATH:$JAVA_HOME/bin

    ReplyDelete
    Replies
    1. I changed permissions on the startup script by running the following command:
      sudo chmod 755 /etc/init.d/scmserver

      I also made the directory for the logs by running the following:
      sudo mkdir /opt/scm-home
      sudo mkdir /opt/scm-home/logs
      sudo chmod 777 /opt/scm-home/logs/

      The startup script still doesn't seem to be working. When I try to run the startup script with the following command:
      sudo ./scm-server start

      I get the following output:
      No directory, logging in with HOME=/

      Delete
    2. I also ran the following commands:
      sudo chmod 777 /opt/scm-server/bin/scm-server
      sudo mkdir /home/scmserver/
      sudo chmod 777 /home/scmserver

      Delete
    3. This comment has been removed by the author.

      Delete
  2. ownload latest release of scm-server
    unpack to /opt/scm-server
    add the script below to /etc/init.d/scmserver
    add a user scmserver
    run update-rc.d-insserv scmserver defaults
    /etc/init.d/scmserver start
    ----------------------------------------------------------------------------------
    useradd -d /data/docs/scm -m -s /sbin/nologin scmserver
    cd /opt
    chown scmserver.scmserver scm-server
    vi bin/scm-server
    ---------------------------------------------
    USER="scmserver"
    JAVA_HOME=/usr/lib/jre-1.7.0
    --------------------------------------
    bin/scm-server start
    bin/scm-server stop



    you shell script modify
    # See how we were called.
    start() {
    # Call the scm-server script as our user
    /otp/scm-server/bin/scm-server start

    }

    stop() {
    if [ ! status = 0 ]
    then
    #SCM_PID=$( ps auxwww | grep java | grep ${appname} | awk '{print $2 }' )
    #kill -9 $SCM_PID
    /otp/scm-server/bin/scm-server stop
    else
    echo "SCM is not running"
    fi

    }

    saved

    chmod 755 scm-server
    chkconfig -level 345 scm-server

    ReplyDelete
    Replies
    1. #!/bin/sh
      2#
      3#
      4# /etc/rc.d/init.d/scm-server
      5#
      6# Starts the SCM-ManagerDaemon
      7#
      8# chkconfig: 2345 90 10
      9# description: SCM-Manager Daemon
      10# processname: jsvc.exec -cp scm-server

      Delete