Re: init script

130 views
Skip to first unread message

Clint Adams

unread,
Mar 19, 2013, 11:53:27 AM3/19/13
to gitit-...@googlegroups.com
On Mon, Mar 18, 2013 at 03:30:59PM -0700, georges....@gmail.com wrote:
> I try gitit and really, it's a very good software. But, i try to find some
> information about init script, to use gitit on a permanent tache, and a
> find only an init script used for darcs wiki. Someone can present some init
> script used for a git based gitit for actual debian wheezy? It could be
> very nice to present this kind of information in help pages.
>
> Thank you for your replies.
>
> And again, it's a very good software, very friendly and so... very useful!

Hi Georges,

This is what I do with runit on Debian wheezy:

::::::::::::::
/etc/sv/gitit/log/run
::::::::::::::
#!/bin/sh
set -e

LOG=/var/log/gitit

test -d "$LOG" || mkdir -p -m2750 "$LOG" && chown gitlog:adm "$LOG"
exec chpst -ugitlog svlogd -tt "$LOG"
::::::::::::::
/etc/sv/gitit/run
::::::::::::::
#!/bin/sh
test -x /usr/bin/gitit && exec chpst -u frdm:frdm -U frdm:frdm
/home/frdm/bin/runit-is-a-fuckwit
::::::::::::::
/home/frdm/bin/runit-is-a-fuckwit
::::::::::::::
#!/bin/sh

cd /home/frdm
exec /usr/bin/gitit -f /home/frdm/gitit.conf

georges....@gmail.com

unread,
Mar 19, 2013, 7:43:53 PM3/19/13
to gitit-...@googlegroups.com, cl...@softwarefreedom.org


Thank you for your answer! But now, i need to understand the use of runit!! :-D

jhn...@gmail.com

unread,
Apr 18, 2013, 7:16:26 AM4/18/13
to gitit-...@googlegroups.com, cl...@softwarefreedom.org
Hi Georges,

Here is a more conventional init script that I use on ubuntu to start a set of gitit servers for different wikis that are proxied through Apache. It's a slightly modified version of the script posted in the discussion around issue 55, and assumes the wikis are in /var/wikis.

Hope that helps,
John Noll

/etc/init.d/gitit:
------- cut here ------
#! /bin/sh
#
# If this isn't starting, try removing --background to see gitit's error output.
# Note also that the PATH here includes /usr/local/bin, which you may wish to
# remove.

### BEGIN INIT INFO
# Provides:          gitit
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: VCS-backed wiki engine
# Required-Start:   $local_fs $network $remote_fs
# Required-Stop:     $local_fs $network $remote_fs
# Description:       VCS-backed wiki engine

### END INIT INFO

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC=git\-backed\ wiki\ engine
NAME=gitit
DAEMON=/usr/local/bin/gitit
BASENAME=gitit
DAEMON_ARGS=\-f\
PIDFILE=
SCRIPTNAME=/etc/init.d/$NAME
USER=www-data
WIKI_DIR=/var/wikis

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

# 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()
{
    count=1

    for f in  ${WIKI_DIR}/*/*gitit.config  ; do
    WIKI_WD=`dirname $f`
    WIKI_NAME=`basename ${WIKI_WD}`
    CONFIG=$f
    PIDFILE=/var/run/${NAME}.${WIKI_NAME}.pid
    echo starting ${WIKI_NAME} ${f}
    start-stop-daemon --start --background --oknodo --quiet --make-pidfile --pidfile ${PIDFILE} --exec $DAEMON --user $USER --chuid $USER --chdir ${WIKI_WD} -- \
        $DAEMON_ARGS ${CONFIG} || return 1
    count=$((count+1))
    done
}

#
# Function that stops the daemon/service
#
do_stop()
{
    log_daemon_msg "Stopping Gitit wikis" gitit
    for PIDFILE in `ls /var/run/${NAME}.*.pid` ; do
        start-stop-daemon --stop --oknodo --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $BASENAME --user $USER --chuid $USER
        RETVAL="$?"

        rm -f $PIDFILE
    done
    return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
    for PIDFILE in `ls /var/run/${NAME}.*.pid` ; do
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME --user $USER --chuid $USER
    done
    return 0
}

case "$1" in
  start)
    log_daemon_msg "Starting $DESC" "$NAME"
    do_start
    log_end_msg $?
    ;;
  stop)
    log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    log_end_msg $?
    ;;
  restart|force-reload)
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
      0)
        do_start
        log_end_msg "$?"
        ;;
      *)
          # Failed to stop
        log_end_msg 1
        ;;
    esac
    ;;
  *)
    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
    exit 3
    ;;
esac
-------------

georges....@gmail.com

unread,
Apr 19, 2013, 5:08:01 PM4/19/13
to gitit-...@googlegroups.com
Thank you for your answer!

It's totally what i needed! I run to try it!



Le lundi 18 mars 2013 23:30:59 UTC+1, georges....@gmail.com a écrit :
Hello!
Reply all
Reply to author
Forward
0 new messages