暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
24 容器endpoint代码解读.txt
69
11页
0次
2022-10-08
100墨值下载
### e. **entrypoint.sh**
```s
[root@ecs-lee 3.0.1]# cat entrypoint.sh
#!/usr/bin/env bash
set -Eeo pipefail
# 幻术
# usage: file_env VAR [DEFAULT]
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
# 环境变量
export GAUSSHOME=/usr/local/mogdb
export PATH=$GAUSSHOME/bin:$PATH
export LD_LIBRARY_PATH=$GAUSSHOME/lib:$LD_LIBRARY_PATH
export LANG=en_US.UTF-8
# 文件环境变量
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
# check to see if this file is being run or sourced from another script
_is_sourced() {
[ "${#FUNCNAME[@]}" -ge 2 ] \
&& [ "${FUNCNAME[0]}" = '_is_sourced' ] \
&& [ "${FUNCNAME[1]}" = 'source' ]
}
# used to create initial mogdb directories and if run as root, ensure ownership
belong to the omm
user
# 创建相关目录
docker_create_db_directories() {
local user; user="$(id -u)"
mkdir -p "$PGDATA"
chmod 700 "$PGDATA"
# ignore failure since it will be fine when using the image provided
directory;
mkdir -p /var/run/mogdb || :
chmod 775 /var/run/mogdb || :
# Create the transaction log directory before initdb is run so the directory
is owned by
the correct user
if [ -n "$POSTGRES_INITDB_XLOGDIR" ]; then
mkdir -p "$POSTGRES_INITDB_XLOGDIR"
if [ "$user" = '0' ]; then
find "$POSTGRES_INITDB_XLOGDIR" \! -user postgres -exec chown
postgres '{
}' +
fi
chmod 700 "$POSTGRES_INITDB_XLOGDIR"
fi
# allow the container to be started with `--user`
if [ "$user" = '0' ]; then
find "$PGDATA" \! -user omm -exec chown omm '{}' +
find /var/run/mogdb \! -user omm -exec chown omm '{}' +
fi
}
# initialize empty PGDATA directory with new database via 'initdb'
# arguments to `initdb` can be passed via POSTGRES_INITDB_ARGS or as arguments
to this function
# `initdb` automatically creates the "postgres", "template0", and "template1"
dbnames
# this is also where the database user is created, specified by `GS_USER` env
# 自定义变量,逻辑为若有传入则使用,没有则使用默认,其中包括
GS_NODENAMEENCODINGLOCALEDBCOMPATIBILITY
docker_init_database_dir() {
# "initdb" is particular about the current user existing in "/etc/passwd",
so we use "nss
_wrapper" to fake that if necessary
if ! getent passwd "$(id -u)" &> /dev/null && [ -e
/usr/lib/libnss_wrapper.so ]; then
export LD_PRELOAD='/usr/lib/libnss_wrapper.so'
export NSS_WRAPPER_PASSWD="$(mktemp)"
export NSS_WRAPPER_GROUP="$(mktemp)"
echo "postgres:x:$(id -u):$(id -g):PostgreSQL:$PGDATA:/bin/false" >
"$NSS_WRAPPER
_PASSWD"
echo "postgres:x:$(id -g):" > "$NSS_WRAPPER_GROUP"
fi
if [ -n "$POSTGRES_INITDB_XLOGDIR" ]; then
set -- --xlogdir "$POSTGRES_INITDB_XLOGDIR" "$@"
fi
cmdbase="gs_initdb --pwfile=<(echo "$GS_PASSWORD")"
if [ -n "$GS_NODENAME" ]; then
cmdbase="$cmdbase --nodename=$GS_NODENAME"
of 11
100墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