Refactor configuration and scripts for Archipelago backend and ISO build
- Updated Cargo.toml to remove unnecessary package backtrace optimizations. - Changed default bind host and port in config.rs for broader accessibility. - Renamed state_manager to _state_manager in server.rs for clarity. - Updated user field to _user in PodmanClient and DockerRuntime for consistency. - Modified build-debian-iso.sh to enhance welcome message and backend startup instructions. - Improved archipelago-menu.sh to display backend status and updated Web UI URL. - Enhanced install-to-disk.sh for better package management and user creation during installation.
This commit is contained in:
@@ -96,12 +96,24 @@ main_menu() {
|
||||
show_banner
|
||||
show_status
|
||||
|
||||
# Show Web UI URL
|
||||
# Show Web UI URL prominently
|
||||
IP=$(hostname -I 2>/dev/null | awk '{print $1}')
|
||||
[ -z "$IP" ] && IP=$(ip -4 addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '127.0.0.1' | head -1)
|
||||
|
||||
echo " ┌─────────────────────────────────────────────────────────────┐"
|
||||
if [ -n "$IP" ]; then
|
||||
echo " 🌐 Web UI: http://$IP"
|
||||
echo ""
|
||||
# Check if backend is running
|
||||
if pgrep -f "archipelago" >/dev/null 2>&1; then
|
||||
echo " │ 🌐 Web UI: http://$IP:5678 (running) │"
|
||||
else
|
||||
echo " │ 🌐 Web UI: http://$IP:5678 (not started) │"
|
||||
fi
|
||||
echo " │ 📡 SSH: ssh user@$IP (password: archipelago) │"
|
||||
else
|
||||
echo " │ 🌐 Web UI: (no network) │"
|
||||
fi
|
||||
echo " └─────────────────────────────────────────────────────────────┘"
|
||||
echo ""
|
||||
|
||||
echo " Main Menu:"
|
||||
echo " ─────────────────────────────────────────────────────────────"
|
||||
@@ -122,17 +134,34 @@ main_menu() {
|
||||
|
||||
case $choice in
|
||||
w|W)
|
||||
if [ -f "$SCRIPT_DIR/start-web-ui.sh" ]; then
|
||||
sudo bash "$SCRIPT_DIR/start-web-ui.sh" 80
|
||||
else
|
||||
# Try to find and start web UI
|
||||
for path in /opt/archipelago/scripts /run/live/medium/archipelago/scripts; do
|
||||
if [ -f "$path/start-web-ui.sh" ]; then
|
||||
sudo bash "$path/start-web-ui.sh" 80
|
||||
break
|
||||
echo ""
|
||||
# Start the real backend on port 5678
|
||||
if command -v archipelago >/dev/null 2>&1; then
|
||||
if pgrep -f "archipelago" >/dev/null 2>&1; then
|
||||
echo " ✅ Archipelago backend already running on port 5678"
|
||||
else
|
||||
echo " 🚀 Starting Archipelago backend on port 5678..."
|
||||
nohup archipelago >/tmp/archipelago.log 2>&1 &
|
||||
sleep 2
|
||||
if pgrep -f "archipelago" >/dev/null 2>&1; then
|
||||
echo " ✅ Backend started!"
|
||||
else
|
||||
echo " ⚠️ Failed to start backend. Check /tmp/archipelago.log"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
IP=$(hostname -I 2>/dev/null | awk '{print $1}')
|
||||
echo ""
|
||||
echo " ┌─────────────────────────────────────────────────────────────┐"
|
||||
echo " │ 🌐 Open in browser: http://$IP:5678 │"
|
||||
echo " └─────────────────────────────────────────────────────────────┘"
|
||||
else
|
||||
echo " ⚠️ Archipelago binary not found at /usr/local/bin/archipelago"
|
||||
echo ""
|
||||
echo " Try running:"
|
||||
echo " sudo cp /run/live/medium/archipelago/bin/archipelago /usr/local/bin/"
|
||||
fi
|
||||
echo ""
|
||||
read -p " Press Enter to continue..."
|
||||
;;
|
||||
1)
|
||||
if [ -f "$SCRIPT_DIR/install-to-disk.sh" ]; then
|
||||
|
||||
@@ -117,10 +117,13 @@ fi
|
||||
|
||||
echo "⚙️ Configuring system..."
|
||||
|
||||
# Mount virtual filesystems
|
||||
# Mount virtual filesystems for chroot
|
||||
mount --bind /dev /mnt/archipelago/dev
|
||||
mount --bind /dev/pts /mnt/archipelago/dev/pts
|
||||
mount --bind /proc /mnt/archipelago/proc
|
||||
mount --bind /sys /mnt/archipelago/sys
|
||||
mount --bind /sys/firmware/efi/efivars /mnt/archipelago/sys/firmware/efi/efivars 2>/dev/null || true
|
||||
mount --bind /run /mnt/archipelago/run
|
||||
|
||||
# Create fstab
|
||||
cat > /mnt/archipelago/etc/fstab <<EOF
|
||||
@@ -140,56 +143,64 @@ cat > /mnt/archipelago/etc/hosts <<EOF
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
EOF
|
||||
|
||||
# Install bootloader and essential packages
|
||||
chroot /mnt/archipelago /bin/bash <<'CHROOT_EOF'
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
# Install bootloader and essential packages in chroot
|
||||
echo "📦 Configuring package sources..."
|
||||
|
||||
# Add sources
|
||||
cat > /etc/apt/sources.list <<EOF
|
||||
# Create sources.list
|
||||
cat > /mnt/archipelago/etc/apt/sources.list <<EOF
|
||||
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
|
||||
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
|
||||
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
|
||||
EOF
|
||||
|
||||
apt-get update
|
||||
echo "📥 Updating package lists..."
|
||||
chroot /mnt/archipelago apt-get update
|
||||
|
||||
# Install kernel, bootloader, and essentials
|
||||
apt-get install -y \
|
||||
linux-image-amd64 \
|
||||
grub-efi-amd64 \
|
||||
echo "📦 Installing kernel and bootloader..."
|
||||
chroot /mnt/archipelago apt-get install -y linux-image-amd64 grub-efi-amd64 grub-efi-amd64-signed shim-signed
|
||||
|
||||
echo "📦 Installing essential packages..."
|
||||
chroot /mnt/archipelago apt-get install -y \
|
||||
sudo \
|
||||
networkmanager \
|
||||
openssh-server \
|
||||
curl \
|
||||
wget \
|
||||
htop \
|
||||
vim \
|
||||
git \
|
||||
podman \
|
||||
podman-compose \
|
||||
buildah \
|
||||
skopeo
|
||||
vim-tiny \
|
||||
ca-certificates
|
||||
|
||||
# Install GRUB
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=archipelago
|
||||
update-grub
|
||||
echo "📦 Installing container tools..."
|
||||
chroot /mnt/archipelago apt-get install -y podman || echo "⚠️ Podman not available in base repos, will use containers.io later"
|
||||
|
||||
# Create archipelago user
|
||||
useradd -m -s /bin/bash -G sudo,podman archipelago
|
||||
echo "archipelago:archipelago" | chpasswd
|
||||
echo "🔧 Installing GRUB bootloader..."
|
||||
# Need to run grub-install inside chroot with proper environment
|
||||
chroot /mnt/archipelago /bin/bash -c "
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=archipelago --recheck 2>&1 || \
|
||||
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=archipelago --removable 2>&1 || \
|
||||
echo '⚠️ GRUB install had issues, trying alternative...'
|
||||
"
|
||||
chroot /mnt/archipelago update-grub
|
||||
|
||||
# Enable services
|
||||
systemctl enable NetworkManager
|
||||
systemctl enable ssh
|
||||
systemctl enable podman
|
||||
echo "👤 Creating archipelago user..."
|
||||
# Create user first, then add to groups that exist
|
||||
chroot /mnt/archipelago useradd -m -s /bin/bash archipelago || echo "User may already exist"
|
||||
chroot /mnt/archipelago usermod -aG sudo archipelago || true
|
||||
chroot /mnt/archipelago usermod -aG podman archipelago 2>/dev/null || true
|
||||
|
||||
# Create Archipelago directories
|
||||
mkdir -p /var/lib/archipelago/{data,config,containers}
|
||||
mkdir -p /etc/archipelago
|
||||
chown -R archipelago:archipelago /var/lib/archipelago
|
||||
# Set password using chpasswd
|
||||
echo "archipelago:archipelago" | chroot /mnt/archipelago chpasswd
|
||||
|
||||
echo "✅ Base system installed"
|
||||
CHROOT_EOF
|
||||
echo "⚙️ Enabling services..."
|
||||
chroot /mnt/archipelago systemctl enable NetworkManager || true
|
||||
chroot /mnt/archipelago systemctl enable ssh || chroot /mnt/archipelago systemctl enable sshd || true
|
||||
|
||||
echo "📁 Creating Archipelago directories..."
|
||||
chroot /mnt/archipelago mkdir -p /var/lib/archipelago/{data,config,containers}
|
||||
chroot /mnt/archipelago mkdir -p /etc/archipelago
|
||||
chroot /mnt/archipelago chown -R archipelago:archipelago /var/lib/archipelago
|
||||
|
||||
echo "✅ Base system configured"
|
||||
|
||||
# Copy Archipelago files
|
||||
echo "📋 Installing Archipelago components..."
|
||||
@@ -228,7 +239,7 @@ if [ -n "$BOOT_MEDIA" ]; then
|
||||
cp -r "$BOOT_MEDIA/archipelago/apps" /mnt/archipelago/etc/archipelago/
|
||||
fi
|
||||
|
||||
# Create profile.d script for auto-menu on login
|
||||
# Create profile.d script for welcome message on login
|
||||
mkdir -p /mnt/archipelago/etc/profile.d
|
||||
cat > /mnt/archipelago/etc/profile.d/archipelago.sh <<'PROFILE_EOF'
|
||||
#!/bin/bash
|
||||
@@ -237,26 +248,60 @@ if [ -t 0 ] && [ -z "$ARCHIPELAGO_WELCOMED" ]; then
|
||||
export ARCHIPELAGO_WELCOMED=1
|
||||
IP=$(hostname -I 2>/dev/null | awk '{print $1}')
|
||||
echo ""
|
||||
echo " 🏝️ Welcome to Archipelago Bitcoin Node OS"
|
||||
echo " ╔═══════════════════════════════════════════════════════════╗"
|
||||
echo " ║ 🏝️ ARCHIPELAGO BITCOIN NODE OS ║"
|
||||
echo " ╚═══════════════════════════════════════════════════════════╝"
|
||||
echo ""
|
||||
if [ -n "$IP" ]; then
|
||||
echo " Web UI: http://$IP"
|
||||
echo " ┌─────────────────────────────────────────────────────────────┐"
|
||||
echo " │ 🌐 Web UI: http://$IP:5678 │"
|
||||
echo " │ 📡 SSH: ssh archipelago@$IP │"
|
||||
echo " └─────────────────────────────────────────────────────────────┘"
|
||||
echo ""
|
||||
fi
|
||||
echo " Menu: Type 'archipelago' to open setup menu"
|
||||
echo " Commands:"
|
||||
echo " archipelago - Start backend server"
|
||||
echo " archipelago-menu - Open setup menu"
|
||||
echo ""
|
||||
fi
|
||||
PROFILE_EOF
|
||||
chmod +x /mnt/archipelago/etc/profile.d/archipelago.sh
|
||||
|
||||
# Create systemd service to auto-start archipelago backend
|
||||
mkdir -p /mnt/archipelago/etc/systemd/system
|
||||
cat > /mnt/archipelago/etc/systemd/system/archipelago.service <<'SERVICE_EOF'
|
||||
[Unit]
|
||||
Description=Archipelago Backend Server
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=archipelago
|
||||
ExecStart=/usr/local/bin/archipelago
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
SERVICE_EOF
|
||||
|
||||
# Enable the service
|
||||
chroot /mnt/archipelago systemctl enable archipelago.service 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "🧹 Cleaning up..."
|
||||
|
||||
# Unmount
|
||||
umount /mnt/archipelago/dev
|
||||
umount /mnt/archipelago/proc
|
||||
umount /mnt/archipelago/sys
|
||||
umount /mnt/archipelago/boot/efi
|
||||
umount /mnt/archipelago
|
||||
# Unmount in reverse order
|
||||
sync
|
||||
umount /mnt/archipelago/run 2>/dev/null || true
|
||||
umount /mnt/archipelago/sys/firmware/efi/efivars 2>/dev/null || true
|
||||
umount /mnt/archipelago/sys 2>/dev/null || true
|
||||
umount /mnt/archipelago/proc 2>/dev/null || true
|
||||
umount /mnt/archipelago/dev/pts 2>/dev/null || true
|
||||
umount /mnt/archipelago/dev 2>/dev/null || true
|
||||
umount /mnt/archipelago/boot/efi 2>/dev/null || true
|
||||
umount /mnt/archipelago 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "╔═══════════════════════════════════════════════════════════╗"
|
||||
|
||||
Reference in New Issue
Block a user