Skip to content

Instantly share code, notes, and snippets.

@suzumura-ss
Last active November 2, 2018 00:54
Show Gist options
  • Save suzumura-ss/1f2f83dc4472b4c3722b to your computer and use it in GitHub Desktop.
Save suzumura-ss/1f2f83dc4472b4c3722b to your computer and use it in GitHub Desktop.
trac with Docker
#!/usr/bin/env python
from optparse import OptionParser
import md5
# build the options
usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option("-u", "--username",action="store", dest="username", type = "string",
help="the username for whom to generate a password")
parser.add_option("-p", "--password",action="store", dest="password", type = "string",
help="the password to use")
(options, args) = parser.parse_args()
# check options
if (options.username is None) or (options.password is None):
parser.error("You must supply both the username and password")
# Generate the string to enter into the htdigest file
realm = 'trac'
kd = lambda x: md5.md5(':'.join(x)).hexdigest()
str = ':'.join((options.username, realm, kd([options.username, realm, options.password])))
f = open("login","w")
f.write(str)
f.close()
FROM ubuntu
WORKDIR /root
ENV TZ=JST-9
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get -y install trac
RUN mkdir ./Main
RUN echo "main\n\n" |trac-admin ./Main initenv
ADD pass.py ./
RUN python ./pass.py -u root -p \!root
CMD ["/bin/bash", "-c", "ip addr; /usr/bin/tracd --port 80 --host 0.0.0.0 --auth=*,login,trac Main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment