fix: Correct services summary file path to user home directory

- Change summary file location from /root/nas_services.txt to ~/nas_services.txt
- Use SUDO_USER environment variable to determine correct user home directory
- Update README.md to reflect the correct path for the services summary file
- Ensure file is created in the home directory of the user who ran sudo
This commit is contained in:
Mărcziem ™
2025-10-03 13:10:54 +02:00
parent 0253b226a4
commit 5a0a2401ce
3 changed files with 181 additions and 21 deletions

View File

@@ -127,6 +127,14 @@ chmod +x tests/unit_tests.sh
./tests/unit_tests.sh ./tests/unit_tests.sh
``` ```
### 5. Check Installation Summary
```bash
# View the services summary file created during installation
cat ~/nas_services.txt
# This file contains all service URLs, ports, and access information
```
## ⚙️ Configuration ## ⚙️ Configuration
The script guides you through an interactive configuration: The script guides you through an interactive configuration:

View File

@@ -33,7 +33,19 @@ install_portainer() {
-v portainer_data:/data \ -v portainer_data:/data \
portainer/portainer-ce:latest portainer/portainer-ce:latest
# Warten bis Portainer vollständig gestartet ist
log_info "Warten auf Portainer-Initialisierung..."
sleep 10
# Portainer neu starten, um das initiale Security-Timeout zu umgehen
log_info "Portainer neu starten, um Security-Timeout zu beheben..."
sudo docker restart portainer
# Kurz warten, bis der Neustart abgeschlossen ist
sleep 5
log_success "Portainer wurde erfolgreich installiert und läuft auf Port 9000 (HTTP) und 9443 (HTTPS)." log_success "Portainer wurde erfolgreich installiert und läuft auf Port 9000 (HTTP) und 9443 (HTTPS)."
log_info "Portainer ist nun verfügbar unter: https://$(hostname -I | awk '{print $1}'):9443"
} }
# Logging-Funktionen bereitstellen, falls nicht vorhanden # Logging-Funktionen bereitstellen, falls nicht vorhanden

178
setup.sh
View File

