Files
fizzy/bin/setup
T
Jeffrey Hardy d17326ecd9 Use bash for bin/setup
That the ruby version is mostly shelling out is a hint that a shell language
might be a better choice. It's more direct, slightly faster, it sidesteps
chicken/egg problems when installing ruby, and writing things in bash is fun.

It's good to have an excuse to flex those shell muscles 💪
2024-08-13 13:03:35 -04:00

35 lines
691 B
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail
app_root="$( cd "$(dirname "$0")/.."; pwd )"
app_name="splat"
# Use application binstubs
export PATH="$app_root/bin:$PATH"
announce() {
echo
echo "--- $@"
}
announce "Installing dependencies"
gem install bundler --conservative
bundle check || bundle install
announce "Preparing database"
rails db:prepare
announce "Removing old logs and tempfiles"
rails log:clear tmp:clear
announce "Restarting services"
rails restart
if [ -d "$HOME/.puma-dev" ]; then
announce "Configuring puma-dev"
ln -nfs "$app_root" "$HOME/.puma-dev/$app_name"
announce "Checking https://$app_name.test/up: "
curl -Is "https://$app_name.test/up" | head -n 1
fi