-
Notifications
You must be signed in to change notification settings - Fork 3
Simulator Django
Get system-wide dependencies: (McStas/McXtrace is unlisted here, it needs to be installed using the normal guidelines from mcstas.org. MPI is also a requirement, for example openmpi.)
$ sudo apt-get install git
$ sudo apt-get install libopenmpi-dev openmpi-bin
$ sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
$ sudo apt-get install python-virtualenv
$ sudo apt-get install makepasswd
$ sudo apt-get install nginx
If your system already includes a webserver like apache2, you may need to run the two following commands for a successful installation / configuration of nginx:
$ sudo update-rc.d apache2 remove
$ sudo service apache2 stop
Set up the virtual environment "mcvenv" and pip dependencies into it:
$ cd /srv
$ sudo mkdir mcweb
$ sudo chown www-data:www-data mcweb
$ sudo -u www-data -s (and perform the rest as www-data..)
$ cd mcweb
$ virtualenv mcvenv
$ source mcvenv/bin/activate
$ pip install -I Django==1.8.2
$ pip install simplejson django_auth_ldap uwsgi python-ldap
NOTE: You may have to sudo to build uwsgi, in which case you must use the absolute pip path (e.g. /srv/mcweb/mcvenv/bin/pip).
Download and install mcsimulator.
$ git clone https://github.com/McStasMcXtrace/McWeb
$ cd McWeb/mcsimrunner/
$ python manage.py migrate
$ python manage.py collect_instr
(Check that all user rights are set to www-data - if not, please:
$ sudo chown -R www-data:www-data mcvenv McWeb
$ sudo chmod -R g+w mcvenv McWeb
)
In McWeb/uwsgi_mcweb.ini, change the paths in the to correspond to your setup (must be absolute).
Appropriately change the VIRTUALENV and DIR variable values in the file McWeb/scripts/uwsgi_mcweb. Create a symlink of this in /etc/init.d/, e.g.:
$ ln -s /srv/mcweb/McWeb/scripts/uwsgi_mcweb /etc/init.d/uwsgi_mcweb
Check that it works by running
$ sudo /etc/init.d/uwsgi_mcweb start
To ensure that the script always starts at machine bootup, use
$ sudo update-rc.d uwsgi_mcweb defaults
Install open ldap "slapd" and ldap-utils:
$ apt-get install slapd ldap-utils
When prompted for the ldap admin password, keep in mind that this is required to set up LDAP access. If you happen to lose the password, or if want to reset it, simply use:
$ dpkg-reconfigure slapd
The ldap database has to be set up and this is done by a Python script inlcuded with the mcstas simulator app. Go to the directory .../McWeb/ldifs/ and run:
$ python ldap_initdb.py <pw>
where pw is the ldap admin password.
Use the following to get mcsimulator online:
$ sudo /etc/init.d/uwsgi_mcweb start/stop/status
$ sudo service nginx start/stop/status
NOTE: You must stop and start the webserver for changes to static content to take effect. (You must also stop apache2, if it is running on your system (sudo service apache2 stop).) Finally, please note that the entire path of folders containing the web app, all the way to "/", must have rx rights on them for www-data.
-
In the file .../McWeb/mcwww/settings.py, change the value of
MCWEB_LDAP_DNto conform to your ldap dn (the one you identified above). -
Notice the variable
AUTHENTICATION_BACKENDSin the same file (settings.py). This contains two lines, one of which is out-commented. This should be the django model backend, and not the ldap backend. Please make sure the django model backend is disabled. Otherwise, LDAP auth will effectively be overridden by the local login.
- In McWeb/mcsimrunner_ng/mcweb/settings.py add your hosting hostname or ip address to the list ALLOWED_HOSTS.
- Use crontab to set the cronjobs in McWeb/scripts/cronjobs.txt (user: www-data).
- Create a Django superuser and add her to LDAP with e.g.
- python manage.py createsuperuser ...
- python manage.py ldap_adduser ...