Skip to content

Commit 2d4ccb4

Browse files
LTSCommerceclaude
andcommitted
Fix fedora-desktop article hallucinations and add real code snippets
- Replace fake code snippets with actual code from the repository - Add proper links to source files on F42 branch - Remove fictional playbooks and use real repository structure - Link directly to play-github-cli-multi.yml and other actual files - Update repository structure documentation to match reality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c617518 commit 2d4ccb4

6 files changed

Lines changed: 76 additions & 749 deletions

File tree

Lines changed: 19 additions & 236 deletions
Original file line numberDiff line numberDiff line change
@@ -1,236 +1,19 @@
1-
#!/bin/bash
2-
# Fedora Desktop Automation Bootstrap Script
3-
# Based on LongTermSupport/fedora-desktop approach
4-
# Transforms fresh Fedora installation into configured development environment
5-
6-
set -euo pipefail # Exit on error, undefined vars, pipe failures
7-
8-
# Configuration variables
9-
readonly SCRIPT_NAME="$(basename "$0")"
10-
readonly PROJECTS_DIR="$HOME/Projects"
11-
readonly FEDORA_DESKTOP_REPO="https://github.com/LongTermSupport/fedora-desktop.git"
12-
readonly MIN_FEDORA_VERSION=40
13-
14-
# Logging functions
15-
log_info() {
16-
echo "ℹ️ [INFO] $*" >&2
17-
}
18-
19-
log_success() {
20-
echo "✅ [SUCCESS] $*" >&2
21-
}
22-
23-
log_warning() {
24-
echo "⚠️ [WARNING] $*" >&2
25-
}
26-
27-
log_error() {
28-
echo "❌ [ERROR] $*" >&2
29-
}
30-
31-
log_step() {
32-
echo "🚀 [STEP] $*" >&2
33-
}
34-
35-
# Error handling
36-
cleanup() {
37-
local exit_code=$?
38-
if [[ $exit_code -ne 0 ]]; then
39-
log_error "Script failed with exit code: $exit_code"
40-
log_info "Check logs above for details"
41-
fi
42-
exit $exit_code
43-
}
44-
45-
trap cleanup EXIT
46-
47-
# Preflight checks
48-
check_prerequisites() {
49-
log_step "Running preflight checks..."
50-
51-
# Check if running as root
52-
if [[ $EUID -eq 0 ]]; then
53-
log_error "Do not run this script as root!"
54-
log_info "This script configures a user desktop environment"
55-
exit 1
56-
fi
57-
58-
# Check Fedora distribution
59-
if ! grep -q "Fedora" /etc/os-release; then
60-
log_error "This script requires Fedora Linux"
61-
exit 1
62-
fi
63-
64-
# Check Fedora version
65-
local fedora_version
66-
fedora_version=$(grep -oP 'VERSION_ID=\K\d+' /etc/os-release)
67-
if [[ $fedora_version -lt $MIN_FEDORA_VERSION ]]; then
68-
log_error "Fedora $MIN_FEDORA_VERSION or higher required (found: $fedora_version)"
69-
exit 1
70-
fi
71-
72-
log_success "Preflight checks passed (Fedora $fedora_version)"
73-
}
74-
75-
# System package installation
76-
install_system_packages() {
77-
log_step "Installing system packages..."
78-
79-
local packages=(
80-
git
81-
python3
82-
python3-pip
83-
ansible
84-
curl
85-
wget
86-
jq
87-
openssl
88-
dnf-plugins-core
89-
)
90-
91-
log_info "Updating system packages..."
92-
sudo dnf update -y --refresh
93-
94-
log_info "Installing required packages: ${packages[*]}"
95-
sudo dnf install -y "${packages[@]}"
96-
97-
# Enable RPM Fusion repositories for multimedia
98-
log_info "Enabling RPM Fusion repositories..."
99-
sudo dnf install -y \
100-
"https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" \
101-
"https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" || true
102-
103-
log_success "System packages installed"
104-
}
105-
106-
# GitHub CLI installation
107-
install_github_cli() {
108-
log_step "Installing GitHub CLI..."
109-
110-
if command -v gh >/dev/null 2>&1; then
111-
log_info "GitHub CLI already installed: $(gh --version | head -n1)"
112-
return
113-
fi
114-
115-
# Add GitHub CLI repository
116-
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
117-
sudo dnf install -y gh
118-
119-
log_success "GitHub CLI installed: $(gh --version | head -n1)"
120-
}
121-
122-
# SSH key setup
123-
setup_ssh_keys() {
124-
log_step "Setting up SSH keys..."
125-
126-
local ssh_dir="$HOME/.ssh"
127-
local ssh_key="$ssh_dir/id_ed25519"
128-
129-
# Create SSH directory
130-
[[ ! -d "$ssh_dir" ]] && mkdir -p "$ssh_dir" && chmod 700 "$ssh_dir"
131-
132-
# Generate SSH key if it doesn't exist
133-
if [[ ! -f "$ssh_key" ]]; then
134-
log_info "Generating new SSH key..."
135-
read -p "Enter your email address for SSH key: " email
136-
ssh-keygen -t ed25519 -C "$email" -f "$ssh_key" -N ""
137-
chmod 600 "$ssh_key"
138-
log_success "SSH key generated: $ssh_key"
139-
else
140-
log_info "SSH key already exists: $ssh_key"
141-
fi
142-
143-
# Start SSH agent and add key
144-
if ! pgrep -x ssh-agent >/dev/null; then
145-
eval "$(ssh-agent -s)"
146-
fi
147-
ssh-add "$ssh_key" 2>/dev/null || true
148-
149-
# Display public key for user
150-
echo
151-
log_info "🔑 Your SSH public key (add this to GitHub):"
152-
echo "$(cat "${ssh_key}.pub")"
153-
echo
154-
}
155-
156-
# Project directory setup
157-
setup_project_structure() {
158-
log_step "Setting up project directory structure..."
159-
160-
local dirs=(
161-
"$PROJECTS_DIR"
162-
"$PROJECTS_DIR/personal"
163-
"$PROJECTS_DIR/work"
164-
"$PROJECTS_DIR/opensource"
165-
"$PROJECTS_DIR/automation"
166-
)
167-
168-
for dir in "${dirs[@]}"; do
169-
[[ ! -d "$dir" ]] && mkdir -p "$dir"
170-
log_info "Created directory: $dir"
171-
done
172-
173-
log_success "Project structure created"
174-
}
175-
176-
# Clone fedora-desktop repository
177-
clone_automation_repo() {
178-
log_step "Cloning fedora-desktop automation repository..."
179-
180-
local repo_dir="$PROJECTS_DIR/automation/fedora-desktop"
181-
182-
if [[ -d "$repo_dir" ]]; then
183-
log_info "Repository already exists, updating..."
184-
cd "$repo_dir"
185-
git pull origin main
186-
else
187-
log_info "Cloning repository..."
188-
git clone "$FEDORA_DESKTOP_REPO" "$repo_dir"
189-
cd "$repo_dir"
190-
fi
191-
192-
log_success "Repository ready: $repo_dir"
193-
}
194-
195-
# Run Ansible playbook
196-
run_ansible_automation() {
197-
log_step "Running Ansible automation..."
198-
199-
cd "$PROJECTS_DIR/automation/fedora-desktop"
200-
201-
# Install Ansible requirements if they exist
202-
[[ -f "requirements.yml" ]] && ansible-galaxy install -r requirements.yml
203-
204-
# Run the main playbook
205-
log_info "Executing main Ansible playbook..."
206-
ansible-playbook -i "localhost," -c local playbooks/playbook-main.yml --ask-become-pass
207-
208-
log_success "Ansible automation completed"
209-
}
210-
211-
# Main execution
212-
main() {
213-
log_info "🐧 Fedora Desktop Automation Bootstrap"
214-
log_info "======================================"
215-
216-
check_prerequisites
217-
install_system_packages
218-
install_github_cli
219-
setup_ssh_keys
220-
setup_project_structure
221-
clone_automation_repo
222-
run_ansible_automation
223-
224-
echo
225-
log_success "🎉 Fedora desktop automation completed!"
226-
log_info "Next steps:"
227-
echo " 1. Add your SSH key to GitHub: https://github.com/settings/keys"
228-
echo " 2. Authenticate GitHub CLI: gh auth login"
229-
echo " 3. Run optional playbooks as needed"
230-
echo " 4. Customize your environment in: $PROJECTS_DIR/automation/fedora-desktop"
231-
}
232-
233-
# Script execution
234-
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
235-
main "$@"
236-
fi
1+
# Bootstrap script from run.bash - Error handling and safety checks
2+
set -e
3+
set -u
4+
set -o pipefail
5+
6+
## Assertions
7+
if [[ "$(whoami)" == "root" ]];
8+
then
9+
echo -e "\n${RED}${BOLD}${CROSS} ERROR${NC}"
10+
echo -e "${RED}Please do not run this as root${NC}\n"
11+
echo -e "Simply run as your normal user\n"
12+
exit 1
13+
fi
14+
15+
# Header
16+
clear
17+
echo -e "${BLUE}${BOLD}╔══════════════════════════════════════════════════════════════╗${NC}"
18+
echo -e "${BLUE}${BOLD}║ FEDORA DESKTOP CONFIGURATION INSTALLER ║${NC}"
19+
echo -e "${BLUE}${BOLD}╚══════════════════════════════════════════════════════════════╝${NC}\n"

code-snippets/fedora-desktop-automation-ansible/development-tools.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)