Setup Mercurial server with multiple repositories on OpenSUSE
Posted by: senex 12 years, 10 months ago
(Comments)
This tutorial is to configure a Mercurial/hg server for multiple repositories on OpenSUSE. Be sure to follow these steps on the server you want to host the repositories on.
First make sure Mercurial is installed
zypper install hg
Now create a location for the repositories
mkdir -p /var/hg/repos
Create some project as an example
cd /var/hg/repos
hg init super_proj
Create a config file for hg to know to what to serve (details here). In /var/hg/hg_repos.conf insert the following
[paths]
/ = /var/hg/repos/*
[web]
push_ssl = false
allow_push = *
Now for a startup script (based on this). In /etc/init.d/hg_serve put the following
#! /bin/sh
#
# Startup script for mercurial server.
#
### BEGIN INIT INFO
# Provides: hg server
# Required-Start: $local_fs $remote_fs $syslog $network
# Required-Stop: $local_fs $remote_fs $syslog $network
# Should-Start: $time sendmail httpd2 xntpd $named cron ndo2db
# Should-Stop: sendmail ndo2db
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: hg server
# Description: hg server
### END INIT INFO
# Change following ines
APP_BIN=/usr/bin/hg
SRC=/var/hg/repos
# Path to PID file of running mercurial process.
PID_FILE=/var/hg/hg.pid
CONFIG_FILE=/var/hg/hg_repos.conf
state=$1
case "$state" in
'start')
echo "Mecurial Server service starting."
${APP_BIN} serve --webdir-conf=$CONFIG_FILE -d -p 8001 --pid-file ${PID_FILE}
;;
'stop')
if [ -f "${PID_FILE}" ]; then
PID=`cat "${PID_FILE}"`
if [ "${PID}" -gt 1 ]; then
kill -TERM ${PID}
echo "Stopping the Mercurial service PID=${PID}."
else
echo Bad PID for Mercurial -- \"${PID}\"
fi
else
echo No PID file recorded for mercurial
fi
;;
'restart')
$0 stop
$0 start
;;
*)
echo "$0 {start|stop|restart}"
exit 1
;;
esac
Now to finalize things
chmod +x /etc/init.d/hg_serve
chkconfig --add hg_serve
service hg_serve start
(If you are using Debian/Ubuntu, to activate the script run "update-rc.d hg_serve defaults")
Now you should be able to access the server via the web. Just point your web browser to http://<your server ip>:8001
Keep in mind, this setup is for internal servers. Refer to other resources for securing your data!
More information on Mercurial can be found at http://mercurial.selenic.com/guide/
Recent Posts
- Podcast feed for Connected Life Christian Church
- PulseAudio Sound Sink
- CppHeaderParser 2.4.3 Released
- CppHeaderParser 2.4.2 Released
- CppHeaderParser 2.4.1 Released
Archive
2016
- November (1)
2014
2013
- August (1)
2012
2011
2006
- June (2)
Categories
- Comic (1)
- CppHeaderParser (8)
- HOWTO (3)
- Project (2)
Authors
- senex (23)
Comments