-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchaotic.sh
More file actions
153 lines (132 loc) · 5.8 KB
/
Copy pathchaotic.sh
File metadata and controls
153 lines (132 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# -----------------------------------------------------------------------------
# Script: deploy_repos.sh
# Description: Configures essential Arch Linux repositories (multilib, chaotic-aur, xerolinux)
# and installs the 'paru' AUR helper using secure, bulletproof Bash methodology.
# -----------------------------------------------------------------------------
# --- Strict Mode and Safety Checks ---
set -euo pipefail
LOG_FILE="/var/log/deploy_repos.log"
CHAOTIC_KEYRING_URL="https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst"
CHAOTIC_MIRRORLIST_URL="https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst"
TEMP_DIR=$(mktemp -d)
# Logging function
log() {
local level="$1"
local message="$2"
echo "[$level] $message" | tee -a "$LOG_FILE"
}
cleanup() {
log "INFO" "Cleaning up temporary directory: $TEMP_DIR"
rm -rf "$TEMP_DIR"
<<<<<<< Updated upstream
# Note: $? holds the exit status of the script's main execution *before* the trap runs,
# but since `set -e` is active, the script might exit from a command failure,
# so we'll just log that cleanup is running.
log "INFO" "Script finished execution."
=======
log "INFO" "Script finished execution with status $?."
>>>>>>> Stashed changes
}
# Trap exit signal to ensure cleanup runs on success or failure
trap cleanup EXIT
# Check for root permissions
check_root() {
if [[ $(id -u) -ne 0 ]]; then
log "ERROR" "This script must be run as root (EUID=0)."
exit 1
fi
log "INFO" "Root check passed."
}
# --- Configuration Functions ---
enable_multilib() {
log "INFO" "1. Enabling [multilib] repository..."
<<<<<<< Updated upstream
# Use sed to safely uncomment the multilib section and its Include line.
=======
# Use sed to safely uncomment the multilib section and its Include line.[2, 3]
>>>>>>> Stashed changes
# Check if the [multilib] header is currently commented out
if grep -q '^#\[multilib\]' /etc/pacman.conf; then
sed -i '/\[multilib\]/{
s/^#//;
n;
s/^#Include/Include/
}' /etc/pacman.conf
log "INFO" "Successfully enabled multilib in /etc/pacman.conf."
else
log "WARNING" "[multilib] appears to be already enabled. Skipping modification."
fi
}
install_chaotic_aur() {
log "INFO" "2. Installing Chaotic-AUR keyring and repository definition."
<<<<<<< Updated upstream
# Install the keyring and mirrorlist packages directly via pacman -U, bypassing keyservers.
=======
# Install the keyring and mirrorlist packages directly via pacman -U, bypassing keyservers.[10, 12]
>>>>>>> Stashed changes
log "INFO" "Downloading keyring and mirrorlist packages..."
curl -sL -o "$TEMP_DIR/chaotic-keyring.pkg.tar.zst" "$CHAOTIC_KEYRING_URL"
curl -sL -o "$TEMP_DIR/chaotic-mirrorlist.pkg.tar.zst" "$CHAOTIC_MIRRORLIST_URL"
log "INFO" "Installing packages via pacman -U to establish trust..."
pacman -U --noconfirm "$TEMP_DIR/chaotic-keyring.pkg.tar.zst" "$TEMP_DIR/chaotic-mirrorlist.pkg.tar.zst"
<<<<<<< Updated upstream
# Append the repository block to the end, ensuring lowest precedence.
# FIXED: Added space between 'if' and '!'
if ! grep -q '\[chaotic-aur\]' /etc/pacman.conf; then
=======
# Append the repository block to the end, ensuring lowest precedence.[8, 11]
if! grep -q '\[chaotic-aur\]' /etc/pacman.conf; then
>>>>>>> Stashed changes
log "INFO" "Appending [chaotic-aur] definition to pacman.conf."
echo -e "\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist" | tee -a /etc/pacman.conf > /dev/null
else
log "WARNING" "[chaotic-aur] definition already present. Skipping append."
fi
}
install_xerolinux() {
log "INFO" "3. Configuring Xerolinux repository with explicit SigLevel."
# Setting SigLevel = Optional TrustAll bypasses the need for GPG key import by the administrator.
# Note: The use of TrustAll reduces security and is generally discouraged for unknown repositories.
XEROLINUX_REPO_BLOCK="\n[xerolinux]\nSigLevel = Optional TrustAll\nServer = https://repos.xerolinux.xyz/\$repo/\$arch"
<<<<<<< Updated upstream
# FIXED: Added space between 'if' and '!'
if ! grep -q '\[xerolinux\]' /etc/pacman.conf; then
log "INFO" "Appending [xerolinux] definition to pacman.conf."
echo -e "$XEROLINUX_REPO_BLOCK" | tee -a /etc/pacman.conf > /dev/null
=======
if! grep -q '\[xerolinux\]' /etc/pacman.conf; then
log "INFO" "Appending [xerolinux] definition to pacman.conf."
echo -e "$XEROLININUX_REPO_BLOCK" | tee -a /etc/pacman.conf > /dev/null [13]
>>>>>>> Stashed changes
else
log "WARNING" "[xerolinux] definition already present. Skipping append."
fi
}
sync_databases() {
log "INFO" "4. Synchronizing package databases and performing initial system upgrade (pacman -Syyu)."
# Synchronization ensures all databases are refreshed and the newly installed Chaotic-AUR keys are trusted.
pacman -Syyu --noconfirm
}
install_aur_helper() {
log "INFO" "5. Installing Paru AUR helper."
<<<<<<< Updated upstream
# Leveraging the pre-built binary package available in Chaotic-AUR for speed.
=======
# Leveraging the pre-built binary package available in Chaotic-AUR for speed.[17]
>>>>>>> Stashed changes
log "INFO" "Installing paru directly using pacman."
pacman -S --noconfirm paru
log "INFO" "Paru installed successfully. AUR is now accessible."
}
# --- Execution Flow ---
check_root
log "INFO" "Starting Arch Linux repository configuration and AUR helper deployment."
enable_multilib
install_chaotic_aur
install_xerolinux
sync_databases
install_aur_helper
log "SUCCESS" "All required repositories and the 'paru' AUR helper have been deployed."
log "SUCCESS" "Administrator verification required for external binary repository integrity."
exit 0