Commit 3c4d1cae authored by Gero Müller's avatar Gero Müller

minor fixes

parent aed5b2d6
#!/bin/bash
if [ ! -f /root/.admpwd ]; then
date | md5sum | head -c 16 > /root/.admpwd
fi
export ADMPWD=`cat /root/.admpwd`
export DEBCONF_FRONTEND=noninteractive
# ----------------------------------------------------------------------
......@@ -37,22 +42,22 @@ apt-get -y upgrade
# ----------------------------------------------------------------------
if [ ! -f /root/.my.cnf ]; then
echo "mariadb-server-10.0 mysql-server/root_password_again password zehdjkamam" | debconf-set-selections
echo "mariadb-server-10.0 mysql-server/root_password password zehdjkamam" | debconf-set-selections
echo "mariadb-server-10.0 mysql-server/root_password_again password $ADMPWD" | debconf-set-selections
echo "mariadb-server-10.0 mysql-server/root_password password $ADMPWD" | debconf-set-selections
echo "mariadb-server-10.0 mariadb-server/oneway_migration boolean true" | debconf-set-selections
apt-get -y -t jessie-backports install mariadb-server
cat > /root/.my.cnf <<-EOF
[client]
user = root
password = zehdjkamam
password = $ADMPWD
EOF
fi
echo "CREATE DATABASE vispa;" | mysql
echo "CREATE USER 'vispa'@'localhost' IDENTIFIED BY 'changeme';" | mysql
echo "GRANT ALL PRIVILEGES ON vispa.* TO 'vispa'@'localhost';" | mysql
echo "FLUSH PRIVILEGES;" | mysql
echo "CREATE DATABASE vispa;" | mysql
echo "CREATE USER 'vispa'@'localhost' IDENTIFIED BY '$ADMPWD';" | mysql
echo "GRANT ALL PRIVILEGES ON vispa.* TO 'vispa'@'localhost';" | mysql
echo "FLUSH PRIVILEGES;" | mysql
fi
# ----------------------------------------------------------------------
# LDAP Server
......@@ -61,8 +66,8 @@ echo "FLUSH PRIVILEGES;" | mysql
# LDAP SETUP: http://techpubs.spinlocksolutions.com/dklar/ldap.html
echo "slapd slapd/password2 password zehdjkamam" | debconf-set-selections
echo "slapd slapd/password1 password zehdjkamam" | debconf-set-selections
echo "slapd slapd/password2 password $ADMPWD" | debconf-set-selections
echo "slapd slapd/password1 password $ADMPWD" | debconf-set-selections
echo "slapd slapd/backend select HDB" | debconf-set-selections
echo "slapd slapd/allow_ldap_v2 boolean false" | debconf-set-selections
......@@ -72,7 +77,7 @@ apt-get -y -t jessie-backports install slapd ldap-utils
# LDAP Config
# ----------------------------------------------------------------------
SLAPD_PWD=`slappasswd -s zehdjkamam`
SLAPD_PWD=`slappasswd -s $ADMPWD`
cat > /tmp/tmp.ldif <<EOF
###########################################################
......@@ -119,7 +124,7 @@ olcDbIndex: uid pres,eq
dn: olcDatabase={1}hdb,cn=config
changeType: modify
add: olcDbIndex
olcDbIndex: cn,sn,mail pres,eq,approx,sub
olcDbIndex: cn,sn,mail,memberUid pres,eq,approx,sub
dn: olcDatabase={1}hdb,cn=config
changeType: modify
......@@ -174,7 +179,7 @@ userPassword: $SLAPD_PWD
description: LDAP administrator
EOF
ldapadd -c -x -D cn=admin,dc=vispa,dc=local -w zehdjkamam -f /tmp/tmp.ldif
ldapadd -c -x -D cn=admin,dc=vispa,dc=local -w $ADMPWD -f /tmp/tmp.ldif
cat > /tmp/tmp.ldif <<EOF
dn: ou=people,dc=vispa,dc=local
......@@ -186,14 +191,14 @@ ou: group
objectClass: organizationalUnit
EOF
ldapadd -c -x -D cn=admin,dc=vispa,dc=local -w zehdjkamam -f /tmp/tmp.ldif
ldapadd -c -x -D cn=admin,dc=vispa,dc=local -w $ADMPWD -f /tmp/tmp.ldif
# ----------------------------------------------------------------------
# VISPA
# ----------------------------------------------------------------------
apt-get -y -t jessie-backports install python-virtualenv python-dev libffi-dev libssl-dev
apt-get -y -t jessie-backports install python-virtualenv python-dev libffi-dev libssl-dev build-essential
if [ ! -d /srv/venv ]; then
virtualenv /srv/venv
......@@ -201,8 +206,15 @@ fi
#/srv/venv/bin/pip install --upgrade pip
#/srv/venv/bin/pip install --upgrade -r /srv/vispa/requirements.txt
/srv/venv/bin/pip install --upgrade pymysql
/srv/venv/bin/pip install --upgrade setuptools
/srv/venv/bin/pip install --upgrade https://github.com/tomerfiliba/rpyc/archive/master.zip
/srv/venv/bin/python /srv/vispa/setup.py develop
if [ -f /srv/vispa/setup.py ]; then
/srv/venv/bin/python /srv/vispa/setup.py develop
#elif [ -f ../../setup.py ]; then
# /srv/venv/bin/python ../../setup.py develop
else
/srv/venv/bin/pip install --upgrade https://forge.physik.rwth-aachen.de/hg/vispa-web/vispa/archive/2.0.zip
fi
mkdir -p /etc/vispa
cat > /etc/vispa/cherrypy.ini <<EOF
......@@ -218,7 +230,7 @@ EOF
cat > /etc/vispa/vispa.ini <<EOF
[database]
sqlalchemy.url = mysql+pymysql://vispa:changeme@localhost/vispa
sqlalchemy.url = mysql+pymysql://vispa:$ADMPWD@localhost/vispa
sqlalchemy.pool_size = 50
sqlalchemy.pool_recycle = 3600
sqlalchemy.max_overflow = 50
......@@ -226,7 +238,7 @@ sqlalchemy.max_overflow = 50
[alembic]
use_alembic = True
# inplace installation
script_location = vispa/models/alembic
#script_location = vispa/models/alembic
# global installation
#script_location = vispa:models/alembic
auto_migrate = True
......@@ -238,7 +250,7 @@ dev_mode = False
[ldap-export]
url = localhost
user = cn=admin,dc=vispa,dc=local
password = zehdjkamam
password = $ADMPWD
user_base = ou=people,dc=vispa,dc=local
group_base = ou=group,dc=vispa,dc=local
sync_on_startup = False
......@@ -320,3 +332,19 @@ Session:
EOF
pam-auth-update --package
# ----------------------------------------------------------------------
# default workspace
# ----------------------------------------------------------------------
while true; do
started=`systemctl status vispa | grep "Bus STARTED" | wc -l`
if [ -z $started ]; then
echo "waiting for VISPA to startup.."
sleep 1
else
echo "delete from workspace where user_id is null;" | mysql vispa
echo "insert into workspace (user_id, name, host, auto_connect, login_credentials, command) values (null, 'vispa.local', 'localhost', 1, 1, '/srv/venv/bin/python');" | mysql vispa
break
fi
done
......@@ -11,7 +11,7 @@ from sqlalchemy.orm import scoped_session, sessionmaker
import ldap3
from ldap3.utils.log import set_library_log_detail_level, OFF, BASIC, NETWORK, EXTENDED
from ldap3.core.exceptions import LDAPNoSuchObjectResult
from ldap3.core.exceptions import LDAPNoSuchObjectResult, LDAPAttributeOrValueExistsResult, LDAPEntryAlreadyExistsResult
logger = logging.getLogger(__name__)
......@@ -120,7 +120,7 @@ class LDAPExport(object):
logger.info("Add user: %s, %s, %s", dn, classes, attributes)
try:
self.connection.add(dn, classes, attributes)
except ldap3.LDAPEntryAlreadyExistsResult:
except LDAPEntryAlreadyExistsResult:
logger.info(" -> updated")
changes = {
'uid': _r(username),
......@@ -147,7 +147,7 @@ class LDAPExport(object):
logger.info("Add group: %s, %s, %s", dn, classes, attributes)
try:
self.connection.add(dn, classes, attributes)
except ldap3.LDAPEntryAlreadyExistsResult:
except LDAPEntryAlreadyExistsResult:
logger.info(" -> updated")
changes = {
'cn': _r(name),
......@@ -162,7 +162,7 @@ class LDAPExport(object):
}
try:
self.connection.modify(dn, change)
except ldap3.LDAPAttributeOrValueExistsResult:
except LDAPAttributeOrValueExistsResult:
pass
def user_set_password(self, name, password):
......
......@@ -88,6 +88,7 @@ class TerminalController(AbstractController):
self.release_session()
windowId = cherrypy.request.private_params.get("_windowId", None)
viewId = cherrypy.request.private_params.get("_viewId", None)
# TODO: add userid to tid
tid = windowId + "-" + viewId
terminal = self._terminal(tid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment