#!/bin/sh -e # Add obsapi user and group to run the passenger RubyApp if ! getent group obsapi > /dev/null; then addgroup --system --quiet obsapi fi if ! getent passwd obsapi > /dev/null; then adduser --system --quiet \ --ingroup obsapi --shell /bin/false \ --no-create-home --home /nonexistent obsapi usermod -c "User for build service api/webui" obsapi fi # regenerate Gemfile.lock rm -f /usr/share/obs/api/Gemfile.lock cd /usr/share/obs/api # previous bundle config does not allow one to regenerate the Gemfile.lock rm -f .bundle/config || true bundle --local --quiet cd - >/dev/null chown www-data:www-data /usr/share/obs/api/Gemfile.lock # Place api and repo url on index page if [ ! -f /usr/share/obs/overview/index.html ] ; then FQHOSTNAME=`hostname -f` || FQHOSTNAME=obs-api sed -e "s,___API_URL___,https://$FQHOSTNAME,g" \ -e "s,___REPO_URL___,http://$FQHOSTNAME:82,g" \ /usr/share/obs/overview/overview.html.TEMPLATE > /usr/share/obs/overview/index.html fi # Config secret.key if [ ! -e "/usr/share/obs/api/config/secret.key" ]; then rm -f /usr/share/obs/api/config/secret.key fi SECRET_KEY="/etc/obs/api/config/secret.key" if [ ! -e "$SECRET_KEY" ]; then touch $SECRET_KEY chmod 0640 $SECRET_KEY chown obsapi:www-data $SECRET_KEY ( dd if=/dev/urandom bs=256 count=1 2>/dev/null |sha256sum| cut -d\ -f 1 >$SECRET_KEY ) ln -s $SECRET_KEY /usr/share/obs/api/config/secret.key else # cope with upgrades here to ensure that obsapi user own the key. chmod 0640 $SECRET_KEY chown obsapi:www-data $SECRET_KEY fi # Generate production.sphinx.conf and set owner www-data if [ ! -x /etc/obs/api/config/production.sphinx.conf ]; then touch /etc/obs/api/config/production.sphinx.conf chown www-data.www-data /etc/obs/api/config/production.sphinx.conf fi # Generate log files touch /var/log/obs/access.log touch /var/log/obs/backend_access.log touch /var/log/obs/delayed_job.log touch /var/log/obs/error.log touch /var/log/obs/lastevents.access.log touch /var/log/obs/production.log touch /var/log/obs/production.searchd.log touch /var/log/obs/production.searchd.query.log touch /var/log/obs/production.sphinx.pid touch /var/log/obs/clockworkd.clock.output # Refine permissions for log and tmp chown -R obsapi.www-data /var/log/obs chown -R obsapi.www-data /var/cache/obs/tmp # Grand www-data write access to the tmp folder chmod -R g+w /var/cache/obs/tmp # Set permissions for obsapi-*.service files as these runs as www-data chown www-data.www-data /var/cache/obs/tmp/pids # Config Database with dbconfig-common . /usr/share/debconf/confmodule . /usr/share/dbconfig-common/dpkg/postinst.mysql dbc_generate_include=template:/etc/obs/api/config/database.yml dbc_generate_include_args="-o template_infile=/usr/share/obs/api/config/database.yml.example" dbc_generate_include_owner=www-data dbc_go obs-api $@ # Secure database password chown obsapi.www-data /etc/obs/api/config/database.yml chmod 0440 /etc/obs/api/config/database.yml # Test whether a2ensite is available (and thus also apache2ctl). if [ -x "$(command -v a2ensite)" ]; then # Enable the obs site a2ensite obs.conf > /dev/null fi echo "OBS api installed. Please see /usr/share/doc/obs-api/README.Debian for the rest of setup." # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-clockwork.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-clockwork.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-clockwork.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-clockwork.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-delayedjob-queue-consistency_check.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-delayedjob-queue-consistency_check.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-delayedjob-queue-consistency_check.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-delayedjob-queue-consistency_check.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-delayedjob-queue-default.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-delayedjob-queue-default.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-delayedjob-queue-default.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-delayedjob-queue-default.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-delayedjob-queue-issuetracking.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-delayedjob-queue-issuetracking.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-delayedjob-queue-issuetracking.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-delayedjob-queue-issuetracking.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-delayedjob-queue-mailers.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-delayedjob-queue-mailers.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-delayedjob-queue-mailers.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-delayedjob-queue-mailers.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-delayedjob-queue-project_log_rotate.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-delayedjob-queue-project_log_rotate.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-delayedjob-queue-project_log_rotate.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-delayedjob-queue-project_log_rotate.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-delayedjob-queue-quick.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-delayedjob-queue-quick.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-delayedjob-queue-quick.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-delayedjob-queue-quick.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi-delayedjob-queue-releasetracking.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi-delayedjob-queue-releasetracking.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi-delayedjob-queue-releasetracking.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi-delayedjob-queue-releasetracking.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_systemd_enable/12.10 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # This will only remove masks created by d-s-h on package removal. deb-systemd-helper unmask 'obsapi.target' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'obsapi.target'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'obsapi.target' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'obsapi.target' >/dev/null || true fi fi # End automatically added section