# HG changeset patch # User Paul Crowley # Date 1236418776 0 # Node ID 964b04126d014e497da163ebd29dd150551c2a1f # Parent 86ec1268d306b7ac5349ba727763d6edfd57ee95 Force install as root and allow path to change. diff -r 86ec1268d306 -r 964b04126d01 install --- a/install Sat Mar 07 09:31:06 2009 +0000 +++ b/install Sat Mar 07 09:39:36 2009 +0000 @@ -1,17 +1,34 @@ #!/usr/bin/env python +import sys import shutil import os import pwd import subprocess +# This must be run as root, because it must create an hg user. +# Normally the clean thing to do is let it fail with a permission error +# if a non-root user tries to run it, but I don't want anyone thinking +# that they can make it work as non-root by changing install paths. +# Patches welcome for doing this more cleanly of course. + +if os.getgid() != 0: + print >>sys.stderr, "Install must be run as root user" + sys.exit(-1) + +if len(sys.argv) > 2: + print >>sys.stderr, "Usage: install []" + sys.exit(-1) +if len(sys.argv) == 2: + dest = sys.argv[1] + '/lib/mercurial-server' +else: + dest = '/usr/local/lib/mercurial-server' + def installFiles(d, *sources): os.makedirs(d) for f in sources: shutil.copy(f, d) -dest = '/usr/local/lib/mercurial-server' - installFiles(dest, 'src/hg-ssh', 'src/refresh-auth') @@ -47,6 +64,5 @@ subprocess.check_call( "adduser --system --shell /bin/sh --group --disabled-password".split() + ["--gecos", "Mercurial repositories", "hg"]) - subprocess.check_call([dest + '/init/hginit'], preexec_fn = becomeFunc('hg'))