Skip to content

Commit

Permalink
Merge pull request #1936 from SUSE/rmt-server-entrypoint-improvements
Browse files Browse the repository at this point in the history
Rmt server entrypoint improvements
  • Loading branch information
dirkmueller authored Oct 31, 2024
2 parents 798e106 + d41266d commit 5e91be1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
34 changes: 25 additions & 9 deletions src/bci_build/package/rmt-server/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e

# PV could be empty, make sure the directories exist
Expand All @@ -23,30 +23,46 @@ MYSQL_USER="${MYSQL_USER:-rmt}"
SCC_SYNC="${SCC_SYNC:-true}"

# Create adjusted /etc/rmt.conf
echo -e "database:\n host: ${MYSQL_HOST}\n database: ${MYSQL_DATABASE}\n username: ${MYSQL_USER}\n password: ${MYSQL_PASSWORD}" > /etc/rmt.conf
echo -e " adapter: mysql2\n encoding: utf8\n timeout: 5000\n pool: 5\n" >> /etc/rmt.conf
echo -e "scc:\n username: ${SCC_USERNAME}\n password: ${SCC_PASSWORD}\n sync_systems: true\n scc_sync: ${SCC_SYNC}\n" >> /etc/rmt.conf
echo -e "log_level:\n rails: debug" >> /etc/rmt.conf
cat > /etc/rmt.conf <<EOF
database:
host: ${MYSQL_HOST}
database: ${MYSQL_DATABASE}
username: ${MYSQL_USER}
password: ${MYSQL_PASSWORD}
adapter: mysql2
encoding: utf8
timeout: 5000
pool: 5
scc:
username: ${SCC_USERNAME}
password: ${SCC_PASSWORD}
sync_systems: true
scc_sync: ${SCC_SYNC}
log_level:
rails: debug
EOF

if [ $# -eq 0 ]; then
set -- /usr/share/rmt/bin/rails server -e production
fi

if [ "$1" == "/usr/share/rmt/bin/rails" -a "$2" == "server" ]; then
if [ "$1" = "/usr/share/rmt/bin/rails" ] && [ "$2" = "server" ]; then
echo "Create/migrate SUSE RMT database"
pushd /usr/share/rmt > /dev/null
/usr/share/rmt/bin/rails db:create db:migrate RAILS_ENV=production
popd > /dev/null
if [ ${SCC_SYNC} == "true" ]; then
if [ "${SCC_SYNC}" = "true" ]; then
echo "Syncing product list"
rmt-cli sync
for PRODUCT in $SCC_PRODUCT_ENABLE
do
rmt-cli products enable $PRODUCT
rmt-cli products enable "$PRODUCT"
done
for PRODUCT in $SCC_PRODUCT_DISABLE
do
rmt-cli products disable $PRODUCT
rmt-cli products disable "$PRODUCT"
done
rmt-cli repos clean
fi
Expand Down
2 changes: 1 addition & 1 deletion src/bci_build/package/rmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
version_in_uid=False,
support_level=SupportLevel.L3,
package_list=["rmt-server", "catatonit"],
package_list=["rmt-server", "catatonit", "bash"],
entrypoint=["/usr/local/bin/entrypoint.sh"],
cmd=["/usr/share/rmt/bin/rails", "server", "-e", "production"],
env={"RAILS_ENV": "production", "LANG": "en"},
Expand Down

0 comments on commit 5e91be1

Please sign in to comment.