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

minor fixes

parent aed5b2d6
#!/bin/bash #!/bin/bash
if [ ! -f /root/.admpwd ]; then
date | md5sum | head -c 16 > /root/.admpwd
fi
export ADMPWD=`cat /root/.admpwd`
export DEBCONF_FRONTEND=noninteractive export DEBCONF_FRONTEND=noninteractive
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -37,22 +42,22 @@ apt-get -y upgrade ...@@ -37,22 +42,22 @@ apt-get -y upgrade
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if [ ! -f /root/.my.cnf ]; then 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_again password $ADMPWD" | 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 password $ADMPWD" | debconf-set-selections
echo "mariadb-server-10.0 mariadb-server/oneway_migration boolean true" | 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 apt-get -y -t jessie-backports install mariadb-server
cat > /root/.my.cnf <<-EOF cat > /root/.my.cnf <<-EOF
[client] [client]
user = root user = root
password = zehdjkamam password = $ADMPWD
EOF EOF
fi
echo "CREATE DATABASE vispa;" | mysql echo "CREATE DATABASE vispa;" | mysql
echo "CREATE USER 'vispa'@'localhost' IDENTIFIED BY 'changeme';" | mysql echo "CREATE USER 'vispa'@'localhost' IDENTIFIED BY '$ADMPWD';" | mysql
echo "GRANT ALL PRIVILEGES ON vispa.* TO 'vispa'@'localhost';" | mysql echo "GRANT ALL PRIVILEGES ON vispa.* TO 'vispa'@'localhost';" | mysql
echo "FLUSH PRIVILEGES;" | mysql echo "FLUSH PRIVILEGES;" | mysql
fi
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# LDAP Server # LDAP Server
...@@ -61,8 +66,8 @@ echo "FLUSH PRIVILEGES;" | mysql ...@@ -61,8 +66,8 @@ echo "FLUSH PRIVILEGES;" | mysql
# LDAP SETUP: http://techpubs.spinlocksolutions.com/dklar/ldap.html # LDAP SETUP: http://techpubs.spinlocksolutions.com/dklar/ldap.html
echo "slapd slapd/password2 password zehdjkamam" | debconf-set-selections echo "slapd slapd/password2 password $ADMPWD" | debconf-set-selections
echo "slapd slapd/password1 password zehdjkamam" | debconf-set-selections echo "slapd slapd/password1 password $ADMPWD" | debconf-set-selections
echo "slapd slapd/backend select HDB" | debconf-set-selections echo "slapd slapd/backend select HDB" | debconf-set-selections
echo "slapd slapd/allow_ldap_v2 boolean false" | 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 ...@@ -72,7 +77,7 @@ apt-get -y -t jessie-backports install slapd ldap-utils
# LDAP Config # LDAP Config
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
SLAPD_PWD=`slappasswd -s zehdjkamam` SLAPD_PWD=`slappasswd -s $ADMPWD`
cat > /tmp/tmp.ldif <<EOF cat > /tmp/tmp.ldif <<EOF
########################################################### ###########################################################
...@@ -119,7 +124,7 @@ olcDbIndex: uid pres,eq ...@@ -119,7 +124,7 @@ olcDbIndex: uid pres,eq
dn: olcDatabase={1}hdb,cn=config dn: olcDatabase={1}hdb,cn=config
changeType: modify changeType: modify
add: olcDbIndex 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 dn: olcDatabase={1}hdb,cn=config
changeType: modify changeType: modify
...@@ -174,7 +179,7 @@ userPassword: $SLAPD_PWD ...@@ -174,7 +179,7 @@ userPassword: $SLAPD_PWD
description: LDAP administrator description: LDAP administrator
EOF 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 cat > /tmp/tmp.ldif <<EOF
dn: ou=people,dc=vispa,dc=local dn: ou=people,dc=vispa,dc=local
...@@ -186,23 +191,30 @@ ou: group ...@@ -186,23 +191,30 @@ ou: group
objectClass: organizationalUnit objectClass: organizationalUnit
EOF 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 # 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 if [ ! -d /srv/venv ]; then
virtualenv /srv/venv virtualenv /srv/venv
fi fi
#/srv/venv/bin/pip install --upgrade pip #/srv/venv/bin/pip install --upgrade pip
#/srv/venv/bin/pip install --upgrade -r /srv/vispa/requirements.txt #/srv/venv/bin/pip install --upgrade -r /srv/vispa/requirements.txt
/srv/venv/bin/pip install --upgrade pymysql /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/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 mkdir -p /etc/vispa
cat > /etc/vispa/cherrypy.ini <<EOF cat > /etc/vispa/cherrypy.ini <<EOF
...@@ -218,7 +230,7 @@ EOF ...@@ -218,7 +230,7 @@ EOF
cat > /etc/vispa/vispa.ini <<EOF cat > /etc/vispa/vispa.ini <<EOF
[database] [database]
sqlalchemy.url = mysql+pymysql://vispa:changeme@localhost/vispa sqlalchemy.url = mysql+pymysql://vispa:$ADMPWD@localhost/vispa
sqlalchemy.pool_size = 50 sqlalchemy.pool_size = 50
sqlalchemy.pool_recycle = 3600 sqlalchemy.pool_recycle = 3600
sqlalchemy.max_overflow = 50 sqlalchemy.max_overflow = 50
...@@ -226,7 +238,7 @@ sqlalchemy.max_overflow = 50 ...@@ -226,7 +238,7 @@ sqlalchemy.max_overflow = 50
[alembic] [alembic]
use_alembic = True use_alembic = True
# inplace installation # inplace installation
script_location = vispa/models/alembic #script_location = vispa/models/alembic
# global installation # global installation
#script_location = vispa:models/alembic #script_location = vispa:models/alembic
auto_migrate = True auto_migrate = True
...@@ -238,7 +250,7 @@ dev_mode = False ...@@ -238,7 +250,7 @@ dev_mode = False
[ldap-export] [ldap-export]
url = localhost url = localhost
user = cn=admin,dc=vispa,dc=local user = cn=admin,dc=vispa,dc=local
password = zehdjkamam password = $ADMPWD
user_base = ou=people,dc=vispa,dc=local user_base = ou=people,dc=vispa,dc=local
group_base = ou=group,dc=vispa,dc=local group_base = ou=group,dc=vispa,dc=local
sync_on_startup = False sync_on_startup = False
...@@ -261,7 +273,7 @@ EOF ...@@ -261,7 +273,7 @@ EOF
cat > /etc/systemd/system/vispa.service <<"EOF" cat > /etc/systemd/system/vispa.service <<"EOF"
[Unit] [Unit]
After=network.target After=network.target
[Service] [Service]
EnvironmentFile=-/etc/default/vispa EnvironmentFile=-/etc/default/vispa
...@@ -272,7 +284,7 @@ RestartSec=2 ...@@ -272,7 +284,7 @@ RestartSec=2
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
...@@ -320,3 +332,19 @@ Session: ...@@ -320,3 +332,19 @@ Session:
EOF EOF
pam-auth-update --package 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 ...@@ -11,7 +11,7 @@ from sqlalchemy.orm import scoped_session, sessionmaker
import ldap3 import ldap3
from ldap3.utils.log import set_library_log_detail_level, OFF, BASIC, NETWORK, EXTENDED 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__) logger = logging.getLogger(__name__)
...@@ -120,7 +120,7 @@ class LDAPExport(object): ...@@ -120,7 +120,7 @@ class LDAPExport(object):
logger.info("Add user: %s, %s, %s", dn, classes, attributes) logger.info("Add user: %s, %s, %s", dn, classes, attributes)
try: try:
self.connection.add(dn, classes, attributes) self.connection.add(dn, classes, attributes)
except ldap3.LDAPEntryAlreadyExistsResult: except LDAPEntryAlreadyExistsResult:
logger.info(" -> updated") logger.info(" -> updated")
changes = { changes = {
'uid': _r(username), 'uid': _r(username),
...@@ -147,7 +147,7 @@ class LDAPExport(object): ...@@ -147,7 +147,7 @@ class LDAPExport(object):
logger.info("Add group: %s, %s, %s", dn, classes, attributes) logger.info("Add group: %s, %s, %s", dn, classes, attributes)
try: try:
self.connection.add(dn, classes, attributes) self.connection.add(dn, classes, attributes)
except ldap3.LDAPEntryAlreadyExistsResult: except LDAPEntryAlreadyExistsResult:
logger.info(" -> updated") logger.info(" -> updated")
changes = { changes = {
'cn': _r(name), 'cn': _r(name),
...@@ -162,7 +162,7 @@ class LDAPExport(object): ...@@ -162,7 +162,7 @@ class LDAPExport(object):
} }
try: try:
self.connection.modify(dn, change) self.connection.modify(dn, change)
except ldap3.LDAPAttributeOrValueExistsResult: except LDAPAttributeOrValueExistsResult:
pass pass
def user_set_password(self, name, password): def user_set_password(self, name, password):
......
...@@ -88,6 +88,7 @@ class TerminalController(AbstractController): ...@@ -88,6 +88,7 @@ class TerminalController(AbstractController):
self.release_session() self.release_session()
windowId = cherrypy.request.private_params.get("_windowId", None) windowId = cherrypy.request.private_params.get("_windowId", None)
viewId = cherrypy.request.private_params.get("_viewId", None) viewId = cherrypy.request.private_params.get("_viewId", None)
# TODO: add userid to tid
tid = windowId + "-" + viewId tid = windowId + "-" + viewId
terminal = self._terminal(tid) 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