Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Nov 1, 2023
1 parent 4876c77 commit f8f4d54
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 35 deletions.
69 changes: 35 additions & 34 deletions .docker/gs64/docker-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,61 @@ readonly ANSI_BLUE="\\033[34m"
readonly ANSI_RESET="\\033[0m"

function print_info() {
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\\n" "$1"
else
echo "$1"
fi
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\\n" "$1"
else
echo "$1"
fi
}

function print_success() {
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\\n" "$1"
else
echo "$1"
fi
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\\n" "$1"
else
echo "$1"
fi
}

function print_error() {
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\\n" "$1" 1>&2
else
echo "$1" 1>&2
fi
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\\n" "$1" 1>&2
else
echo "$1" 1>&2
fi
}

function executeWithArguments() {
rm -rf logs out err
LAST_ARGUMENTS=$*
"$@" > out 2> err || true
rm -rf logs out err
LAST_ARGUMENTS=$*
"$@" > out 2> err || true
}

function assertOutputIncludesMessage() {
local message=$1
local output=$2

if [ "$(grep -c "$message" "$output")" -eq 0 ]; then
print_error "Expected std$output to have: '$message' when invoked with $LAST_ARGUMENTS"
print_info "Output contents"
cat "$output"
exit 1
fi
local message=$1
local output=$2

if [ "$(grep -c "$message" "$output")" -eq 0 ]; then
print_error "Expected std$output to have: '$message' when invoked with $LAST_ARGUMENTS"
print_info "Output contents"
cat "$output"
exit 1
fi
}

set -e

print_info "Creating network"
docker network prune --force
docker network rm --force launchpad-net
docker network create --attachable launchpad-net

print_info "Starting stone"
docker run --rm --detach --name gs64-stone \
-e TZ="America/Argentina/Buenos_Aires" \
--cap-add=SYS_RESOURCE \
--network=launchpad-net \
--volume=$PWD:/opt/gemstone/projects/Launchpad:ro \
--volume=$PWD/.docker/gs64/gem.conf:/opt/gemstone/conf/gem.conf \
ghcr.io/ba-st/gs64-rowan:v3.7.0
-e TZ="America/Argentina/Buenos_Aires" \
--cap-add=SYS_RESOURCE \
--network=launchpad-net \
--volume=$PWD:/opt/gemstone/projects/Launchpad:ro \

Check notice on line 62 in .docker/gs64/docker-tests.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] .docker/gs64/docker-tests.sh#L62 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./.docker/gs64/docker-tests.sh:62:12: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
--volume=$PWD/.docker/gs64/gem.conf:/opt/gemstone/conf/gem.conf \

Check notice on line 63 in .docker/gs64/docker-tests.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] .docker/gs64/docker-tests.sh#L63 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./.docker/gs64/docker-tests.sh:63:12: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
ghcr.io/ba-st/gs64-rowan:v3.7.0

sleep 1
print_info "Loading Launchpad in the stone"
Expand Down Expand Up @@ -149,3 +149,4 @@ print_success "OK"

print_info "Stopping stone"
docker stop gs64-stone
docker network rm --force launchpad-net
52 changes: 51 additions & 1 deletion docker/gs64/launchpad
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

# Configure NETLDI service database
echo "${NETLDI_SERVICE_NAME} ${NETLDI_PORT}/tcp # GemStone - Netldi" >> /etc/services

# Prepare Launchpad topaz input script
readonly SYSTEM_USER_PASSWORD="${GS64_SYSTEM_USER_PASSWORD:-swordfish}"
readonly STONE_NAME="${GS64_STONE_SERVICE_NAME:-gs64stone}"

Expand All @@ -13,4 +17,50 @@ doit
exit 0
EOF

exec topaz -l -- launchpad "$@"
# Ensure write permissions
NEED_WRITE_PERMISSION=(
"${GEMSTONE_GLOBAL_DIR}/locks/"
"${GEMSTONE_LOG_DIR}/"
)

for path in "${NEED_WRITE_PERMISSION[@]}"; do
if ! gosu "${GS_USER}" test -w "$path"; then
chown "${GS_UID}:${GS_GID}" "$path"
chmod ug+w "$path"
fi
done

pid=0

termination_handler() {
exit_status=0
if [ $pid -ne 0 ]; then
echo 'SIGTERM received, shutting down the gem'
kill "$pid"
stopnetldi
wait "$pid"
exit_status=$?
fi
exit "$exit_status"
}

trap 'termination_handler' SIGTERM

# start GemStone services
# shellcheck disable=SC2086
gosu "${GS_USER}" startnetldi \
-g \
-a "${GS_USER}" \
-n \
-P "${NETLDI_PORT}" \
-l "${GEMSTONE_LOG_DIR}/${NETLDI_SERVICE_NAME}.log" \
-D "${GEMSTONE_LOG_DIR}" \
${NETLDI_ARGS:-} \
"${NETLDI_SERVICE_NAME}"

# list GemStone services
gslist -cvl

gosu "${GS_USER}" topaz -l -- launchpad "$@"
pid="$!"
wait "$pid"

0 comments on commit f8f4d54

Please sign in to comment.