@@ -466,6 +466,16 @@ run_installation() {
# Installation summary # Installation summary
show_installation_summary() { show_installation_summary() {
local ip_address
ip_address=$(hostname -I | awk '{print $1}')
local user_home
if [[ -n "${SUDO_USER:-}" ]]; then
user_home=$(eval echo "~${SUDO_USER}")
else
user_home="$HOME"
fi
local summary_file="${user_home}/nas_services.txt"
echo echo
log_success "=== NAS Setup Completed Successfully ===" log_success "=== NAS Setup Completed Successfully ==="
echo echo
@@ -490,47 +500,177 @@ show_installation_summary() {
echo " ✓ NFS server installed" echo " ✓ NFS server installed"
fi fi
if [[ "${INSTALL_NETDATA:-false}" == "true" ]]; then if [[ "${INSTALL_NETDATA:-false}" == "true" ]]; then
echo " ✓ Netdata monitoring: http://$(hostname -I | awk '{print $1}'):${NETDATA_PORT}" echo " ✓ Netdata monitoring: http://${ip_address}:${NETDATA_PORT}"
fi fi
if [[ "${INSTALL_JELLYFIN:-false}" == "true" ]]; then if [[ "${INSTALL_JELLYFIN:-false}" == "true" ]]; then
echo " ✓ Jellyfin media server: http://$(hostname -I | awk '{print $1}'):8096" echo " ✓ Jellyfin media server: http://${ip_address}:8096"
fi fi
if [[ "${INSTALL_PORTAINER:-false}" == "true" ]]; then if [[ "${INSTALL_PORTAINER:-false}" == "true" ]]; then
echo " ✓ Portainer Docker management: http://$(hostname -I | awk '{print $1}'):9000" echo " ✓ Portainer Docker management: http://${ip_address}:9000"
fi fi
if [[ "${INSTALL_WEBMIN:-false}" == "true" ]]; then if [[ "${INSTALL_WEBMIN:-false}" == "true" ]]; then
echo " ✓ Webmin web interface: https://$(hostname -I | awk '{print $1}'):10000" echo " ✓ Webmin web interface: https://${ip_address}:10000"
fi fi
# Docker notes # Create services summary file
if [[ "${INSTALL_DOCKER:-false}" != "true" ]]; then log_info "Creating services summary file: ${summary_file}"
echo cat > "${summary_file}" << EOF
log_warning "Docker wurde nicht installiert oder wurde während der Installation deaktiviert." ============================================================
echo "If you need Docker later, repair the daemon and restart Docker with the helper script in the repository:" NAS Services - Installation Summary
echo " cd $(pwd) && sudo bash scripts/repair_docker.sh" ============================================================
echo "Or create a minimal valid daemon.json and restart Docker manually:"
echo " sudo mv /etc/docker/daemon.json /tmp/daemon.json.broken.$(date +%s) || true" Installation Date: $(date)
echo " sudo tee /etc/docker/daemon.json > /dev/null <<'EOF'" System IP Address: ${ip_address}
echo "{" Admin User: ${ADMIN_USER:-$NEW_USER}
echo " \"storage-driver\": \"overlay2\"" SSH Port: ${SSH_PORT:-$DEFAULT_SSH_PORT}
echo "}"
echo "EOF" ------------------------------------------------------------
echo " sudo systemctl daemon-reload && sudo systemctl restart docker" Installed Services and Access Information:
echo ------------------------------------------------------------
SSH Access:
- Host: ${ip_address}
- Port: ${SSH_PORT:-$DEFAULT_SSH_PORT}
- User: ${ADMIN_USER:-$NEW_USER}
- Command: ssh -p ${SSH_PORT:-$DEFAULT_SSH_PORT} ${ADMIN_USER:-$NEW_USER}@${ip_address}
EOF
# Add service information to file
if [[ "${INSTALL_NETDATA:-false}" == "true" ]]; then
cat >> "${summary_file}" << EOF
Netdata Monitoring:
- URL: http://${ip_address}:${NETDATA_PORT}
- Description: Real-time system monitoring and metrics
EOF
fi fi
if [[ "${INSTALL_JELLYFIN:-false}" == "true" ]]; then
cat >> "${summary_file}" << EOF
Jellyfin Media Server:
- Web Interface: http://${ip_address}:8096
- HTTPS Interface: http://${ip_address}:8920
- DLNA Port: ${ip_address}:1900 (UDP)
- Description: Media streaming and management server
EOF
fi
if [[ "${INSTALL_PORTAINER:-false}" == "true" ]]; then
cat >> "${summary_file}" << EOF
Portainer Docker Management:
- HTTP Interface: http://${ip_address}:9000
- HTTPS Interface: https://${ip_address}:9443
- Description: Web-based Docker container management
- Note: Use HTTPS (9443) for secure access
EOF
fi
if [[ "${INSTALL_VAULTWARDEN:-false}" == "true" ]]; then
cat >> "${summary_file}" << EOF
Vaultwarden Password Manager:
- URL: http://${ip_address}:8080
- Description: Bitwarden-compatible password manager
EOF
fi
if [[ "${INSTALL_WEBMIN:-false}" == "true" ]]; then
cat >> "${summary_file}" << EOF
Webmin System Administration:
- URL: https://${ip_address}:10000
- Description: Web-based system administration interface
EOF
fi
if [[ "${INSTALL_NFS:-false}" == "true" ]]; then
cat >> "${summary_file}" << EOF
NFS Server:
- Port: ${ip_address}:2049
- Description: Network File System for Unix/Linux clients
- Mount example: mount -t nfs ${ip_address}:/srv/nfs /mnt/nfs
EOF
fi
# Samba information
cat >> "${summary_file}" << EOF
Samba File Sharing:
- Ports: ${ip_address}:139 (TCP), ${ip_address}:445 (TCP), ${ip_address}:137-138 (UDP)
- Description: Windows file sharing (SMB/CIFS)
- Access: \\\\${ip_address} or smb://${ip_address}
EOF
# Docker information if installed
if [[ "${INSTALL_DOCKER:-false}" == "true" ]]; then
cat >> "${summary_file}" << EOF
Docker:
- Status: Installed and running
- Socket: /var/run/docker.sock
- Description: Container runtime for additional services
EOF
fi
cat >> "${summary_file}" << EOF
------------------------------------------------------------
System Information:
------------------------------------------------------------
- Configuration file: ${CONFIG_FILE}
- Installation log: ${LOG_FILE}
- System distribution: ${DISTRO_NAME} ${DISTRO_VERSION}
- Kernel: $(uname -r)
------------------------------------------------------------
Security Notes:
------------------------------------------------------------
- Firewall is active and configured
- Fail2ban is monitoring for suspicious activity
- SSH uses Ed25519 keys for enhanced security
- Root login via SSH is disabled
EOF
if [[ "${ENABLE_AUTO_UPDATES:-false}" == "true" ]]; then
echo "- Automatic security updates are enabled" >> "${summary_file}"
else
echo "- Automatic updates are disabled (manual updates recommended)" >> "${summary_file}"
fi
cat >> "${summary_file}" << EOF
------------------------------------------------------------
Next Steps:
------------------------------------------------------------
1. Reboot the system to ensure all changes take effect
2. Review the services above and access them using the provided URLs
3. Configure user accounts and permissions for file sharing
4. Set up backups for your important data
5. Regularly check system logs and monitoring
============================================================
EOF
log_success "Services summary saved to: ${summary_file}"
log_info "You can view this file with: cat ${summary_file}"
echo echo
log_info "Next steps:" log_info "Next steps:"
echo " 1. Reboot the system to ensure all changes take effect" echo " 1. Reboot the system to ensure all changes take effect"
echo " 2. Access your NAS via SSH on port ${SSH_PORT:-$DEFAULT_SSH_PORT}" echo " 2. Access your NAS via SSH on port ${SSH_PORT:-$DEFAULT_SSH_PORT}"
echo " 3. Configure file shares through Samba" echo " 3. Configure file shares through Samba"
echo " 4. Review firewall rules with: sudo ufw status" echo " 4. Review firewall rules with: sudo ufw status"
echo " 5. Check the services summary file: cat ${summary_file}"
echo echo
log_warning "Important: Please save the following information:" log_warning "Important: Please save the following information:"
echo " - SSH Port: ${SSH_PORT:-$DEFAULT_SSH_PORT}" echo " - SSH Port: ${SSH_PORT:-$DEFAULT_SSH_PORT}"
echo " - Admin User: ${ADMIN_USER:-$NEW_USER}" echo " - Admin User: ${ADMIN_USER:-$NEW_USER}"
echo " - Configuration saved in: ${CONFIG_FILE}" echo " - Configuration saved in: ${CONFIG_FILE}"
echo " - Installation log: ${LOG_FILE}" echo " - Installation log: ${LOG_FILE}"
echo " - Services summary: ${summary_file}"
} }
# Main script execution # Main script execution