This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit ea4e8af3064f7d31abd0ab3e7e71fbd12f142d87 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Jun 25 19:02:06 2015 +0200 added argument for log level + added postinst file + updated debian files --- app/mum.py | 4 +++- debian/postinst | 37 +++++++++++++++++++++++++++++++++++++ debian/rules | 20 +++++++++++--------- mum-daemon.sh | 2 +- mum.conf | 3 ++- mum.sh | 5 ++++- views/hostpage.html | 1 + 7 files changed, 59 insertions(+), 13 deletions(-) diff --git a/app/mum.py b/app/mum.py index 91a9f06..a44a48c 100755 --- a/app/mum.py +++ b/app/mum.py @@ -98,7 +98,8 @@ def do_upload(): def create_logger(dict_conf): logger = logging.getLogger("mum_log") - logger.setLevel(logging.DEBUG) + level = getattr(logging, dict_conf["log_level"]) + logger.setLevel(level) formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s') file_handler = RotatingFileHandler(dict_conf['log_location'], 'a', 1000000, 1) file_handler.setLevel(logging.DEBUG) @@ -130,6 +131,7 @@ if __name__ == '__main__': parser.add_argument("--smtp_server", help="name of the SMTP server to send e-mail notifications") parser.add_argument("--smtp_port", help="port number of the SMTP server") parser.add_argument("--smtp_address", help="e-mail address of the sender for e-mail notifications") + parser.add_argument("--log_level", help="set the log level : DEBUG, INFO, WARNING, ERROR") args = parser.parse_args() # creating the default conf structure from the configuration file diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..6e2020f --- /dev/null +++ b/debian/postinst @@ -0,0 +1,37 @@ +#!/bin/bash + +cd /usr/lib/mum + +venv/bin/python --version >/dev/null 2>&1 || virtualenv venv +./in-venv.sh pip install -r requirements.txt + +# changing bottle templates in order to make it compatible with angularJS +sed -i 's/{{/[[/g' venv/bin/bottle.py +sed -i 's/}}/]]/g' venv/bin/bottle.py +sed -i 's/{{/[[/g' venv/lib/python2.7/site-packages/bottle.py +sed -i 's/}}/]]/g' venv/lib/python2.7/site-packages/bottle.py + +# creating mum user if doesn't exist +NB_MUM_USR=$(grep '^mum:' /etc/passwd | wc -l) +if [ $NB_MUM_USR -eq 0 ]; then + /usr/sbin/adduser mum --system + echo 'mum user created' +fi + +# creating mum group if doesn't exist and adding mum user to it +NB_MUM_GRP=$(grep '^mum:' /etc/group | wc -l) +if [ $NB_MUM_GRP -eq 0 ]; then + /usr/sbin/addgroup mum --system + echo 'mum group created' + /usr/sbin/usermod -a -G mum mum + echo 'mum user added to mum group' +fi + +# adding mum group to sudoers if not registered +NB_MUM_SUDOERS=$(grep '^mum\s' /etc/sudoers | wc -l) +if [ $NB_MUM_SUDOERS -eq 0 ]; then + echo 'mum ALL= /usr/bin/nmap' >> /etc/sudoers + echo "mum added to sudoers" +fi + +exit 0; \ No newline at end of file diff --git a/debian/rules b/debian/rules index 9c91a1b..dedaaeb 100755 --- a/debian/rules +++ b/debian/rules @@ -26,8 +26,9 @@ DEST_APP=$(CURDIR)/debian/mum/usr/lib/mum DEST_CONF=$(CURDIR)/debian/mum/etc/mum DEST_VAR=$(CURDIR)/debian/mum/var/lib/mum DEST_BIN=$(CURDIR)/debian/mum/usr/bin -#DEST_INIT_D=$(CURDIR)/debian/mum/etc/init.d -#DEST_SYSTEMD=$(CURDIR)/debian/mum/etc/systemd/system +DEST_INIT_D=$(CURDIR)/debian/mum/etc/init.d +DEST_SYSTEMD=$(CURDIR)/debian/usr/lib/systemd/system +DEST_DOC=$(CURDIR)/debian/usr/share/doc/mum build : build-stamp @@ -50,7 +51,12 @@ install : build clean $(app) $(bower_components) $(static) $(views) $(install_sc mkdir -p $(DEST_APP) mkdir -p $(DEST_CONF) mkdir -p $(DEST_VAR) + mkdir -p $(DEST_BIN) + mkdir -p $(DEST_SYSTEMD) + mkdir -p $(DEST_DOC) mkdir $(DEST_VAR)/keys + mkdir $(DEST_VAR)/logs + mkdir $(DEST_VAR)/data cp -R $(app) $(DEST_APP) cp -R $(bower_components) $(DEST_APP) @@ -59,16 +65,12 @@ install : build clean $(app) $(bower_components) $(static) $(views) $(install_sc cp $(install_script) $(DEST_APP) cp $(in_venv) $(DEST_APP) cp $(mum_conf) $(DEST_CONF) - #@if test -d $(DEST_INIT_D); then \ - # cp $(mum_daemon) $(DEST_INIT_D) - #else :; fi - #@if test -d $(DEST_SYSTEMD); then \ - # cp $(mum_service) $(DEST_SYSTEMD) - #else :; fi + cp $(mum_service) $(DEST_SYSTEMD) cp $(readme) $(DEST_APP) cp $(requirements) $(DEST_APP) cp $(run) $(DEST_APP) - ln -s $(run) $(DEST_BIN) + cp $(mum_daemon) $(DEST_DOC) + ln -s /usr/lib/mum/mum.sh -t $(DEST_BIN) find $(DEST_APP)/app -type f -iname "*.pyc" -exec rm -f {} \; rm -rf $(DEST_APP)/bower_components/jquery diff --git a/mum-daemon.sh b/mum-daemon.sh index 28290d5..adcb03b 100755 --- a/mum-daemon.sh +++ b/mum-daemon.sh @@ -11,7 +11,7 @@ DESC="Mum service" NAME="mum" -DAEMON=/usr/lib/mum/mum.sh +DAEMON=/bin/mum DAEMON_OPTS=/etc/mum PIDFILE=/var/run/$NAME.pid diff --git a/mum.conf b/mum.conf index cdff5fb..0a12be8 100644 --- a/mum.conf +++ b/mum.conf @@ -4,9 +4,10 @@ db_location=/var/lib/mum/data/mum.db log_location=/var/lib/mum/logs external_modules_location=/etc/mum/modules/ keys_location=/var/lib/mum/keys/ -smtp_server= +smtp_server=localhost smtp_port= smtp_address= +log_level=WARNING #scan=Scan name|Scan description|Priority|Nmap parameter options scan=Complete scan and detection|This scan is the most complete but the longest one. Recommended for commom server monitoring. Time necessary: from a minute to several hours depending of the host.|1|-sU -sS -p U:161,T:1-65535 -A -Pn diff --git a/mum.sh b/mum.sh index 10b3a77..39d4ef3 100755 --- a/mum.sh +++ b/mum.sh @@ -1,8 +1,11 @@ #!/bin/sh +DIR=$(basename /usr/lib/mum) +cd $DIR + if [ ! -d "venv" ]; then echo "Preparing the virtual environment for the first launch (this may take several minutes)" echo "Log files will be saved on /etc/mum" - ./install.sh > /etc/mum/mum.install.log 2> /etc/mum/mum.install.err + ./install.sh > /var/log/mum/mum.install.log 2> /var/log/mum/mum.install.err fi exec ./in-venv.sh python app/mum.py $* diff --git a/views/hostpage.html b/views/hostpage.html index 8cd95ff..8a34387 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -477,6 +477,7 @@ <button ng-click="item.upload(item, '\keys')">upload</button> </li> </ul>--> + <div class="row" ng-show="show_form('private_key')"> <div class="col-xs-3"> <label for="private_key">Select a private key</label> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.