2022-12-01 14:42:56 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-12-01 18:08:49 +01:00
|
|
|
DATA_DIR=${DATA_DIR:-/data}
|
2023-11-24 16:31:43 +01:00
|
|
|
|
2022-12-01 18:08:49 +01:00
|
|
|
mkdir -p ${DATA_DIR}
|
|
|
|
mkdir -p ${DATA_DIR}/couch/{dbs,views}
|
|
|
|
mkdir -p ${DATA_DIR}/search
|
|
|
|
chown -R couchdb:couchdb ${DATA_DIR}/couch
|
2023-11-24 16:31:43 +01:00
|
|
|
|
|
|
|
echo ${TARGETBUILD} > /buildtarget.txt
|
|
|
|
if [[ "${TARGETBUILD}" = "aas" ]]; then
|
|
|
|
# Azure AppService uses /home for persistent data & SSH on port 2222
|
|
|
|
DATA_DIR="${DATA_DIR:-/home}"
|
|
|
|
WEBSITES_ENABLE_APP_SERVICE_STORAGE=true
|
|
|
|
mkdir -p $DATA_DIR/{search,minio,couch}
|
|
|
|
mkdir -p $DATA_DIR/couch/{dbs,views}
|
|
|
|
chown -R couchdb:couchdb $DATA_DIR/couch/
|
|
|
|
apt update
|
|
|
|
apt-get install -y openssh-server
|
|
|
|
echo "root:Docker!" | chpasswd
|
|
|
|
mkdir -p /tmp
|
|
|
|
chmod +x /tmp/ssh_setup.sh \
|
|
|
|
&& (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null)
|
|
|
|
cp /etc/sshd_config /etc/ssh/sshd_config
|
|
|
|
/etc/init.d/ssh restart
|
|
|
|
sed -i "s#DATA_DIR#/home#g" /opt/clouseau/clouseau.ini
|
|
|
|
sed -i "s#DATA_DIR#/home#g" /opt/couchdb/etc/local.ini
|
|
|
|
elif [[ "${TARGETBUILD}" = "single" ]]; then
|
|
|
|
sed -i "s#DATA_DIR#/data#g" /opt/clouseau/clouseau.ini
|
|
|
|
sed -i "s#DATA_DIR#/data#g" /opt/couchdb/etc/local.ini
|
|
|
|
elif [[ -n $KUBERNETES_SERVICE_HOST ]]; then
|
|
|
|
# In Kubernetes the directory /opt/couchdb/data has a persistent volume
|
|
|
|
# mount for storing database data.
|
|
|
|
sed -i "s#DATA_DIR#/opt/couchdb/data#g" /opt/clouseau/clouseau.ini
|
|
|
|
sed -i "s#DATA_DIR#/opt/couchdb/data#g" /opt/couchdb/etc/local.ini
|
|
|
|
sed -i "s/^-name .*$//g" /opt/couchdb/etc/vm.args
|
|
|
|
else
|
|
|
|
sed -i "s#DATA_DIR#/data#g" /opt/clouseau/clouseau.ini
|
|
|
|
sed -i "s#DATA_DIR#/data#g" /opt/couchdb/etc/local.ini
|
|
|
|
fi
|
|
|
|
|
2022-12-15 18:28:39 +01:00
|
|
|
/opt/clouseau/bin/clouseau > /dev/stdout 2>&1 &
|
2022-12-01 14:42:56 +01:00
|
|
|
/docker-entrypoint.sh /opt/couchdb/bin/couchdb &
|
2023-11-24 16:31:43 +01:00
|
|
|
|
|
|
|
while [[ $(curl -s -w "%{http_code}\n" http://localhost:5984/_up -o /dev/null) -ne 200 ]]; do
|
|
|
|
echo 'Waiting for CouchDB to start...';
|
|
|
|
sleep 5;
|
|
|
|
done
|
|
|
|
|
2022-12-01 14:42:56 +01:00
|
|
|
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_users
|
|
|
|
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_replicator
|
|
|
|
sleep infinity
|