Make Samba and rclone backup system optional

- Add interactive prompt before Samba installation
- Add interactive prompt before rclone backup system setup
- Update summary section to conditionally display installed components
- Fix indentation in backup script section
This commit is contained in:
Claude
2025-12-28 00:18:18 +00:00
parent 893d13af53
commit 0a88f8ae1f
+94 -54
View File
@@ -243,16 +243,27 @@ echo "Verifying Docker installation..."
docker --version || echo "Warning: Docker verification failed"
docker compose version || echo "Warning: Docker Compose verification failed"
# Install and Configure Samba
# Samba File Sharing (Optional)
echo ""
echo "Installing Samba file sharing..."
echo " - Samba: SMB/CIFS file server for network file sharing"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "SAMBA FILE SHARING (Optional)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Samba allows you to share folders over the network to Windows, Mac, and Linux."
echo "The script will share your primary drive at ~/drives/primary"
echo ""
read -p "Install and configure Samba file sharing? (y/n): " INSTALL_SAMBA
apt install -y samba || echo "Warning: Samba installation failed, continuing..."
if [ "$INSTALL_SAMBA" = "y" ] || [ "$INSTALL_SAMBA" = "Y" ]; then
echo ""
echo "Installing Samba file sharing..."
echo " - Samba: SMB/CIFS file server for network file sharing"
echo ""
# Configure Samba share for primary drive
if command -v smbd &> /dev/null; then
apt install -y samba || echo "Warning: Samba installation failed, continuing..."
# Configure Samba share for primary drive
if command -v smbd &> /dev/null; then
echo ""
echo "Configuring Samba share for primary drive..."
@@ -299,8 +310,11 @@ SAMBA_CONFIG
echo " Share name: Primary"
echo " Path: $ACTUAL_HOME/drives/primary"
echo " Access: \\\\$(hostname)\\Primary (Windows) or smb://$(hostname)/Primary (Mac/Linux)"
else
else
echo "✗ Samba installation failed, skipping configuration"
fi
else
echo "Skipping Samba installation."
fi
# Install NetBird
@@ -341,35 +355,50 @@ if [ -f /tmp/rustdesk.deb ]; then
rm /tmp/rustdesk.deb
fi
# Create rclone backup script and instructions
echo ""
echo "Setting up rclone backup configuration..."
echo ""
# Create backup script directory
mkdir -p /usr/local/bin/backup-scripts
# Create mount point directories
echo ""
echo "Creating mount point directories in $ACTUAL_HOME/drives/..."
mkdir -p "$ACTUAL_HOME/drives/primary"
mkdir -p "$ACTUAL_HOME/drives/backup1"
mkdir -p "$ACTUAL_HOME/drives/backup2"
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$ACTUAL_HOME/drives"
# Rclone Split Backup System (Optional)
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "DRIVE SETUP - Mount your drives"
echo "RCLONE SPLIT BACKUP SYSTEM (Optional)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Available block devices:"
echo "This sets up a split backup system using rclone:"
echo " - Creates mount points for primary + 2 backup drives"
echo " - Installs backup script that splits data across backup drives"
echo " - Optionally configures automatic daily backups"
echo ""
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,LABEL
echo "Useful when: Primary drive (e.g., 4TB) > individual backup drives (e.g., 2TB each)"
echo ""
read -p "Set up rclone split backup system? (y/n): " SETUP_BACKUP
read -p "Do you want to mount drives now? (y/n): " MOUNT_NOW
if [ "$SETUP_BACKUP" = "y" ] || [ "$SETUP_BACKUP" = "Y" ]; then
echo ""
echo "Setting up rclone backup configuration..."
echo ""
if [ "$MOUNT_NOW" = "y" ] || [ "$MOUNT_NOW" = "Y" ]; then
# Create backup script directory
mkdir -p /usr/local/bin/backup-scripts
# Create mount point directories
echo ""
echo "Creating mount point directories in $ACTUAL_HOME/drives/..."
mkdir -p "$ACTUAL_HOME/drives/primary"
mkdir -p "$ACTUAL_HOME/drives/backup1"
mkdir -p "$ACTUAL_HOME/drives/backup2"
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$ACTUAL_HOME/drives"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "DRIVE SETUP - Mount your drives"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Available block devices:"
echo ""
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,LABEL
echo ""
read -p "Do you want to mount drives now? (y/n): " MOUNT_NOW
if [ "$MOUNT_NOW" = "y" ] || [ "$MOUNT_NOW" = "Y" ]; then
echo ""
echo "Enter device paths (e.g., /dev/sdb1) or leave blank to skip"
echo ""
@@ -434,17 +463,17 @@ if [ "$MOUNT_NOW" = "y" ] || [ "$MOUNT_NOW" = "Y" ]; then
echo "✓ Backup of original fstab saved with timestamp"
fi
else
else
echo ""
echo "Skipping drive mounting. You can mount manually later."
echo "Mount points created at:"
echo " $ACTUAL_HOME/drives/primary"
echo " $ACTUAL_HOME/drives/backup1"
echo " $ACTUAL_HOME/drives/backup2"
fi
fi
# Create example backup script with correct paths
cat > /usr/local/bin/backup-scripts/rclone-backup.sh << BACKUP_SCRIPT
# Create example backup script with correct paths
cat > /usr/local/bin/backup-scripts/rclone-backup.sh << BACKUP_SCRIPT
#!/bin/bash
################################################################################
@@ -596,10 +625,10 @@ backup_to_drive "\$BACKUP2" "Backup Drive 2" "\${BACKUP2_DIRS[@]}"
echo "=== Backup Completed: \$(date) ===" | tee -a "\$LOG"
BACKUP_SCRIPT
chmod +x /usr/local/bin/backup-scripts/rclone-backup.sh
chmod +x /usr/local/bin/backup-scripts/rclone-backup.sh
# Create systemd service for automatic backups (optional)
cat > /etc/systemd/system/rclone-backup.service << 'SERVICE'
# Create systemd service for automatic backups (optional)
cat > /etc/systemd/system/rclone-backup.service << 'SERVICE'
[Unit]
Description=Rclone Backup Service
After=network.target
@@ -610,8 +639,8 @@ ExecStart=/usr/local/bin/backup-scripts/rclone-backup.sh
User=root
SERVICE
# Create systemd timer for daily backups at 2 AM (optional)
cat > /etc/systemd/system/rclone-backup.timer << 'TIMER'
# Create systemd timer for daily backups at 2 AM (optional)
cat > /etc/systemd/system/rclone-backup.timer << 'TIMER'
[Unit]
Description=Daily Rclone Backup Timer
Requires=rclone-backup.service
@@ -625,9 +654,11 @@ Persistent=true
WantedBy=timers.target
TIMER
echo "✓ Rclone backup script created at /usr/local/bin/backup-scripts/rclone-backup.sh"
echo "✓ Systemd service/timer created (disabled by default)"
echo "✓ Rclone backup script created at /usr/local/bin/backup-scripts/rclone-backup.sh"
echo "✓ Systemd service/timer created (disabled by default)"
else
echo "Skipping rclone backup system setup."
fi
# Full system upgrade
echo ""
@@ -644,13 +675,17 @@ echo ""
echo "=== Installation Complete! ==="
echo ""
echo "Installed Software:"
echo " ✓ net-tools, ncdu, git, curl, wget, vim, htop, tree, zip/unzip"
echo " ✓ rclone - Backup/sync tool"
echo " ✓ net-tools, ncdu, git, curl, wget, vim, htop, tree, zip/unzip, rclone"
echo " ✓ OpenSSH Server - SSH remote access"
echo " ✓ Samba - File sharing (Primary drive shared)"
echo " ✓ Docker Engine + Docker Compose"
if [ "$INSTALL_SAMBA" = "y" ] || [ "$INSTALL_SAMBA" = "Y" ]; then
echo " ✓ Samba - File sharing (Primary drive shared)"
fi
echo " ✓ NetBird - Mesh VPN"
echo " ✓ RustDesk - Remote desktop"
if [ "$SETUP_BACKUP" = "y" ] || [ "$SETUP_BACKUP" = "Y" ]; then
echo " ✓ Rclone split backup system configured"
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "SSH AUTHENTICATION SETUP"
@@ -702,6 +737,7 @@ echo " ✓ Just GitHub or just Launchpad"
echo " ✓ Just NetBird SSH"
echo " ✓ None (password auth only - if no keys imported)"
echo ""
if [ "$SETUP_BACKUP" = "y" ] || [ "$SETUP_BACKUP" = "Y" ]; then
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "RCLONE BACKUP SETUP - Exact Drive Mirroring"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@@ -912,21 +948,25 @@ echo " rclone check $ACTUAL_HOME/drives/primary/documents \\"
echo " $ACTUAL_HOME/drives/backup1/documents \\"
echo " --checksum --one-way"
echo ""
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "OTHER IMPORTANT NOTES"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo " Samba File Sharing:"
if command -v smbd &> /dev/null && grep -q "\[Primary\]" /etc/samba/smb.conf 2>/dev/null; then
echo " ✓ Share 'Primary' is accessible at:"
echo " Windows: \\\\$(hostname)\\Primary"
echo " Mac/Linux: smb://$(hostname)/Primary"
echo " • Username: $ACTUAL_USER"
echo " • Use the Samba password you just set"
echo ""
else
echo " Not configured (Samba installation may have failed)"
echo ""
if [ "$INSTALL_SAMBA" = "y" ] || [ "$INSTALL_SAMBA" = "Y" ]; then
echo " Samba File Sharing:"
if command -v smbd &> /dev/null && grep -q "\[Primary\]" /etc/samba/smb.conf 2>/dev/null; then
echo " ✓ Share 'Primary' is accessible at:"
echo " Windows: \\\\$(hostname)\\Primary"
echo " Mac/Linux: smb://$(hostname)/Primary"
echo " • Username: $ACTUAL_USER"
echo " • Use the Samba password you just set"
echo ""
else
echo " ✗ Installation may have failed - check 'systemctl status smbd'"
echo ""
fi
fi
echo " Docker: Log out and back in for group membership to take effect"
echo ""