2018-02-02 02:36:09 +07:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-12-07 22:09:30 +07:00
|
|
|
TZ=${TZ:-UTC}
|
|
|
|
|
2018-02-02 02:36:09 +07:00
|
|
|
JLS_PATH="/opt/jetbrains-license-server"
|
2018-02-15 22:52:47 +07:00
|
|
|
JLS_LISTEN_ADDRESS="0.0.0.0"
|
2019-01-23 01:49:15 +07:00
|
|
|
JLS_PORT=8000
|
2018-12-03 10:46:31 +07:00
|
|
|
JLS_CONTEXT=${JLS_CONTEXT:-/}
|
|
|
|
JLS_ACCESS_CONFIG=${JLS_ACCESS_CONFIG:-/data/access-config.json}
|
2019-11-29 00:28:07 +07:00
|
|
|
JLS_PROXY_TYPE=${JLS_PROXY_TYPE:-https}
|
2018-02-02 02:36:09 +07:00
|
|
|
|
2019-11-17 13:15:23 +07:00
|
|
|
if [ -n "${PGID}" ] && [ "${PGID}" != "$(id -g jls)" ]; then
|
|
|
|
echo "Switching to PGID ${PGID}..."
|
|
|
|
sed -i -e "s/^jls:\([^:]*\):[0-9]*/jls:\1:${PGID}/" /etc/group
|
|
|
|
sed -i -e "s/^jls:\([^:]*\):\([0-9]*\):[0-9]*/jls:\1:\2:${PGID}/" /etc/passwd
|
|
|
|
fi
|
|
|
|
if [ -n "${PUID}" ] && [ "${PUID}" != "$(id -u jls)" ]; then
|
|
|
|
echo "Switching to PUID ${PUID}..."
|
|
|
|
sed -i -e "s/^jls:\([^:]*\):[0-9]*:\([0-9]*\)/jls:\1:${PUID}:\2/" /etc/passwd
|
|
|
|
fi
|
|
|
|
|
2019-12-07 22:09:30 +07:00
|
|
|
# Timezone
|
|
|
|
echo "Setting timezone to ${TZ}..."
|
|
|
|
ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime
|
|
|
|
echo ${TZ} > /etc/timezone
|
|
|
|
|
2018-02-15 22:52:47 +07:00
|
|
|
# Init
|
|
|
|
echo "Initializing files and folders..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls touch "/data/access-config.json"
|
2018-02-15 22:52:47 +07:00
|
|
|
|
2018-02-02 02:36:09 +07:00
|
|
|
# https://www.jetbrains.com/help/license_server/setting_host_and_port.html
|
|
|
|
echo "Configuring Jetbrains License Server..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --listen ${JLS_LISTEN_ADDRESS} --port ${JLS_PORT} --context ${JLS_CONTEXT}
|
2018-02-02 02:36:09 +07:00
|
|
|
|
|
|
|
# https://www.jetbrains.com/help/license_server/setting_host_and_port.html
|
2019-11-28 23:12:56 +07:00
|
|
|
if [ ! -z "$JLS_VIRTUAL_HOSTS" ]; then
|
2019-10-10 20:58:56 +07:00
|
|
|
echo "Following virtual hosts will be used:"
|
2018-02-02 02:36:09 +07:00
|
|
|
for JLS_VIRTUAL_HOST in $(echo ${JLS_VIRTUAL_HOSTS} | tr "," "\n"); do
|
|
|
|
echo "-> ${JLS_VIRTUAL_HOST}"
|
|
|
|
done
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --jetty.virtualHosts.names=${JLS_VIRTUAL_HOSTS}
|
2018-02-02 02:36:09 +07:00
|
|
|
fi
|
|
|
|
|
2019-11-28 23:12:56 +07:00
|
|
|
# https://www.jetbrains.com/help/license_server/configuring_proxy_settings.html
|
|
|
|
if [ ! -z "$JLS_PROXY_HOST" -a ! -z "$JLS_PROXY_PORT" ]; then
|
|
|
|
echo "Setting ${JLS_PROXY_TYPE} proxy to $JLS_PROXY_HOST:$JLS_PROXY_PORT..."
|
|
|
|
su-exec jls:jls license-server configure \
|
|
|
|
-J-D${JLS_PROXY_TYPE}.proxyHost=${JLS_PROXY_HOST} \
|
|
|
|
-J-D${JLS_PROXY_TYPE}.proxyPort=${JLS_PROXY_PORT}
|
|
|
|
|
|
|
|
if [ ! -z "$JLS_PROXY_USER" -a ! -z "$JLS_PROXY_PASSWORD" ]; then
|
|
|
|
echo "Setting ${JLS_PROXY_TYPE} proxy credentials..."
|
|
|
|
su-exec jls:jls license-server configure \
|
|
|
|
-J-D${JLS_PROXY_TYPE}.proxyUser=${JLS_PROXY_USER} \
|
|
|
|
-J-D${JLS_PROXY_TYPE}.proxyPassword=${JLS_PROXY_PASSWORD}
|
|
|
|
fi
|
|
|
|
fi
|
2019-11-29 00:28:07 +07:00
|
|
|
unset JLS_PROXY_USER
|
|
|
|
unset JLS_PROXY_PASSWORD
|
2019-11-28 23:12:56 +07:00
|
|
|
|
2018-02-02 02:36:09 +07:00
|
|
|
# https://www.jetbrains.com/help/license_server/configuring_user_restrictions.html
|
|
|
|
if [ -s "$JLS_ACCESS_CONFIG" ]; then
|
|
|
|
echo "Enabling user restrictions access from $JLS_ACCESS_CONFIG..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --access.config=file:${JLS_ACCESS_CONFIG}
|
2018-02-02 02:36:09 +07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# https://www.jetbrains.com/help/license_server/detailed_server_usage_statistics.html
|
2019-11-28 23:12:56 +07:00
|
|
|
if [ ! -z "$JLS_SMTP_SERVER" -a ! -z "$JLS_STATS_RECIPIENTS" ]; then
|
2018-12-03 10:46:31 +07:00
|
|
|
JLS_SMTP_PORT=${JLS_SMTP_PORT:-25}
|
2018-02-02 02:36:09 +07:00
|
|
|
echo "Enabling User Reporting via SMTP at $JLS_SMTP_SERVER:$JLS_SMTP_PORT..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --smtp.server ${JLS_SMTP_SERVER} --smtp.server.port ${JLS_SMTP_PORT}
|
2018-02-02 02:36:09 +07:00
|
|
|
|
2019-11-28 23:12:56 +07:00
|
|
|
if [ ! -z "$JLS_SMTP_USERNAME" -a ! -z "$JLS_SMTP_PASSWORD" ]; then
|
2018-02-02 02:36:09 +07:00
|
|
|
echo "Using SMTP username $JLS_SMTP_USERNAME with password..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --smtp.server.username ${JLS_SMTP_USERNAME}
|
|
|
|
su-exec jls:jls license-server configure --smtp.server.password ${JLS_SMTP_PASSWORD}
|
2018-02-02 02:36:09 +07:00
|
|
|
fi
|
2019-11-29 00:28:07 +07:00
|
|
|
unset JLS_SMTP_USERNAME
|
|
|
|
unset JLS_SMTP_PASSWORD
|
2018-02-02 02:36:09 +07:00
|
|
|
|
2019-11-28 23:12:56 +07:00
|
|
|
if [ ! -z "$JLS_STATS_FROM" ]; then
|
2018-02-02 02:36:09 +07:00
|
|
|
echo "Setting stats sender to $JLS_STATS_FROM..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --stats.from ${JLS_STATS_FROM}
|
2018-02-02 02:36:09 +07:00
|
|
|
fi
|
|
|
|
|
2018-02-16 08:02:48 +07:00
|
|
|
if [ "$JLS_REPORT_OUT_OF_LICENSE" -gt 0 ]; then
|
|
|
|
echo "Setting report out of licence to $JLS_REPORT_OUT_OF_LICENSE%..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --reporting.out.of.license.threshold ${JLS_REPORT_OUT_OF_LICENSE}
|
2018-02-16 08:02:48 +07:00
|
|
|
fi
|
|
|
|
|
2018-02-02 02:36:09 +07:00
|
|
|
echo "Stats recipients: $JLS_STATS_RECIPIENTS..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --stats.recipients ${JLS_STATS_RECIPIENTS}
|
2018-02-02 02:36:09 +07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# https://www.jetbrains.com/help/license_server/detailed_server_usage_statistics.html
|
2019-11-28 23:12:56 +07:00
|
|
|
if [ ! -z "$JLS_STATS_TOKEN" ]; then
|
2018-02-02 02:36:09 +07:00
|
|
|
echo "Enabling stats via API at /$JLS_STATS_TOKEN..."
|
2019-11-17 13:15:23 +07:00
|
|
|
su-exec jls:jls license-server configure --reporting.token ${JLS_STATS_TOKEN}
|
2018-02-02 02:36:09 +07:00
|
|
|
fi
|
2019-11-28 23:12:56 +07:00
|
|
|
unset JLS_STATS_TOKEN
|
2018-02-02 02:36:09 +07:00
|
|
|
|
2019-11-17 13:15:23 +07:00
|
|
|
echo "Fixing perms..."
|
|
|
|
chown -R jls:jls /data "$JLS_PATH"
|
|
|
|
|
|
|
|
exec su-exec jls:jls "$@"
|