/[gentoo-x86]/dev-vcs/monotone/files/monotone-0.36.initd
Gentoo

Contents of /dev-vcs/monotone/files/monotone-0.36.initd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri Mar 5 16:49:36 2010 UTC (10 years, 6 months ago) by sping
Branch: MAIN
dev-vcs/monotone: Copy from dev-util/monotone
(Portage version: 2.2_rc64/cvs/Linux i686, RepoMan options: --force)

1 #!/sbin/runscript
2 # Copyright 2006 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License, v2 or later
4 # $Header: /var/cvsroot/gentoo-x86/dev-util/monotone/files/monotone-0.36.initd,v 1.2 2008/08/30 01:23:31 dragonheart Exp $
5
6 opts="import"
7
8 depend() {
9 need net
10 }
11
12 # Substitute common default values
13 MTN_USER=${MTN_USER:-monotone}
14 MTN_GROUP=${MTN_GROUP:-monotone}
15 MTN_KEY=${MTN_KEY:-monotone@`hostname --fqdn`}
16 MTN_CONFDIR=${MTN_CONFDIR:-/etc/monotone}
17 MTN_COMMON="--norc --confdir=${MTN_CONFDIR} \
18 --keydir=${MTN_KEYDIR:-/var/lib/monotone/keys} \
19 --db=${MTN_DB:-/var/lib/monotone/default.mtn} \
20 --rcfile=${MTN_CONFDIR}/hooks.lua --log=/var/log/monotone/monotone.log"
21 #--dump=$ERRORLOG
22 MTN_PIDFILE="/var/run/monotone/monotone.pid"
23 MTN_HOME=$(awk -F: -vuid=$MTN_USER -vuser=$MTN_USER '$3 == uid || $1 == user { print $6 }' < /etc/passwd)
24
25 dbexists() {
26 # Create the database if it doesn't exist
27 if [ ! -e ${MTN_DB:-/var/lib/monotone/default.mtn} ]; then
28 ebegin "Creating monotone database"
29 start-stop-daemon --start \
30 --chuid ${MTN_USER}:${MTN_GROUP} \
31 --exec /usr/bin/mtn -- ${MTN_COMMON} db init
32 eend $?
33 fi
34 if [ ! -e ${MTN_KEYDIR:-/var/lib/monotone/keys}/${MTN_KEY} ]; then
35 ebegin "Creating monotone server keypair"
36 export MTN_PWD=${RANDOM}
37 yes "${MTN_PWD}" | \
38 start-stop-daemon --start \
39 --chuid ${MTN_USER}:${MTN_GROUP} \
40 --exec /usr/bin/mtn -- ${MTN_COMMON} genkey ${MTN_KEY}
41
42 eend $?
43 # Update the password lua hook
44 cat > ${MTN_CONFDIR}/passphrase.lua <<EOF
45 -- This file is automaticaly generated by the init scripts.
46 -- If you want to add custom hooks, edit ${MTN_CONFDIR}/hooks.lua
47 -- If you want to change the settings, please edit /etc/conf.d/monotone
48
49 function get_passphrase(identity)
50 if (identity == "${MTN_KEY}") then
51 return "${MTN_PWD}"
52 end
53 return false
54 end
55 EOF
56 fi
57 }
58
59 start() {
60 cd ${MTN_HOME}
61 dbexists
62
63 ebegin "Starting monotone server"
64 start-stop-daemon --start --background \
65 --chuid ${MTN_USER}:${MTN_GROUP} \
66 --exec /usr/bin/mtn -- ${MTN_COMMON} --pid-file=${MTN_PIDFILE} \
67 --key=${MTN_KEY} --bind=${MTN_ADDRESS:-0.0.0.0} serve
68 eend $?
69 }
70
71 stop() {
72 ebegin "Stopping monotone server"
73 start-stop-daemon --stop --quiet --pidfile ${MTN_PIDFILE}
74 eend $?
75 }
76
77 import() {
78 cd ${MTN_HOME}
79 dbexists
80
81 # Read packets into the database
82 einfo "Importing packets to monotone database"
83 cat | /usr/bin/mtn ${MTN_COMMON} read
84 eend $?
85 }

  ViewVC Help
Powered by ViewVC 1.1.20