Add jekyll_install.sh

This commit is contained in:
RomanNum3ral 2026-04-27 23:09:55 +00:00
commit 61795a4eeb
1 changed files with 66 additions and 0 deletions

66
jekyll_install.sh Normal file
View File

@ -0,0 +1,66 @@
#!/usr/bin/env bash
set -e
echo "[+] Installing system dependencies..."
sudo pacman -Sy --noconfirm ruby base-devel
echo "[+] Setting up Ruby user gem path..."
GEM_PATH=$(ruby -e 'puts Gem.user_dir')
BIN_PATH="$GEM_PATH/bin"
# add to PATH if not already there
if ! grep -q "$BIN_PATH" ~/.bashrc; then
echo "export PATH=\"$BIN_PATH:\$PATH\"" >> ~/.bashrc
echo "[+] Added gem bin path to ~/.bashrc"
fi
export PATH="$BIN_PATH:$PATH"
echo "[+] Installing Jekyll + dependencies..."
gem install --user-install bundler jekyll webrick
echo "[+] Creating Jekyll site..."
SITE_DIR="$HOME/jekyll-site"
mkdir -p "$SITE_DIR"
cd "$SITE_DIR"
jekyll new . --force
echo "[+] Adding webrick to Gemfile..."
if ! grep -q "webrick" Gemfile; then
echo 'gem "webrick"' >> Gemfile
fi
echo "[+] Installing bundle..."
bundle install
echo "[+] Testing Jekyll..."
bundle exec jekyll build
echo "[+] Creating systemd service..."
SERVICE_FILE="/etc/systemd/system/jekyll.service"
sudo bash -c "cat > $SERVICE_FILE" <<EOF
[Unit]
Description=Jekyll Site
After=network.target
[Service]
User=$USER
WorkingDirectory=$SITE_DIR
ExecStart=$BIN_PATH/bundle exec jekyll serve --host 0.0.0.0 --port 4000
Restart=always
[Install]
WantedBy=multi-user.target
EOF
echo "[+] Enabling service..."
sudo systemctl daemon-reload
sudo systemctl enable --now jekyll
echo "[+] Done!"
echo "Access your site at: http://$(hostname -I | awk '{print $1}'):4000"
echo "Check logs with: journalctl -u jekyll -f"