Unix/Ubuntu

Trac 설치하기

ForceCore 2009. 2. 9. 19:42
$ sudo apt-get install trac trac-mercurial
패키지로 가자 -_-;;
그러면 아파치 외 이상한 것들이 많이 설치될 것이다.

아파치로 돌리긴... 싫다. 귀찮다...
아니 아파치로 할... 까?
아니다. 그냥 simplicity를 위해, tracd로 계속 가자.

80번 포트, 9080번 포트에 둘 다 실행하고 싶었다.
/etc/init.d/skel의 것을 복사하여 고쳤다.

후후...

#! /bin/sh
### BEGIN INIT INFO
# Provides:          tracd
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the tracd web server
# Description:       starts tracd using start-stop-daemon
### END INIT INFO

# Do NOT "set -e"

# trac setup
# hostname in FQDN.
HOSTNAME=lab.xxx.ac.kr
PORT=80
TRACDIR=/host/trac
REPOS=$TRACDIR/project

# Generic daemon script stuff
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="tracd on port $PORT"
NAME=tracd$PORT
DAEMON=/usr/bin/tracd
PIDFILE=/var/run/$NAME.pid
DAEMON_ARGS="-d -p $PORT --auth=\"*\",$TRACDIR/passwd,$HOSTNAME $REPOS --pidfile $PIDFILE"
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
    # Return
    #   0 if daemon has been started
    #   1 if daemon was already running
    #   2 if daemon could not be started
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
        || return 1
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
        $DAEMON_ARGS \
        || return 2
    return 0
}

#
# Function that stops the daemon/service
#
do_stop()
{
    # Return
    #   0 if daemon has been stopped
    #   1 if daemon was already stopped
    #   2 if daemon could not be stopped
    #   other if a failure occurred
    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
    #start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
    RETVAL="$?"
    [ "$RETVAL" = 2 ] && return 2
    # Wait for children to finish too if this is a daemon that forks
    # and if the daemon is only ever run from this initscript.
    # If the above conditions are not satisfied then add some other code
    # that waits for the process to drop all resources that could be
    # needed by services started subsequently.  A last resort is to
    # sleep for some time.
    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
    [ "$?" = 2 ] && return 2
    # Many daemons don't delete their pidfiles when they exit.
    # rm -f $PIDFILE
    return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
    #
    # If the daemon can reload its configuration without
    # restarting (for example, when it is sent a SIGHUP),
    # then implement that here.
    #
    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
    return 0
}

case "$1" in
  start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    do_start
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    case "$?" in
        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  restart|force-reload)
    #
    # If the "reload" option is implemented then remove the
    # 'force-reload' alias
    #
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
      0|1)
        do_start
        case "$?" in
            0) log_end_msg 0 ;;
            1) log_end_msg 1 ;; # Old process is still running
            *) log_end_msg 1 ;; # Failed to start
        esac
        ;;
      *)
          # Failed to stop
        log_end_msg 1
        ;;
    esac
    ;;
  *)
    #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
    exit 3
    ;;
esac

:

알겠죠 -_-?!!

9080번 포트에서 실행하는 녀석은 스크립트 이름도 tracd9080이고 PORT variable이 9080이다.
$ sudo chmod +x /etc/init.d/tracd80
$ sudo /usr/sbin/update-rc.d -f tracd80 defaults
이런 명령어도 해야 한다고 한다. 뭐하는거지...a 전자는 실행 가능하게 해주는거고....
후자는 tarcd80을 참조하는 rcX.d소프트링크를 생성해주는 명령어이다. (좋은데?)

실행이 되면 해야 할 일.
$ trac-admin /path/to/repository
이라는 명령어가 있다. htpasswd나 digest같은 것으로 사용자가 존재하도록 했다면.....
Trac [/export/trac/w00t]> permission list

User           Action      
----------------------------
authenticated  TICKET_CREATE
authenticated  TICKET_MODIFY
authenticated  TRAC_ADMIN  
authenticated  WIKI_ADMIN  
authenticated  WIKI_CREATE 
authenticated  WIKI_MODIFY 


Available actions:
 BROWSER_VIEW, CHANGESET_VIEW, CONFIG_VIEW, EMAIL_VIEW, FILE_VIEW,
... 생략 ...
권한 목록을 보자. 익명 유저는 anonymous인데 필자는
> permission remove anonymous *
> permission add authenticated TRAC_ADMIN
> permission add authenticated WIKI_ADMIN
로 익명유저는 아무것도 못 하게 이미 해놓은 상태이다 -ㅠ- authenticated 유저는 평등하게 WIKI_ADMIN, TRAC_ADMIN을 할 수 있게 했다. 특정 유저만 가능케 하려면 유저 id별로 저런 권한을 주면 된다. 어쨌거나 admin권한을 가진 계정을 하나 만들면, trac-admin같은 CLI로 trac설정을 하지 않아도 되어서 좋다. trac페이지에 접속해서 admin기능페이지로 들어가면 그만이니까...