<commit_before>
import os
from contextlib import closing
from kokki import *

apt_list_path = '/etc/apt/sources.list.d/mongodb.list'

if not os.path.exists(apt_list_path):
    apt = None
    if env.system.platform == "ubuntu":
        ver = env.system.lsb['release']
        if ver == '10.04':
            apt = 'deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen'
        elif ver == '9.10':
            apt = 'deb http://downloads.mongodb.org/distros/ubuntu 9.10 10gen'
        elif ver == '9.04':
            apt = 'deb http://downloads.mongodb.org/distros/ubuntu 9.4 10gen'
    elif env.system.platform == "debian":
        ver = env.system.lsb['release']
        if ver == '5.0':
            apt = 'deb http://downloads.mongodb.org/distros/debian 5.0 10gen'

    if not apt:
        raise Fail("Can't find a mongodb package for your platform/version")

    with closing(open(apt_list_path, 'w')) as fp:
        fp.write(apt + "\n")

    import subprocess
    subprocess.call("apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10", shell=True)
    subprocess.call("apt-get update", shell=True)

Package("mongodb-stable")

Directory(env.config.mongodb.dbpath,
    owner = "mongodb",
    group = "mongodb",
    mode = 0755,
    recursive = True)

Execute("initctl reload mongodb",
    action = "nothing")

Service("mongodb")

File("/etc/init/mongodb.conf",
    owner = "root",
    group = "root",
    mode = 0644,
    content = Template("mongodb/upstart.conf.j2", variables=dict(mongodb=env.config.mongodb)),
    notifies = [
        ("run", env.resources["Execute"]["initctl reload mongodb"], True),
        ("start", env.resources["Service"]["mongodb"]),
    ])

File(env.config.mongodb.configpath,
    owner = "root",
    group = "root",
    mode = 0644,
    content = Template("mongodb/mongodb.conf.j2", variables=dict(mongodb=env.config.mongodb)),
    notifies = [("restart", env.resources["Service"]["mongodb"])])<commit_msg>Maybe just stop and start it<commit_after>
import os
from contextlib import closing
from kokki import *

apt_list_path = '/etc/apt/sources.list.d/mongodb.list'

if not os.path.exists(apt_list_path):
    apt = None
    if env.system.platform == "ubuntu":
        ver = env.system.lsb['release']
        if ver == '10.04':
            apt = 'deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen'
        elif ver == '9.10':
            apt = 'deb http://downloads.mongodb.org/distros/ubuntu 9.10 10gen'
        elif ver == '9.04':
            apt = 'deb http://downloads.mongodb.org/distros/ubuntu 9.4 10gen'
    elif env.system.platform == "debian":
        ver = env.system.lsb['release']
        if ver == '5.0':
            apt = 'deb http://downloads.mongodb.org/distros/debian 5.0 10gen'

    if not apt:
        raise Fail("Can't find a mongodb package for your platform/version")

    with closing(open(apt_list_path, 'w')) as fp:
        fp.write(apt + "\n")

    import subprocess
    subprocess.call("apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10", shell=True)
    subprocess.call("apt-get update", shell=True)

Package("mongodb-stable")

Directory(env.config.mongodb.dbpath,
    owner = "mongodb",
    group = "mongodb",
    mode = 0755,
    recursive = True)

# Execute("initctl reload mongodb",
#     action = "nothing")

Service("mongodb")

File("/etc/init/mongodb.conf",
    owner = "root",
    group = "root",
    mode = 0644,
    content = Template("mongodb/upstart.conf.j2", variables=dict(mongodb=env.config.mongodb)),
    notifies = [
        ("stop", env.resources["Service"]["mongodb"]),
        ("start", env.resources["Service"]["mongodb"]),
    ])

File(env.config.mongodb.configpath,
    owner = "root",
    group = "root",
    mode = 0644,
    content = Template("mongodb/mongodb.conf.j2", variables=dict(mongodb=env.config.mongodb)),
    notifies = [("restart", env.resources["Service"]["mongodb"])])
{'fraction_non_alphanumeric': 0.16037977931742367, 'fraction_numerical': 0.024634334103156273, 'mean_word_length': 2.9573604060913707, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5205487', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1302, 'n_words': 275}