From dfbea01c8fa7f31c0f81a4aa51d0f02facd567f8 Mon Sep 17 00:00:00 2001 From: Vladislav Manchev Date: Tue, 12 Jan 2016 14:08:43 +0200 Subject: [PATCH] Add support for running OpenBSD in development environment. --- README.dev.md | 31 ++++++++++++++++++++++++- bin/write-rabbitmq-consumers-state-file | 3 ++- scripts/lib/install | 3 ++- scripts/setup/configure-rabbitmq | 4 +++- scripts/setup/flush-memcached | 6 +++-- scripts/setup/initialize-database | 3 ++- scripts/setup/terminate-psql-sessions | 11 ++++++--- tools/build-api-tarball | 3 ++- tools/build-release-tarball | 4 +++- tools/clean-branches | 3 ++- tools/clean-repo | 5 ++-- tools/deprecated/backup | 3 ++- tools/deprecated/install-server | 3 ++- tools/django-template-graph | 3 ++- tools/do-destroy-rebuild-database | 4 +++- tools/do-destroy-rebuild-test-database | 4 +++- tools/download-zxcvbn | 4 +++- tools/emoji_dump/build_emoji | 6 +++-- tools/generate-fixtures | 3 ++- tools/generate-test-credentials | 3 ++- tools/node | 3 ++- tools/postgres-init-dev-db | 15 ++++++++++-- tools/postgres-init-test-db | 4 +++- tools/test-all | 3 ++- tools/test-backend | 3 ++- tools/test-js-with-node | 3 ++- 26 files changed, 108 insertions(+), 32 deletions(-) diff --git a/README.dev.md b/README.dev.md index 915e11c0c1..ac3c335009 100644 --- a/README.dev.md +++ b/README.dev.md @@ -204,6 +204,35 @@ host all all ::1/128 md5 Now continue with the Common to Fedora/CentOS instructions below. +### On OpenBSD 5.8 (experimental): + +These instructions are experimental and may have bugs; patches welcome! + +``` +doas pkg_add sudo bash gcc postgresql-server redis rabbitmq memcached node libmemcached py-Pillow py-cryptography py-cffi + +# Get tsearch_extras and build it (using a modified version which aliases int4 on OpenBSD): +git clone https://github.com/blablacio/tsearch_extras +cd tsearch_extras +gmake && sudo gmake install + +# Point environment to custom include locations and use newer GCC (needed for Node modules): +export CFLAGS="-I/usr/local/include -I/usr/local/include/sasl" +export CXX=eg++ + +# Create tsearch_data directory: +sudo mkdir /usr/local/share/postgresql/tsearch_data + + +# Hack around missing dictionary files -- need to fix this to get +# the proper dictionaries from what in debian is the hunspell-en-us package. +sudo touch /usr/local/share/postgresql/tsearch_data/english.stop +sudo touch /usr/local/share/postgresql/tsearch_data/en_us.dict +sudo touch /usr/local/share/postgresql/tsearch_data/en_us.affix +``` + +Now continue with the All Systems instructions below. + ### Common to Fedora/CentOS instructions ``` @@ -243,7 +272,7 @@ npm install ./tools/download-zxcvbn ./tools/emoji_dump/build_emoji ./scripts/setup/generate_secrets.py -d -sudo cp ./puppet/zulip/files/postgresql/zulip_english.stop /usr/share/postgresql/9.3/tsearch_data/ +if [ $(uname) = "OpenBSD" ]; then sudo cp ./puppet/zulip/files/postgresql/zulip_english.stop /var/postgresql/tsearch_data/; else sudo cp ./puppet/zulip/files/postgresql/zulip_english.stop /usr/share/postgresql/9.3/tsearch_data/; fi ./scripts/setup/configure-rabbitmq ./tools/postgres-init-dev-db ./tools/do-destroy-rebuild-database diff --git a/bin/write-rabbitmq-consumers-state-file b/bin/write-rabbitmq-consumers-state-file index a84c60be5e..f67893bb44 100755 --- a/bin/write-rabbitmq-consumers-state-file +++ b/bin/write-rabbitmq-consumers-state-file @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e queue=$1 diff --git a/scripts/lib/install b/scripts/lib/install index 3c6e3a7e76..5571f6721b 100755 --- a/scripts/lib/install +++ b/scripts/lib/install @@ -1,4 +1,5 @@ -#!/bin/bash -xe +#!/usr/bin/env bash +set -xe # Assumes we've already been untarred diff --git a/scripts/setup/configure-rabbitmq b/scripts/setup/configure-rabbitmq index 9c435a7611..bee7d48064 100755 --- a/scripts/setup/configure-rabbitmq +++ b/scripts/setup/configure-rabbitmq @@ -1,7 +1,9 @@ -#!/bin/sh -xe +#!/usr/bin/env bash # # Delete the "guest" default user and replace it with a Zulip user # with a real password +set -e +set -x RABBITMQ_USERNAME=$("$(dirname "$0")/../../bin/get-django-setting" RABBITMQ_USERNAME) RABBITMQ_PASSWORD=$("$(dirname "$0")/../../bin/get-django-setting" RABBITMQ_PASSWORD) diff --git a/scripts/setup/flush-memcached b/scripts/setup/flush-memcached index ede74ea66e..7b09df47c8 100755 --- a/scripts/setup/flush-memcached +++ b/scripts/setup/flush-memcached @@ -1,4 +1,6 @@ -#!/bin/sh -xe +#!/usr/bin/env bash +set -e +set -x # Flush memcached -echo 'flush_all' | nc localhost 11211 +echo 'flush_all' | nc -w 0 localhost 11211 diff --git a/scripts/setup/initialize-database b/scripts/setup/initialize-database index c3a1dcd70e..031a73eea8 100755 --- a/scripts/setup/initialize-database +++ b/scripts/setup/initialize-database @@ -1,4 +1,5 @@ -#!/bin/bash -xe +#!/usr/bin/env bash +set -xe # Change to root directory of the checkout that we're running from cd "$(dirname "$0")/../.." diff --git a/scripts/setup/terminate-psql-sessions b/scripts/setup/terminate-psql-sessions index e97dc394b9..c10fa60a89 100755 --- a/scripts/setup/terminate-psql-sessions +++ b/scripts/setup/terminate-psql-sessions @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e set -x @@ -6,9 +6,14 @@ vergte() { [ "$1" = "`echo -e "$1\n$2" | sort -V | tail -n1`" ] } +DEFAULT_USER="postgres" +if [ "$(uname)" = "OpenBSD" ]; then + DEFAULT_USER="_postgresql" +fi + cd / if [ "$EUID" -eq 0 ]; then - version=$(su postgres -c 'psql -A -t -d postgres -c "show server_version"') + version=$(sudo -u "$DEFAULT_USER" sh -c 'psql -A -t -d postgres -c "show server_version"') else version=$(psql -A -t -d postgres -c "show server_version") fi @@ -25,7 +30,7 @@ else fi if [ "$EUID" -eq 0 ]; then - su postgres -c psql postgres postgres < "$1" diff --git a/tools/generate-test-credentials b/tools/generate-test-credentials index 5c25eebebf..0238570cc6 100755 --- a/tools/generate-test-credentials +++ b/tools/generate-test-credentials @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e cd "$(dirname "$0")"/.. diff --git a/tools/node b/tools/node index ae51083904..0afe14f415 100755 --- a/tools/node +++ b/tools/node @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e # Wrapper for node which finds the right binary. diff --git a/tools/postgres-init-dev-db b/tools/postgres-init-dev-db index cf71624407..5039532b1f 100755 --- a/tools/postgres-init-dev-db +++ b/tools/postgres-init-dev-db @@ -1,12 +1,23 @@ -#!/bin/bash -xe +#!/usr/bin/env bash +set -x +set -e -ROOT_POSTGRES="sudo -u postgres psql" +DEFAULT_USER="postgres" +if [ "$(uname)" = "OpenBSD" ]; then + DEFAULT_USER="_postgresql" +fi + +ROOT_POSTGRES="sudo -u "$DEFAULT_USER" psql" DEFAULT_DB="" if [ "$(uname)" = "Darwin" ]; then ROOT_POSTGRES="psql" DEFAULT_DB="postgres" fi +if [ "$(uname)" = "OpenBSD" ]; then + DEFAULT_DB="postgres" +fi + VAGRANTUSERNAME=$(whoami) if [[ $# == 0 ]]; then diff --git a/tools/postgres-init-test-db b/tools/postgres-init-test-db index f67ae3b669..0a3a461b1e 100755 --- a/tools/postgres-init-test-db +++ b/tools/postgres-init-test-db @@ -1,3 +1,5 @@ -#!/bin/bash -xe +#!/usr/bin/env bash +set -x +set -e "$(dirname "$0")/postgres-init-dev-db" zulip_test "$("$(dirname "$0")/../bin/get-django-setting" LOCAL_DATABASE_PASSWORD)" zulip_test zulip,public diff --git a/tools/test-all b/tools/test-all index f2afc7ae3a..c4dad02963 100755 --- a/tools/test-all +++ b/tools/test-all @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e cd "$(dirname "$0")"/.. diff --git a/tools/test-backend b/tools/test-backend index 2e73744a6d..2533781a8a 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e target='zerver' diff --git a/tools/test-js-with-node b/tools/test-js-with-node index 90510e51ec..536dec74be 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -1,4 +1,5 @@ -#!/bin/bash -e +#!/usr/bin/env bash +set -e cd "$(dirname "$0")"/..