|
| 1 | +--- |
| 2 | +title: "Bash-Script für die automatische Installation von Apps " |
| 3 | +date: 2025-08-18T11:11:41.499Z |
| 4 | +description: In diesem Tutorial zeige ich, wie ihr mit einem Bash-Script automatisch eure Lieblings-Apps installieren könnt, |
| 5 | +draft: true |
| 6 | +tags: |
| 7 | + - bash |
| 8 | + - linux |
| 9 | + - tutorials |
| 10 | + - debian |
| 11 | +categories: |
| 12 | + - Scripting |
| 13 | + - Tutorials |
| 14 | + - Linux |
| 15 | +menu: |
| 16 | + sidebar: |
| 17 | + name: Bash-Script für App-Installation |
| 18 | + identifier: bash-app |
| 19 | + parent: linux-scripting |
| 20 | +keywords: |
| 21 | + - bash-scripting debian |
| 22 | +--- |
| 23 | +## Bash-Installations-Script für Standard-Apps unter Debian |
| 24 | + |
| 25 | +In diesem Tutorial möchte ich euch zeigen wie ihr ein Bash-Script erstellt, mit dessen Hilfe, ihr eure Standard-Anwendungen auf neue Debian-Systeme automatisiert installieren lassen könnt. |
| 26 | + |
| 27 | +Wir gehen das Bash-Script Schritt für Schritt zusammen durch, damit ihr es auch nach euren Vorlieben anpassen könnt. |
| 28 | + |
| 29 | +```bash |
| 30 | +#!/bin/bash |
| 31 | + |
| 32 | +# Version: 1 |
| 33 | + |
| 34 | +# Hinweis: |
| 35 | +# Dieses Script ist für Debian-basierende Betriebssysteme gedacht! |
| 36 | +# Es ermöglicht die automatisierte Installation von Anwendungen via dem apt-Paketmanager. |
| 37 | +# Es ist wichtig das dieses Script als root-user ausgeführt wird! |
| 38 | + |
| 39 | + |
| 40 | +# Anwendung: |
| 41 | +# sudo chmod =x automatic_install_apps.sh |
| 42 | +# sudo ./automatic_install_apps.sh oder sudo sh automatic_install-apps.sh |
| 43 | + |
| 44 | +# Note: |
| 45 | +# This script is intended for Debian-based operating systems! |
| 46 | +# It enables the automated installation of applications via the apt package manager. |
| 47 | +# It is important that this script is executed as root user! |
| 48 | + |
| 49 | + |
| 50 | +# Usage: |
| 51 | +# sudo chmod =x automatic_install_apps.sh |
| 52 | +# sudo ./automatic_install_apps.sh or sudo sh automatic_install-apps.sh |
| 53 | + |
| 54 | + |
| 55 | +echo "=================================================================" |
| 56 | + |
| 57 | +echo " Automatisches App-Installation / Automatic App-Installation" |
| 58 | + |
| 59 | +echo " (Debian/Ubuntu/Mint)" |
| 60 | + |
| 61 | +echo "=================================================================" |
| 62 | + |
| 63 | + |
| 64 | +if ! command -v apt >/dev/null 2>&1; then |
| 65 | + echo "Kein 'apt'-Paketmanager gefunden. Dieses Script funktioniert nur auf Debian-basierten Systemen / No 'apt' package manager found. This script only works on Debian-based systems." |
| 66 | + exit 2 |
| 67 | +fi |
| 68 | + |
| 69 | +# Auflisten der Anwendungen / List your packages here |
| 70 | +PACKAGES=( |
| 71 | + nano |
| 72 | + wget |
| 73 | + htop |
| 74 | + net-tools |
| 75 | + fail2ban |
| 76 | + ufw |
| 77 | + |
| 78 | +) |
| 79 | + |
| 80 | +# //// Example - Add the Netbird repository |
| 81 | + |
| 82 | +# # Netbird is a secure, open-source VPN solution. |
| 83 | +# # This section installs Netbird and sets it up with a setup key. |
| 84 | + |
| 85 | +# # Make sure to set the setupkey for Netbird in the .env file |
| 86 | + |
| 87 | +# # Example .env file content: |
| 88 | +# # setupkey=your_setup_key_here |
| 89 | + |
| 90 | +# Load environment variables from .env file |
| 91 | + |
| 92 | +if [ -f .env ]; then |
| 93 | + export $(grep -v '^#' .env | xargs) |
| 94 | +else |
| 95 | + echo ".env file not found. Please create a .env file with the required variables." |
| 96 | + exit 1 |
| 97 | +fi |
| 98 | + |
| 99 | +echo "Install ca-certificats, curl, gnupg, add netbird sources..." |
| 100 | +sudo apt update |
| 101 | +sudo apt install ca-certificates curl gnupg -y |
| 102 | + |
| 103 | +echo "Adding netbird repository..." |
| 104 | +curl -fsSL https://pkgs.netbird.io/install.sh | sh |
| 105 | + |
| 106 | +echo "Install netbird... " |
| 107 | +sudo apt update |
| 108 | +sudo apt install netbird -y |
| 109 | + |
| 110 | +echo "Set Netbird-Domain: ${netbird_domain} and register" |
| 111 | +netbird up --management-url ${netbird_domain} --setup-key ${setupkey} |
| 112 | + |
| 113 | +echo "Enable netbird service..." |
| 114 | +sudo systemctl enable netbird |
| 115 | +echo "Starting netbird service..." |
| 116 | +sudo systemctl start netbird |
| 117 | + |
| 118 | +echo "Netbird installation and setup complete." |
| 119 | + |
| 120 | +echo "Updating package list..." |
| 121 | +sudo apt update |
| 122 | + |
| 123 | +echo "Installing packages: ${PACKAGES[*]}" |
| 124 | +sudo apt install -y "${PACKAGES[@]}" |
| 125 | + |
| 126 | +echo "All packages installed." |
| 127 | + |
| 128 | +# echo "Cleaning up package cache..." |
| 129 | +# sudo apt clean |
| 130 | +# echo "Package cache cleaned." |
| 131 | + |
| 132 | +# Clean up unused packages |
| 133 | +echo "Cleaning up ..." |
| 134 | +sudo apt autoremove -y |
| 135 | +echo "Cleanup complete." |
| 136 | +echo "Installation of custom base packages completed successfully." |
| 137 | +echo "You can now use the installed packages." |
| 138 | + |
| 139 | +``` |
0 commit comments