2024-10-19 19:49:35 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-10-19 21:33:25 +02:00
|
|
|
# TANGERINE UI
|
|
|
|
# Install/Update script
|
|
|
|
# ---------------------
|
|
|
|
#
|
|
|
|
# This script pulls the latest changes from the Tangerine UI repository,
|
|
|
|
# copies the CSS files to the Mastodon installation directory, and adds Tangerine UI to Mastodon's themes.yml.
|
|
|
|
# It can also be used to update Tangerine UI on your Mastodon instance.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# • Set the TANGERINEUI and MASTODON paths below before running the script for the first time.
|
|
|
|
# • Only run this script as the mastodon user.
|
|
|
|
# • Use --skip-confirm to bypass all confirmation steps.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# /!\ This script is not suitable for Glitch-soc instances.
|
|
|
|
|
2024-10-19 19:49:35 +02:00
|
|
|
TANGERINEUI="/home/mastodon/TangerineUI"
|
|
|
|
MASTODON="/home/mastodon/live"
|
|
|
|
|
2024-10-19 22:36:52 +02:00
|
|
|
set -e
|
|
|
|
|
2024-10-19 20:26:08 +02:00
|
|
|
# Confirm paths
|
|
|
|
confirm_path() {
|
|
|
|
local path="$1"
|
|
|
|
local prompt_message="$2"
|
|
|
|
|
|
|
|
echo "$prompt_message: $path"
|
2024-10-19 20:29:36 +02:00
|
|
|
read -p "Is this path correct? (Y/n): " response
|
|
|
|
response=${response:-y}
|
2024-10-19 20:26:08 +02:00
|
|
|
case "$response" in
|
|
|
|
[Yy]* ) echo "Path confirmed.";;
|
|
|
|
[Nn]* ) echo "Please update the path in the script."; exit 1;;
|
2024-10-19 21:33:25 +02:00
|
|
|
* ) echo "Invalid response. Exiting." >&2; exit 1;;
|
2024-10-19 20:26:08 +02:00
|
|
|
esac
|
|
|
|
}
|
2024-10-19 21:33:25 +02:00
|
|
|
|
|
|
|
# Check for command-line arguments
|
|
|
|
SKIP_CONFIRM=false
|
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
|
|
case $1 in
|
|
|
|
--skip-confirm) SKIP_CONFIRM=true ;;
|
|
|
|
*) echo "Unknown parameter passed: $1" >&2; exit 1 ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# Confirm the paths with the user unless --skip-confirm is provided
|
|
|
|
if [ "$SKIP_CONFIRM" = false ]; then
|
|
|
|
confirm_path "$TANGERINEUI" "Tangerine UI repository directory"
|
|
|
|
confirm_path "$MASTODON" "Mastodon directory"
|
|
|
|
else
|
|
|
|
echo "Skipping path confirmation."
|
|
|
|
fi
|
2024-10-19 20:26:08 +02:00
|
|
|
|
2024-10-19 19:49:35 +02:00
|
|
|
# Navigate to the repository
|
2024-10-19 21:33:25 +02:00
|
|
|
cd "$TANGERINEUI" || { echo "Tangerine UI repository directory not found: $TANGERINEUI" >&2; exit 1; }
|
2024-10-19 19:49:35 +02:00
|
|
|
|
|
|
|
# Pull the latest changes from the repository
|
2024-10-19 21:33:25 +02:00
|
|
|
git pull || { echo "Failed to pull latest changes from the Tangerine UI repository" >&2; exit 1; }
|
2024-10-19 19:49:35 +02:00
|
|
|
|
2024-10-19 21:33:25 +02:00
|
|
|
# Copy files from the Tangerine UI repository to the Mastodon directory
|
2024-10-19 19:49:35 +02:00
|
|
|
cp -r "./mastodon/app/javascript/styles/"* "$MASTODON/app/javascript/styles"
|
|
|
|
|
2024-10-19 19:58:08 +02:00
|
|
|
# Add Tangerine UI to themes.yml if not already present
|
|
|
|
THEME_FILE="$MASTODON/config/themes.yml"
|
|
|
|
THEME_LINES=(
|
|
|
|
"tangerineui: styles/tangerineui.scss"
|
|
|
|
"tangerineui-purple: styles/tangerineui-purple.scss"
|
|
|
|
"tangerineui-cherry: styles/tangerineui-cherry.scss"
|
|
|
|
"tangerineui-lagoon: styles/tangerineui-lagoon.scss"
|
|
|
|
)
|
|
|
|
|
2024-10-19 21:33:25 +02:00
|
|
|
# Check if the themes are already present and add missing ones
|
|
|
|
if [ -f "$THEME_FILE" ]; then
|
|
|
|
for line in "${THEME_LINES[@]}"; do
|
|
|
|
if ! grep -Fxq "$line" "$THEME_FILE"; then
|
|
|
|
echo "$line" >> "$THEME_FILE"
|
2024-10-19 21:37:55 +02:00
|
|
|
echo "Added to themes.yml: $line"
|
2024-10-19 21:33:25 +02:00
|
|
|
else
|
2024-10-19 21:37:55 +02:00
|
|
|
echo "Already present in themes.yml: $line"
|
2024-10-19 21:33:25 +02:00
|
|
|
fi
|
|
|
|
done
|
2024-10-19 19:58:08 +02:00
|
|
|
else
|
2024-10-19 21:33:25 +02:00
|
|
|
echo "themes.yml not found: $THEME_FILE" >&2
|
|
|
|
exit 1
|
2024-10-19 19:58:08 +02:00
|
|
|
fi
|
2024-10-19 19:49:35 +02:00
|
|
|
|
|
|
|
# Navigate to the Mastodon directory
|
2024-10-19 21:33:25 +02:00
|
|
|
cd "$MASTODON"
|
2024-10-19 19:49:35 +02:00
|
|
|
|
|
|
|
# Precompile assets in production mode
|
|
|
|
RAILS_ENV=production bundle exec rails assets:precompile
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Tangerine UI was successfully installed."
|
|
|
|
echo "Restart all Mastodon services for the changes to take effect."
|