fix the fail2ban issues and other things
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# configure reads TITLE and DESCRIPTION
|
||||
# shellcheck disable=SC2034
|
||||
TITLE="Languages"
|
||||
# shellcheck disable=SC2034
|
||||
DESCRIPTION="Install more languages with mise, e.g. Ruby on Rails"
|
||||
|
||||
# Records that you've chosen, even if you chose nothing, so this isn't "to do"
|
||||
LANGUAGES_CONF="$HOME/.config/coredesktop/languages"
|
||||
|
||||
# mise installs these gems into each Ruby it installs, so Rails is still there
|
||||
# after update moves to a new Ruby
|
||||
DEFAULT_GEMS="$HOME/.default-gems"
|
||||
|
||||
is_installed() {
|
||||
command -v mise > /dev/null
|
||||
}
|
||||
|
||||
is_configured() {
|
||||
[ -f "$LANGUAGES_CONF" ]
|
||||
}
|
||||
|
||||
# Add a gem to ~/.default-gems unless it's there
|
||||
add_default_gem() {
|
||||
grep -qsx "$1" "$DEFAULT_GEMS" || echo "$1" >> "$DEFAULT_GEMS"
|
||||
}
|
||||
|
||||
install_rails() {
|
||||
echo "Installing Ruby and Rails..."
|
||||
add_default_gem bundler || return 1
|
||||
add_default_gem rails || return 1
|
||||
mise use -g ruby@latest || return 1
|
||||
# Ruby may already have been installed before ~/.default-gems listed these
|
||||
mise exec -- gem install --conservative bundler rails || return 1
|
||||
grep -qsx rails "$LANGUAGES_CONF" || echo rails >> "$LANGUAGES_CONF"
|
||||
}
|
||||
|
||||
run_configure() {
|
||||
local tools tool
|
||||
export MISE_YES=1
|
||||
# From home, so a project's mise.toml in the current directory doesn't count
|
||||
cd "$HOME" || return 1
|
||||
|
||||
echo "Go, Rust, Node.js, Python, Bun and Zig are already installed. mise installs other"
|
||||
echo "languages for you, and the version a project asks for in its mise.toml."
|
||||
mkdir -p "$(dirname "$LANGUAGES_CONF")"
|
||||
touch "$LANGUAGES_CONF" || return 1
|
||||
|
||||
if confirm "Install Ruby on Rails?"; then
|
||||
install_rails || return 1
|
||||
fi
|
||||
|
||||
echo "Anything else? Name tools mise knows (mise registry lists them), with a version,"
|
||||
read -rp "e.g. java@21 deno@latest, or press Enter for none: " tools
|
||||
for tool in $tools; do
|
||||
echo "Installing $tool..."
|
||||
mise use -g "$tool" || return 1
|
||||
done
|
||||
|
||||
echo "update keeps them up to date. To remove one later: mise unuse -g <tool>"
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# set -e
|
||||
|
||||
#====================================================================================
|
||||
# Install Mise
|
||||
#====================================================================================
|
||||
|
||||
# Check if Mise is already installed
|
||||
if ! command -v mise &> /dev/null; then
|
||||
echo "Installing Mises"
|
||||
curl https://mise.run/bash | sh
|
||||
else
|
||||
echo "Mises is installed"
|
||||
fi
|
||||
|
||||
eval "$($HOME/.local/bin/mise activate bash)"
|
||||
|
||||
source ~/.bashrc
|
||||
|
||||
#====================================================================================
|
||||
# Install Ruby
|
||||
#====================================================================================
|
||||
|
||||
# Check if Ruby is already installed
|
||||
if ! command -v ruby &> /dev/null; then
|
||||
echo "Installing Ruby"
|
||||
mise install ruby@latest
|
||||
mise use -g ruby@latest
|
||||
|
||||
# Explicitly add shims to PATH
|
||||
export PATH="$HOME/.local/share/mise/shims:$PATH"
|
||||
|
||||
# Force reshim
|
||||
$HOME/.local/bin/mise reshim
|
||||
|
||||
source "$HOME/.bashrc"
|
||||
|
||||
gem install bundler
|
||||
else
|
||||
echo "Ruby is installed"
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Install Rails
|
||||
#====================================================================================
|
||||
|
||||
# Check if Rails is already installed
|
||||
if ! command -v rails &> /dev/null; then
|
||||
echo "Installing Rails"
|
||||
gem install rails
|
||||
else
|
||||
echo "Rails is installed"
|
||||
fi
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# mise now comes from pacman, and shell/bashrc activates it, so remove the copy
|
||||
# mise.run installed in ~/.local/bin and the line it added to ~/.bashrc. Ruby and
|
||||
# Rails are no longer installed for everyone, only with configure languages:
|
||||
# machines that have them keep them, and update keeps Rails on new Rubies.
|
||||
LANGUAGES_CONF="$HOME/.config/coredesktop/languages"
|
||||
DEFAULT_GEMS="$HOME/.default-gems"
|
||||
|
||||
# 10-pacman.sh installs mise from packages.conf before migrations run
|
||||
[ -x /usr/bin/mise ] || { echo "mise isn't installed from pacman yet."; exit 1; }
|
||||
|
||||
if [ -f ~/.bashrc ] && grep -qE '\.local/bin/mise activate' ~/.bashrc; then
|
||||
tmp="$(mktemp ~/.bashrc.XXXXXX)" || exit 1
|
||||
# grep -v exits 1 when that line was all there was, which is fine
|
||||
grep -vE '\.local/bin/mise activate' ~/.bashrc > "$tmp"
|
||||
(( $? <= 1 )) && cat "$tmp" > ~/.bashrc
|
||||
status=$?
|
||||
rm -f "$tmp"
|
||||
[ $status -eq 0 ] || exit 1
|
||||
fi
|
||||
rm -f ~/.local/bin/mise
|
||||
|
||||
# Ruby that CoreDesktop installed: count it as chosen with configure languages.
|
||||
# From home, so a project's mise.toml in the current directory doesn't count.
|
||||
cd "$HOME" || exit 1
|
||||
if /usr/bin/mise ls --global --quiet 2> /dev/null | grep -q '^ruby '; then
|
||||
mkdir -p "$(dirname "$LANGUAGES_CONF")" || exit 1
|
||||
grep -qsx rails "$LANGUAGES_CONF" || echo rails >> "$LANGUAGES_CONF"
|
||||
for gem in bundler rails; do
|
||||
grep -qsx "$gem" "$DEFAULT_GEMS" || echo "$gem" >> "$DEFAULT_GEMS"
|
||||
done
|
||||
# update used to move to a new Ruby without Rails
|
||||
echo "Making sure Rails is installed..."
|
||||
MISE_YES=1 /usr/bin/mise exec -- gem install --conservative bundler rails || exit 1
|
||||
fi
|
||||
exit 0
|
||||
Reference in New Issue
Block a user