caiok commented on a change in pull request #197: BOOKKEEPER-974: Add an 
official bookkeeper docker image
URL: https://github.com/apache/bookkeeper/pull/197#discussion_r127402908
 
 

 ##########
 File path: docker/4.4.0-alpine/run.sh
 ##########
 @@ -0,0 +1,68 @@
+#/bin/bash
+
+# -------------- #
+set -x -e -u
+# -------------- #
+
+# -------------- #
+# Allow the container to be started with `--user`
+if [ "$1" = 'bookkeeper' -a "$(id -u)" = '0' ]; then
+    chown -R "$BK_USER" "${BK_DIR}" "${BK_JOURNAL_DIR}" "${BK_LEDGER_DIR}" 
"${BK_INDEX_DIR}"
+    exec su-exec "$BK_USER" /bin/bash "$0" "$@"
+    exit
+fi
+# -------------- #
+
+# -------------- #
+# Copy input config files in Bookkeeper configuration directory
+cp -vaf /conf/* ${BK_DIR}/conf || true
+chown -R "$BK_USER" ${BK_DIR}/conf
+
+# Bookkeeper setup
+sed -r -i.bak \
+       -e "s|^journalDirectory.*=.*|journalDirectory=${BK_JOURNAL_DIR}|" \
+       -e "s|^ledgerDirectories.*=.*|ledgerDirectories=${BK_LEDGER_DIR}|" \
+       -e "s|^[# ]*indexDirectories.*=.*|indexDirectories=${BK_INDEX_DIR}|" \
+       -e "s|^[# 
]*useHostNameAsBookieID.*=.*false|useHostNameAsBookieID=true|" \
+       ${BK_DIR}/conf/bk_server.conf
+
+if [[ "${ZK_SERVERS}" != "" ]]; then
+       sed -r -i "s|^zkServers.*=.*|zkServers=${ZK_SERVERS}|" 
${BK_DIR}/conf/bk_server.conf
+fi
+if [[ "${BK_PORT}" != "" ]]; then
+       sed -r -i "s|^bookiePort.*=.*|bookiePort=${BK_PORT}|" 
${BK_DIR}/conf/bk_server.conf
+fi
+if [[ "${BK_LEDGERS_PATH}" != "" ]]; then
+       sed -r -i "s|^[# 
]*zkLedgersRootPath.*=.*|zkLedgersRootPath=${BK_LEDGERS_PATH}|" 
${BK_DIR}/conf/bk_server.conf
+fi
+
+diff ${BK_DIR}/conf/bk_server.conf.bak ${BK_DIR}/conf/bk_server.conf || true
+# -------------- #
+
+# -------------- #
+# Wait for zookeeper server
+#set +x
+#zk_server1=$(echo ${ZK_SERVERS} | cut -d"," -f1)
+#zk_server1_host=$(echo ${zk_server1} | cut -d":" -f1)
+#zk_server1_port=$(echo ${zk_server1} | cut -d":" -f2)
+
+#echo -en "\nWaiting for Zookeeper (${zk_server1_host}:${zk_server1_port})..."
+#while [[ $(nc -z ${zk_server1_host} ${zk_server1_port}) -ne 0 ]] ; do
+#      echo -n "."
+#      sleep 2
+#done
+#echo " Connected!"
+#set -x
+# -------------- #
+
+
+# -------------- #
+# Trying to format bookkeeper dir on zookeeper. If the dir already exists, it 
does nothing.
 
 Review comment:
   I've messed up someway this line before open the PR, the correct one is 
obviously "exec bookkeeper shell metaformat -nonInteractive || true"
   
   @sijie This command should ignore format if it find zk dir structure already 
formatted, right? What kind of issues can it arise? (just my curiosity)
   @jiazhai I will do metaformat only if it's passed a non empty env var 
BK_TRY_METAFORMAT, it should satisfy both requirements.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to