diff options
author | Stevan Radakovic <stevan.radakovic@linaro.org> | 2018-06-06 14:56:41 +0200 |
---|---|---|
committer | Stevan Radakovic <stevan.radakovic@linaro.org> | 2018-06-06 14:56:41 +0200 |
commit | 4b7993a015c5236be6365a36df7d6bef2270ddd0 (patch) | |
tree | 445d8167b9ac3241b244f2502e65ed08c78183d2 | |
parent | 146b00a2eb8170a6b71186d25ee48bb9e8914f9e (diff) |
Remove obsolete parts in postinst.
-rw-r--r-- | debian/lava-server.postinst | 169 |
1 files changed, 0 insertions, 169 deletions
diff --git a/debian/lava-server.postinst b/debian/lava-server.postinst index f90b328..8bd8a90 100644 --- a/debian/lava-server.postinst +++ b/debian/lava-server.postinst @@ -19,183 +19,14 @@ set -e LAVA_SYS_MOUNTDIR="/var/lib/lava-server/default" -master_config() { - if [ "$LAVA_INSTANCE" = '$LAVA_INSTANCE' ] - then - LAVA_DB_NAME="default" - fi - if [ "$LAVA_DB_NAME" = '$LAVA_DB_NAME' ] - then - LAVA_DB_NAME="lavaserver" - fi - if [ "$LAVA_DB_USER" = '$LAVA_DB_USER' ] - then - LAVA_DB_USER="lavaserver" - fi - if [ "$LAVA_DB_PORT" = '$LAVA_DB_PORT' ] - then - LAVA_DB_PORT=5432 - fi - if [ "$LAVA_DB_PASSWORD" = '$LAVA_DB_PASSWORD' ] - then - LAVA_DB_PASSWORD=`env LANG=C LC_ALL=C tr -dc "[:alnum:]" < /dev/urandom | dd bs=1 count=12 2>/dev/null` - fi - LAVA_SYS_USER="lavaserver" - LAVA_SYS_HOME=/var/lib/lava-server/home/ - if [ "$LAVA_DB_PORT" = '' ] - then - LAVA_DB_PORT=5432 - fi - if [ "$LAVA_PREFIX" = '' ] - then - LAVA_PREFIX="/var/lib/lava-server/" - fi - write_config() { - # reduce the content of this conf file once l-d-t is replaced. - cat <<INSTANCE_CONF -# Instance name -LAVA_INSTANCE="$LAVA_INSTANCE" -# System configuration (Unix-level) -LAVA_SYS_USER="$LAVA_SYS_USER" -# PostgreSQL configuration -LAVA_DB_NAME="$LAVA_DB_NAME" -LAVA_DB_USER="$LAVA_DB_USER" -LAVA_DB_SERVER="localhost" -LAVA_DB_PORT="$LAVA_DB_PORT" -LAVA_DB_PASSWORD="$LAVA_DB_PASSWORD" -INSTANCE_CONF - } - write_config >/etc/lava-server/instance.conf - rm -f /etc/lava-server/worker.conf -} die() { echo "$1" exit 1 } -install_database() -{ - VIEWS=$1 - # check postgres is not just installed but actually ready. - pg=1 - limit=3 - while [ $pg -le $limit ]; do - if ! pg_isready -d '$LAVA_DB_NAME' -p $LAVA_DB_PORT -q; then - echo "[$pg] Postgres not ready for connection to $LAVA_DB_NAME on port $LAVA_DB_PORT." - sleep 1 - else - break - fi - pg=$(( $pg + 1 )) - done - if [ $pg -ge $limit ]; then - echo "Failed to connect to postgres." - exit $pg - fi - # Create database user, if it doesn't exist - if ! su postgres -c "psql \"-c SELECT usename FROM pg_user WHERE usename='$LAVA_DB_USER'\"" | grep "$LAVA_DB_USER"; then - su postgres -c "createuser --no-createdb --encrypted --login --no-superuser --no-createrole --no-password --port $LAVA_DB_PORT $LAVA_DB_USER"|| "Failed to create database user" - # Set a password for our new user - su postgres -c "psql --port $LAVA_DB_PORT --quiet --command=\"ALTER USER \"$LAVA_DB_USER\" WITH PASSWORD '$LAVA_DB_PASSWORD'\"" || die "Failed to set database password" - fi - # Create a database for our new user, if it doesn't exist - if ! su postgres -c "psql -c \"SELECT datname FROM pg_database WHERE datname='$LAVA_DB_NAME'\"" | grep "$LAVA_DB_NAME"; then - su postgres -c "createdb --port $LAVA_DB_PORT --locale=C.UTF-8 --encoding=UTF-8 --owner=$LAVA_DB_USER --template=template0 --no-password $LAVA_DB_NAME" || die "Failed to create a database" - fi - # Create devel user, if it doesn't exist, for unit test support - if ! su postgres -c "psql \"-c SELECT usename FROM pg_user WHERE usename='devel'\"" | grep "devel"; then - su postgres -c "createuser --createdb --login --no-superuser --no-createrole --no-password --port $LAVA_DB_PORT devel"|| "Failed to create test case user" - # Set a password for the devel user - su postgres -c "psql --port $LAVA_DB_PORT --quiet --command=\"ALTER USER \"devel\" WITH PASSWORD 'devel'\"" || die "Failed to set test case password" - fi - # create the devel database, if it doesn't exist - if ! su postgres -c "psql -c \"SELECT datname FROM pg_database WHERE datname='devel'\"" | grep "devel"; then - su postgres -c "createdb devel --owner devel" - fi - # existing materialized views can interfere with migrations - if [ "$VIEWS" = "drop_views" ]; then - echo "Dropping materialized views ahead of migration." - lava-server manage drop_materialized_views - fi - # syncdb - # fake-initial only in django 1.8 but needed for upgrades from 1.7 using 1.9 - if [ "`dpkg --compare-versions $(django-admin --version) gt '1.8' && echo $?`" = '0' ]; then - lava-server manage migrate --noinput --fake-initial - else - lava-server manage migrate --noinput - fi - # recreate materialized views after the migration changes are complete. - echo "Refreshing all materialized views: lava-server manage refresh_queries --all" - lava-server manage refresh_queries --all - # superuser - password must be changed - if ! su postgres -c "psql \"-c SELECT usename FROM pg_user WHERE usename='$LAVA_SYS_USER'\"" | grep "$LAVA_SYS_USER"; then - if ! su postgres -c "psql $LAVA_DB_NAME \"-c SELECT username FROM auth_user WHERE username='$LAVA_SYS_USER'\"" | grep "$LAVA_SYS_USER"; then - lava-server manage createsuperuser --noinput --username=$LAVA_SYS_USER --email=$LAVA_SYS_USER@lava.invalid || true - fi - fi -} - - case "$1" in configure) - if [ -f /etc/lava-server/instance.conf ]; then - . /etc/lava-server/instance.conf - else - . /usr/share/lava-server/instance.conf.template - fi - if [ -z "$LAVA_SYS_USER" ]; then - LAVA_SYS_USER="lavaserver" - fi - master_config - # directories within the SSHFS mount, only on master - mkdir -p $LAVA_SYS_MOUNTDIR/media/job-output/ - adduser --quiet --system --group --home $LAVA_SYS_HOME $LAVA_SYS_USER --shell /bin/sh - find $LAVA_SYS_MOUNTDIR -maxdepth 2 -type d -exec chown $LAVA_SYS_USER:$LAVA_SYS_USER {} \; - # fixup bug from date based subdirectories - allowed to be missing. - find $LAVA_SYS_MOUNTDIR/media/job-output/2017 -maxdepth 2 -type d -exec chown $LAVA_SYS_USER:$LAVA_SYS_USER {} \; 2>/dev/null || true - # support changes in xml-rpc API for 2017.6 - find /etc/lava-server/dispatcher.d/ -maxdepth 1 -exec chown $LAVA_SYS_USER:$LAVA_SYS_USER {} \; 2>/dev/null || true - find /etc/lava-server/dispatcher-config/ -maxdepth 1 -type d -exec chown $LAVA_SYS_USER:$LAVA_SYS_USER {} \; 2>/dev/null || true - find /etc/lava-server/dispatcher-config/devices/ -maxdepth 1 -exec chown $LAVA_SYS_USER:$LAVA_SYS_USER {} \; 2>/dev/null || true - find /etc/lava-server/dispatcher-config/devices-types/ -maxdepth 1 -exec chown $LAVA_SYS_USER:$LAVA_SYS_USER {} \; 2>/dev/null || true - # user may not have been removed but the directory has, after purge. - if [ ! -d $LAVA_SYS_HOME ]; then - mkdir $LAVA_SYS_HOME - chown $LAVA_SYS_USER:$LAVA_SYS_USER $LAVA_SYS_HOME - fi - # Fix permissions of /etc/lava-server/instance.conf - chown $LAVA_SYS_USER:$LAVA_SYS_USER /etc/lava-server/instance.conf - chmod 0640 /etc/lava-server/instance.conf - # Allow lavaserver to write to all the log files - chmod u+rXs /var/log/lava-server/ - # Allow users in the adm group to read the scheduler logs - touch /var/log/lava-server/lava-scheduler.log - chgrp adm /var/log/lava-server/lava-scheduler.log - chmod g+rXs /var/log/lava-server/ - # Allow lava user to write the secret key - touch /etc/lava-server/secret_key.conf - chown $LAVA_SYS_USER:$LAVA_SYS_USER /etc/lava-server/secret_key.conf - chmod 0640 /etc/lava-server/secret_key.conf - # Allow lavaserver to write device dictionary files - chown $LAVA_SYS_USER:$LAVA_SYS_USER /etc/lava-server/dispatcher-config/devices/ - # install database only on the master - # FIXME: determine if postgresql is installed. - if dpkg --compare-versions "$2" ge "2017.7-1"; then - install_database 'drop_views' - else - install_database '' - fi - # Allow lavaserver to write to all the log files - touch /var/log/lava-server/django.log - chown $LAVA_SYS_USER:adm /var/log/lava-server/django.log - - # allow reinstalls when the user has not been removed. - if [ ! -d $LAVA_SYS_HOME/ ]; then - mkdir -p $LAVA_SYS_HOME/ - else - chown $LAVA_SYS_USER:$LAVA_SYS_USER $LAVA_SYS_HOME/ - fi if [ -f /etc/apache2/sites-enabled/lava-server.conf ]; then apache2ctl restart fi |