Initialer Import der Synology Scripts
This commit is contained in:
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+541
@@ -0,0 +1,541 @@
|
||||
#!/bin/bash
|
||||
# Variablen
|
||||
# Konfiguration für den Zugriff auf die Synology DiskStation
|
||||
SYNOLOGY_HOST="9.99.50.10"
|
||||
SYNOLOGY_USERNAME="Madzone"
|
||||
SYNOLOGY_PASSWORD="P@ssw0rd"
|
||||
SSH_PRIVATE_KEY="$HOME/.ssh/id_rsa_synology"
|
||||
host=$(nslookup 9.99.50.10)
|
||||
# Zielpfad für das Full-Chain-Zertifikat
|
||||
FULLCHAIN_CERT="fullchain.${HOST_FQDN}.crt"
|
||||
HOST_FQDN=$(hostname -f)
|
||||
HOST_NORMAL=$(hostname -s)
|
||||
DOMAIN=$(hostname -d)
|
||||
REMOTE_DIR="/volume1/HEIMLAN/HEIMLAN"
|
||||
NFS_MOUNT="/mnt/CSR"
|
||||
SSH_PRIVATE_KEY="$HOME/.ssh/id_rsa_synology"
|
||||
TMP="/tmp"
|
||||
|
||||
# Name der Zertifikatsdateien
|
||||
ROOT_CERT="CERT_HEIMLAN_RootCA.crt"
|
||||
SUBCA_CERT="CERT_HEIMLAN_SubCA.crt"
|
||||
SERVER_CERT="CERT_${HOST_FQDN}.crt"
|
||||
|
||||
# Globale Variablen für das Betriebssystem
|
||||
OS=""
|
||||
distro=""
|
||||
version=""
|
||||
codename=""
|
||||
|
||||
# Globale Variablen für OPENSSL
|
||||
CSR_DIR="/tmp"
|
||||
KEY_DIR="/tmp"
|
||||
SSL_DIR=""
|
||||
PKI_DIR=""
|
||||
|
||||
# Extrahiere OU (Organizational Unit) und O (Organization) und wandele sie in Großbuchstaben um
|
||||
OU=$(echo "${DOMAIN%%.*}" | tr '[:lower:]' '[:upper:]')
|
||||
O=$(echo "${DOMAIN#*.}" | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
# Read IP address dynamically from active network interface
|
||||
IP_ADDRESS=$(nmcli -t -f IP4.ADDRESS device show | awk -F: '{split($2,a,"/"); print a[1]; exit}')
|
||||
echo "IP Address: $IP_ADDRESS"
|
||||
|
||||
# GLobale SSH Variablen
|
||||
KEY_PATH="$HOME/.ssh/id_rsa_synology" # Pfad zum SSH-Schlüssel
|
||||
NAS_HOME="/var/services/homes/$SYNOLOGY_USERNAME" # Angepasstes Home-Verzeichnis auf der NAS
|
||||
dnf install sshpass nfs-utils -y
|
||||
|
||||
#*********************************************************************
|
||||
#echo "SSH KEY wird im System implemntiert..."
|
||||
#sudo ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_synology
|
||||
#echo "SSH KEY wurde Erfolgreich im System implemntiert"
|
||||
#echo "SSH Verbindung wird in die .ssh eingetragen...."
|
||||
#sudo ssh-copy-id -i ~/.ssh/id_rsa_synology.pub ${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}${SYNOLOGY_PASSWORD}
|
||||
#echo "SSH Verbindung wurde Erfolgreich in die .ssh eingetragen !!!"
|
||||
|
||||
|
||||
colourmsg(){
|
||||
echo -e "\033[0;36m$1\033[0m"
|
||||
}
|
||||
# Funktion zum Erstellen eines Ordners mit Unterordnern über SSH mit sshpass
|
||||
create_remote_folders() {
|
||||
|
||||
# SSH-Befehl zum Erstellen des Ordners mit Unterordnern mit sshpass
|
||||
echo sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CSR"
|
||||
sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CSR"
|
||||
echo sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CERT"
|
||||
sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CERT"
|
||||
echo sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/KEY"
|
||||
sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/KEY"
|
||||
echo "Ordner ${REMOTE_DIR}/$HOST_FQDN/ wurde auf ${host} erstellt."
|
||||
}
|
||||
|
||||
# Funktion zum Erstellen von SSH-Schlüsseln
|
||||
generate_ssh_key() {
|
||||
if [ ! -f "$KEY_PATH" ]; then
|
||||
echo "Erstelle SSH-Schlüssel..."
|
||||
ssh-keygen -t rsa -b 4096 -N "" -f "$KEY_PATH"
|
||||
else
|
||||
echo "SSH-Schlüssel existieren bereits."
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren des öffentlichen Schlüssels zur NAS
|
||||
copy_ssh_key_to_nas() {
|
||||
echo "Kopiere den öffentlichen Schlüssel zur NAS..."
|
||||
#cat ${KEY_PATH}.pub | ssh -o StrictHostKeyChecking=no $SYNOLOGY_USERNAME@$SYNOLOGY_HOST "tee -a $NAS_HOME/.ssh/authorized_keys && chmod 600 $NAS_HOME/.ssh/authorized_keys"
|
||||
cat ${KEY_PATH}.pub | sshpass -p "$SYNOLOGY_PASSWORD" ssh -o StrictHostKeyChecking=no $SYNOLOGY_USERNAME@$SYNOLOGY_HOST "tee -a $NAS_HOME/.ssh/authorized_keys && chmod 600 $NAS_HOME/.ssh/authorized_keys"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Öffentlicher Schlüssel erfolgreich zur NAS kopiert."
|
||||
else
|
||||
echo "Fehler beim Kopieren des öffentlichen Schlüssels zur NAS."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren der Datei von der NAS zum lokalen Rechner
|
||||
copy_file_from_nas() {
|
||||
echo "Kopiere die Datei von der NAS zum lokalen Rechner..."
|
||||
scp -i "$KEY_PATH" $SYNOLOGY_USERNAME@SYNOLOGY_HOST:$NAS_HOME "$KEY_PATH"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Datei erfolgreich kopiert."
|
||||
else
|
||||
echo "Fehler beim Kopieren der Datei."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Funktion zum Ermitteln des Betriebssystems
|
||||
detect_os() {
|
||||
echo "Das installierte Derivat wird ermittelt...."
|
||||
OS=$(uname -s)
|
||||
|
||||
case $OS in
|
||||
Linux*)
|
||||
# Überprüfen, ob lsb_release verfügbar ist
|
||||
if command -v lsb_release &> /dev/null; then
|
||||
# Verwende lsb_release, wenn es verfügbar ist
|
||||
distro=$(lsb_release -si)
|
||||
version=$(lsb_release -sr)
|
||||
codename=$(lsb_release -sc)
|
||||
else
|
||||
# Überprüfe /etc/os-release
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
distro=$NAME
|
||||
version=$VERSION_ID
|
||||
codename=$VERSION_CODENAME
|
||||
# Überprüfe /etc/lsb-release
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
. /etc/lsb-release
|
||||
distro=$DISTRIB_ID
|
||||
version=$DISTRIB_RELEASE
|
||||
codename=$DISTRIB_CODENAME
|
||||
# Überprüfe /etc/debian_version
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
distro="Debian"
|
||||
version=$(cat /etc/debian_version)
|
||||
codename=$(uname -r)
|
||||
# Überprüfe /etc/redhat-release
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
distro=$(cat /etc/redhat-release)
|
||||
version=$(uname -r)
|
||||
codename=$(uname -r)
|
||||
else
|
||||
distro="Unbekannte Distribution"
|
||||
version="Unbekannte Version"
|
||||
codename="Unbekannter Codename"
|
||||
fi
|
||||
fi
|
||||
# Ausgabe der ermittelten Informationen
|
||||
echo "\n\n"
|
||||
echo "Distribution: $distro"
|
||||
echo "Version: $version"
|
||||
echo "Codename: $codename"
|
||||
echo "\n\n"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OS: $OS"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${distro} wurde ....... Ausgewählt......."
|
||||
}
|
||||
install_requierments(){
|
||||
echo "Erstellen des Zertifikatsrequests..."
|
||||
echo " Funktion create_certificate_request() wert der Variable distro: $distro"
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
echo "" Alle Noetigen Kompomenten werden Installiert....
|
||||
apt install sudo sshpass nfs-common -y
|
||||
;;
|
||||
CentOS)
|
||||
echo "" Alle Noetigen Kompomenten werden Installiert....
|
||||
dnf install sudo sshpass nfs-utils -y
|
||||
;;
|
||||
"Red Hat Enterprise Linux")
|
||||
echo "" Alle Noetigen Kompomenten werden Installiert....
|
||||
dnf install sudo sshpass nfs-utils -y
|
||||
;;
|
||||
*)
|
||||
echo "Das Betriebssystem wird nicht unterstützt für Zertifikatsrequest.";;
|
||||
esac
|
||||
}
|
||||
# Funktion zum Erstellen des Zertifikatsrequests
|
||||
create_certificate_request() {
|
||||
echo "Erstellen des Zertifikatsrequests..."
|
||||
echo " Funktion create_certificate_request() wert der Variable distro: $distro"
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
apt install sudo sshpass nfs-common -y
|
||||
# Debian / Ubuntu spezifische Pfade
|
||||
#KEY_DIR="/etc/ssl/private/"
|
||||
# Erstellen des privaten Schlüssels
|
||||
openssl genrsa -out "${KEY_DIR}/KEY_${HOST_FQDN}.pem" 4096
|
||||
echo "Privater Schlüssel wurde erstellt: private.key"
|
||||
# CSR erstellen
|
||||
#CSR_DIR="/tmp"
|
||||
openssl req -new -key "${KEY_DIR}/KEY_${HOST_FQDN}.pem" -out "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -subj "/C=DE/ST=TH/L=ILM/O=${O}/OU=${OU}/CN=${HOST_FQDN}/emailAddress=admin@$DOMAIN"
|
||||
echo "Zertifikatsrequest wurde erstellt: request.csr"
|
||||
# CSR anzeigen
|
||||
echo "Inhalt des erstellten Zertifikatsrequests: DEBIAN|UBUNTU......."
|
||||
openssl req -in "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -text -noout
|
||||
;;
|
||||
CentOS)
|
||||
# CentOS spezifische Pfade
|
||||
#KEY_DIR="/etc/pki/tls/private/"
|
||||
# Erstellen des privaten Schlüssels
|
||||
openssl genrsa -out "${KEY_DIR}KEY_${HOST_FQDN}.pem" 4096
|
||||
echo "Privater Schlüssel wurde erstellt und gespeichert unter: ${KEY_DIR}KEY_${HOST_FQDN}.key"
|
||||
# CSR erstellen
|
||||
#CSR_DIR="/tmp"
|
||||
openssl req -new -key "${KEY_DIR}/KEY_${HOST_FQDN}.pem" -out "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -subj "/C=DE/ST=TH/L=ILM/O=HEIMLAN/OU=HEIMLAN/CN=${HOST_FQDN}/emailAddress=admin@$DOMAIN"
|
||||
echo "Zertifikatsrequest wurde erstellt und gespeichert unter: ${CSR_DIR}/CSR_${HOST_FQDN}.csr"
|
||||
# CSR anzeigen
|
||||
echo "Inhalt des erstellten Zertifikatsrequests: CENTOS....."
|
||||
openssl req -in "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -text -noout
|
||||
;;
|
||||
"Red Hat Enterprise Linux")
|
||||
# CentOS spezifische Pfade
|
||||
#KEY_DIR="/etc/pki/tls/private/"
|
||||
# Erstellen des privaten Schlüssels
|
||||
openssl genrsa -out "${KEY_DIR}/KEY_${HOST_FQDN}.pem" 4096
|
||||
echo "Privater Schlüssel wurde erstellt und gespeichert unter: ${KEY_DIR}KEY_${HOST_FQDN}.key"
|
||||
# CSR erstellen
|
||||
#CSR_DIR="/tmp"
|
||||
openssl req -new -key "${KEY_DIR}/KEY_${HOST_FQDN}.pem" -out "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -subj "/C=DE/ST=TH/L=ILM/O=HEIMLAN/OU=HEIMLAN/CN=${HOST_FQDN}/emailAddress=admin@$DOMAIN"
|
||||
echo "Zertifikatsrequest wurde erstellt und gespeichert unter: ${CSR_DIR}/CSR_${HOST_FQDN}.csr"
|
||||
# CSR anzeigen
|
||||
echo "Inhalt des erstellten Zertifikatsrequests: RHEL ....."
|
||||
openssl req -in "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -text -noout
|
||||
;;
|
||||
*)
|
||||
echo "Das Betriebssystem wird nicht unterstützt für Zertifikatsrequest.";;
|
||||
esac
|
||||
}
|
||||
|
||||
# Funktion zum Erstellen des SSH-Schlüsselpaars und Hinzufügen zur Synology
|
||||
setup_ssh_keys() {
|
||||
echo "=== Einrichten von SSH-Schlüsseln ==="
|
||||
|
||||
# Überprüfen, ob der private Schlüssel bereits vorhanden ist
|
||||
if [ ! -f "${SSH_PRIVATE_KEY}" ]; then
|
||||
echo "Erstelle SSH-Schlüsselpaar..."
|
||||
ssh-keygen -t rsa -b 4096 -f "${SSH_PRIVATE_KEY}" -N "" -C "Synology SSH key"
|
||||
echo "SSH-Schlüsselpaar wurde erstellt: ${SSH_PRIVATE_KEY}"
|
||||
else
|
||||
echo "SSH-Schlüsselpaar ist bereits vorhanden: ${SSH_PRIVATE_KEY}"
|
||||
fi
|
||||
|
||||
# SSH-Schlüssel zur Synology hinzufügen
|
||||
echo "Füge den öffentlichen Schlüssel zur Synology hinzu..."
|
||||
ssh-copy-id -i "${SSH_PRIVATE_KEY}.pub" "${SYNOLOGY_USER}@${SYNOLOGY_HOST}"
|
||||
echo "Öffentlicher Schlüssel wurde zur Synology hinzugefügt."
|
||||
}
|
||||
|
||||
# Funktion zum Hochladen des Requests zur Synology
|
||||
upload_certificate_request() {
|
||||
echo "Hochladen des Zertifikatsrequests zur Synology..."
|
||||
# Mounten der NFS-Freigabe mit Benutzername und Passwort
|
||||
sudo mkdir -p ${NFS_MOUNT}
|
||||
echo "sudo mkdir $NFS_MOUNT"
|
||||
#sudo mkdir -p ${NFS_MOUNT}
|
||||
#sleep 10
|
||||
#ls /mnt/CSR/
|
||||
#sudo mount -t nfs -o username="${SYNOLOGY_USER}",password="${SYNOLOGY_PASSWORD}" "${SYNOLOGY_HOST}:${REMOTE_DIR}/$HOST_NORMAL/CSR" "${NFS_MOUNT}"
|
||||
sudo mount -t nfs -o nfsvers=3 "${SYNOLOGY_HOST}:${REMOTE_DIR}" "${NFS_MOUNT}"
|
||||
ls -lha /mnt/CSR/
|
||||
#echo "TEST WARTE ZEIT 30 SEKUNDEN......"
|
||||
#sleep 30
|
||||
# Überprüfen, ob das Mount erfolgreich war
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "NFS-Freigabe erfolgreich eingebunden: ${NFS_MOUNT}"
|
||||
# Kopieren der Datei auf die NFS-Freigabe
|
||||
ls -lha /mnt/CSR/
|
||||
sleep 5
|
||||
sudo cp "${CSR_DIR}/CSR_${HOST_FQDN}.csr" "${NFS_MOUNT}/${HOST_FQDN}/CSR/"
|
||||
sudo cp "${KEY_DIR}/KEY_${HOST_FQDN}.pem" "${NFS_MOUNT}/${HOST_FQDN}/KEY/"
|
||||
sleep 5
|
||||
ls -lha /mnt/CSR/
|
||||
echo "Datei erfolgreich auf die NFS-Freigabe hochgeladen."
|
||||
#echo "2. TEST WARTE ZEIT 30 SEKUNDEN......"
|
||||
#sleep 30
|
||||
else
|
||||
echo "Fehler beim Einbinden der NFS-Freigabe: ${NFS_MOUNT}"
|
||||
fi
|
||||
echo "Zertifikatsrequest wurde zur Synology hochgeladen."
|
||||
}
|
||||
umountNFS(){
|
||||
# NFS-Freigabe wieder aushängen
|
||||
sudo umount "${NFS_MOUNT}"
|
||||
cd /mnt
|
||||
rmdir CSR/
|
||||
echo "NFS-Freigabe erfolgreich ausgehängt."
|
||||
}
|
||||
# Funktion zum Herunterladen von Root-Zertifikat, Sub-CA-Zertifikat und Server-Zertifikat
|
||||
download_certificates() {
|
||||
echo "Herunterladen von Root-Zertifikat, Sub-CA-Zertifikat und Server-Zertifikat..."
|
||||
echo "=== Überprüfen und Herunterladen der Datei von der Synology ==="
|
||||
|
||||
# SSH-Befehl, um die Existenz der Datei auf der Synology zu überprüfen
|
||||
ssh -i "$KEY_PATH" "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" test -f "${REMOTE_DIR}/${HOST_FQDN}/CERT/$SERVER_CERT"
|
||||
|
||||
# Prüfen des Rückgabewerts von test (-f) und Entscheidung treffen
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Datei CERT_${HOST_FQDN}.crt auf der Synology gefunden. Beginne mit dem Download..."
|
||||
cp "${NFS_MOUNT}/${HOST_FQDN}/CERT/$SERVER_CERT" "${TMP}/$SERVER_CERT"
|
||||
cp "${NFS_MOUNT}/RootCA/$ROOT_CERT" "${TMP}/$ROOT_CERT"
|
||||
cp "${NFS_MOUNT}/SubCA/$SUBCA_CERT" "${TMP}/$SUBCA_CERT"
|
||||
echo "Datei erfolgreich heruntergeladen nach ${TMP}"
|
||||
else
|
||||
#echo "Datei $SERVER_CERT nicht auf der Synology gefunden. Warte 300 Sekunden..."
|
||||
#sleep 300
|
||||
echo "Datei $SERVER_CERT nicht auf der Synology gefunden. Warte 300 Sekunden..."
|
||||
|
||||
# Timer mit Countdown anzeigen
|
||||
for ((i=300; i>0; i--)); do
|
||||
echo -ne "Noch $i Sekunden warten...\r"
|
||||
sleep 1
|
||||
done
|
||||
echo
|
||||
download_certificates # Rekursiver Aufruf, um erneut zu prüfen
|
||||
fi
|
||||
echo "Zertifikate wurden heruntergeladen."
|
||||
}
|
||||
|
||||
# Funktion zum Erstellen des Full-Chain-Zertifikats und Umbenennen
|
||||
create_fullchain_certificate() {
|
||||
echo "Erstellen des Full-Chain-Zertifikats..."
|
||||
# Zielpfad für das Full-Chain-Zertifikat
|
||||
FULLCHAIN_CERT="/tmp/fullchain.crt"
|
||||
|
||||
# Full-Chain-Zertifikat erstellen
|
||||
cat "$TMP/$SERVER_CERT" "$TMP/$SUBCA_CERT" "$TMP/$ROOT_CERT" > "$FULLCHAIN_CERT"
|
||||
|
||||
echo "Full-Chain-Zertifikat wurde erstellt: $FULLCHAIN_CERT"
|
||||
|
||||
# Server-Zertifikat nach Hostnamen benennen
|
||||
HOSTNAME=$(hostname)
|
||||
mv "$FULLCHAIN_CERT" "$TMP/fullchain_$HOST_FQDN.crt"
|
||||
|
||||
echo "Full-Chain-Zertifikat umbenannt zu fullchain_$HOST_FQDN.crt"
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren der Zertifikate in die richtigen Pfade je nach Derivat und Typ
|
||||
copy_certificates() {
|
||||
echo "Kopieren der Zertifikate in die richtigen Pfade..."
|
||||
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
# Debian / Ubuntu spezifische Pfade
|
||||
SSL_DIR="/usr/local/share/ca-certificates/"
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR/$SERVER_CERT"
|
||||
echo "Zertifikate wurden nach $SSL_DIR kopiert."
|
||||
update-ca-certificates
|
||||
;;
|
||||
CentOS|"Red Hat Enterprise Linux")
|
||||
# CentOS spezifische Pfade
|
||||
SSL_DIR="/etc/pki/tls/certs/"
|
||||
PKI_DIR="/etc/pki/ca-trust/source/anchors/"
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR/$ROOT_CERT"
|
||||
cp "$TMP/$ROOT_CERT" "$PKI_DIR/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR/$SUBCA_CERT"
|
||||
cp "$TMP/$SUBCA_CERT" "$PKI_DIR/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR/$SERVER_CERT"
|
||||
cp "$TMP/$SERVER_CERT" "$PKI_DIR/$SERVER_CERT"
|
||||
echo "Zertifikate wurden nach $SSL_DIR und nach $PKI_DIR kopiert."
|
||||
update-ca-trust
|
||||
;;
|
||||
*)
|
||||
echo "Das Betriebssystem $OS wird nicht unterstützt für Zertifikate-Kopieren."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren der Zertifikate in die richtigen Pfade je nach WebServer Ty
|
||||
copy_web_certificates() {
|
||||
echo "Kopieren der Zertifikate in die richtigen Pfade und Aktualisieren der Konfigurationsdateien..."
|
||||
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
# Debian / Ubuntu spezifische Pfade
|
||||
SSL_DIR_APACHE="/etc/ssl/certs/"
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
|
||||
# Prüfen, ob Apache installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/apache2/apache2.conf" ]; then
|
||||
SSL_DIR_APACHE="/etc/apache2/ssl/"
|
||||
fi
|
||||
|
||||
# Prüfen, ob Nginx installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
fi
|
||||
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_APACHE/$ROOT_CERT"
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_NGINX/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_APACHE/$SUBCA_CERT"
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_NGINX/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_CERT"
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_CERT"
|
||||
|
||||
echo "Zertifikate wurden nach $SSL_DIR_APACHE und $SSL_DIR_NGINX kopiert."
|
||||
|
||||
# Aktualisieren der Apache-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/apache2/apache2.conf" ]; then
|
||||
update_apache_config "$SSL_DIR_APACHE/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_KEY"
|
||||
fi
|
||||
|
||||
# Aktualisieren der Nginx-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
update_nginx_config "$SSL_DIR_NGINX/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_KEY"
|
||||
fi
|
||||
;;
|
||||
CentOS|"Red Hat Enterprise Linux")
|
||||
# CentOS spezifische Pfade
|
||||
SSL_DIR_APACHE="/etc/pki/tls/certs/"
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
|
||||
# Prüfen, ob Apache installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/httpd/conf/httpd.conf" ]; then
|
||||
SSL_DIR_APACHE="/etc/httpd/ssl/"
|
||||
fi
|
||||
|
||||
# Prüfen, ob Nginx installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
fi
|
||||
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_APACHE/$ROOT_CERT"
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_NGINX/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_APACHE/$SUBCA_CERT"
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_NGINX/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_CERT"
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_CERT"
|
||||
|
||||
echo "Zertifikate wurden nach $SSL_DIR_APACHE und $SSL_DIR_NGINX kopiert."
|
||||
|
||||
# Aktualisieren der Apache-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/httpd/conf/httpd.conf" ]; then
|
||||
update_apache_config "$SSL_DIR_APACHE/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_KEY"
|
||||
fi
|
||||
|
||||
# Aktualisieren der Nginx-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
update_nginx_config "$SSL_DIR_NGINX/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_KEY"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Es ist kein WEbServer auf diesen System Installiert"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Funktion zum Aktualisieren der Apache-Konfiguration
|
||||
update_apache_config() {
|
||||
local cert_file="$1"
|
||||
local key_file="$2"
|
||||
|
||||
echo "Aktualisiere Apache-Konfiguration für SSL-Zertifikate..."
|
||||
|
||||
# Konfigurationsdatei für SSL-Zertifikate finden und bearbeiten
|
||||
local apache_config_file=$(find /etc/apache2 -name "ssl.conf" -o -name "httpd.conf" 2>/dev/null | head -1)
|
||||
if [ -n "$apache_config_file" ]; then
|
||||
# SSLCertificateFile aktualisieren
|
||||
sed -i "s|^\( *SSLCertificateFile *\).*|\1$cert_file|" "$apache_config_file"
|
||||
# SSLCertificateKeyFile aktualisieren
|
||||
sed -i "s|^\( *SSLCertificateKeyFile *\).*|\1$key_file|" "$apache_config_file"
|
||||
echo "Apache-Konfiguration aktualisiert."
|
||||
else
|
||||
echo "Apache-Konfigurationsdatei nicht gefunden oder nicht aktualisiert."
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Aktualisieren der Nginx-Konfiguration
|
||||
update_nginx_config() {
|
||||
local cert_file="$1"
|
||||
local key_file="$2"
|
||||
|
||||
echo "Aktualisiere Nginx-Konfiguration für SSL-Zertifikate..."
|
||||
|
||||
# Konfigurationsdatei für SSL-Zertifikate finden und bearbeiten
|
||||
local nginx_config_file="/etc/nginx/nginx.conf"
|
||||
if [ -f "$nginx_config_file" ]; then
|
||||
# SSL Zertifikat und Key aktualisieren
|
||||
sed -i "s|^\( *ssl_certificate *\).*|\1$cert_file;|" "$nginx_config_file"
|
||||
sed -i "s|^\( *ssl_certificate_key *\).*|\1$key_file;|" "$nginx_config_file"
|
||||
echo "Nginx-Konfiguration aktualisiert."
|
||||
else
|
||||
echo "Nginx-Konfigurationsdatei nicht gefunden oder nicht aktualisiert."
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Ermitteln des installierten Webserver-Dienstes
|
||||
detect_webserver() {
|
||||
if [ -f "/etc/apache2/apache2.conf" ]; then
|
||||
echo "Apache Webserver ist installiert."
|
||||
fi
|
||||
if [ -f "/etc/httpd/conf/httpd.conf" ]; then
|
||||
echo "Apache Webserver ist installiert."
|
||||
fi
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
echo "Nginx Webserver ist installiert."
|
||||
fi
|
||||
}
|
||||
|
||||
echo
|
||||
# Hauptprogramm
|
||||
detect_os
|
||||
install_requierments
|
||||
generate_ssh_key
|
||||
copy_ssh_key_to_nas
|
||||
create_certificate_request
|
||||
create_remote_folders
|
||||
#Wird nicht genutz
|
||||
#setup_ssh_keys
|
||||
upload_certificate_request
|
||||
download_certificates
|
||||
create_fullchain_certificate
|
||||
copy_certificates
|
||||
|
||||
# Funktionen fue WebServer Zertifiakte
|
||||
detect_webserver
|
||||
copy_web_certificates
|
||||
#umountNFS
|
||||
echo "Prozess abgeschlossen."
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Installing PostgreSQL..."
|
||||
sudo apt install -y postgresql postgresql-contrib
|
||||
|
||||
echo "Enable local connections"
|
||||
sudo sed -i 's/local\s\+all\s\+postgres\s\+peer/local all postgres trust/' /etc/postgresql/16/main/pg_hba.conf
|
||||
sudo sed -i 's/local\s\+all\s\+all\s\+peer/local all all md5/' /etc/postgresql/16/main/pg_hba.conf
|
||||
|
||||
echo "Stopping PostgreSQL service..."
|
||||
sudo systemctl stop postgresql
|
||||
|
||||
echo "Starting PostgreSQL service..."
|
||||
sudo systemctl start postgresql
|
||||
|
||||
echo "Configuring Alfresco database..."
|
||||
psql -U postgres -c "CREATE USER alfresco WITH PASSWORD 'alfresco';"
|
||||
psql -U postgres -c "CREATE DATABASE alfresco OWNER alfresco ENCODING 'UTF8';"
|
||||
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE alfresco TO alfresco;"
|
||||
|
||||
echo "Stopping PostgreSQL service..."
|
||||
sudo systemctl stop postgresql
|
||||
|
||||
echo "Enabling PostgreSQL to start on boot..."
|
||||
sudo systemctl enable postgresql
|
||||
|
||||
echo "PostgreSQL installation and setup completed successfully!"
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Installing Java JDK 17..."
|
||||
sudo apt install -y openjdk-17-jdk
|
||||
|
||||
echo "Setting Java 17 as the default Java version..."
|
||||
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1
|
||||
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-17-openjdk-amd64/bin/javac 1
|
||||
sudo update-alternatives --set java /usr/lib/jvm/java-17-openjdk-amd64/bin/java
|
||||
sudo update-alternatives --set javac /usr/lib/jvm/java-17-openjdk-amd64/bin/javac
|
||||
|
||||
echo "Checking Java version..."
|
||||
java -version
|
||||
|
||||
echo "Java JDK 17 installation and setup completed successfully!"
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Variables
|
||||
TOMCAT_VERSION=10.1.26
|
||||
TOMCAT_USER=ubuntu
|
||||
TOMCAT_GROUP=ubuntu
|
||||
TOMCAT_HOME=/home/ubuntu/tomcat
|
||||
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Downloading Apache Tomcat..."
|
||||
wget https://dlcdn.apache.org/tomcat/tomcat-10/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz -O /tmp/apache-tomcat-$TOMCAT_VERSION.tar.gz
|
||||
|
||||
echo "Extracting Tomcat..."
|
||||
sudo mkdir -p $TOMCAT_HOME
|
||||
sudo tar xzvf /tmp/apache-tomcat-$TOMCAT_VERSION.tar.gz -C $TOMCAT_HOME --strip-components=1
|
||||
|
||||
echo "Setting permissions for Tomcat directories..."
|
||||
sudo chown -R $TOMCAT_USER:$TOMCAT_GROUP $TOMCAT_HOME
|
||||
sudo chmod -R u+x $TOMCAT_HOME/bin
|
||||
|
||||
echo "Creating Tomcat systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/tomcat.service
|
||||
[Unit]
|
||||
Description=Apache Tomcat Web Application Container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
User=$TOMCAT_USER
|
||||
Group=$TOMCAT_GROUP
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
Environment="CATALINA_PID=$TOMCAT_HOME/temp/tomcat.pid"
|
||||
Environment="CATALINA_HOME=$TOMCAT_HOME"
|
||||
Environment="CATALINA_BASE=$TOMCAT_HOME"
|
||||
Environment="CATALINA_OPTS=-Xms2048M -Xmx3072M -server -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80"
|
||||
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
|
||||
Environment="JAVA_TOOL_OPTIONS=-Dencryption.keystore.type=JCEKS -Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding -Dencryption.keyAlgorithm=DESede -Dencryption.keystore.location=/home/ubuntu/keystore/metadata-keystore/keystore -Dmetadata-keystore.password=mp6yc0UD9e -Dmetadata-keystore.aliases=metadata -Dmetadata-keystore.metadata.password=oKIWzVdEdA -Dmetadata-keystore.metadata.algorithm=DESede"
|
||||
|
||||
ExecStart=$TOMCAT_HOME/bin/startup.sh
|
||||
ExecStop=$TOMCAT_HOME/bin/shutdown.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Tomcat service..."
|
||||
sudo systemctl start tomcat
|
||||
|
||||
echo "Stopping Tomcat service..."
|
||||
sudo systemctl stop tomcat
|
||||
|
||||
echo "Enabling Tomcat service to start on boot..."
|
||||
sudo systemctl enable tomcat
|
||||
|
||||
echo "Apache Tomcat installation and setup completed successfully!"
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Variables
|
||||
ACTIVEMQ_VERSION=5.18.5
|
||||
ACTIVEMQ_USER=ubuntu
|
||||
ACTIVEMQ_GROUP=ubuntu
|
||||
ACTIVEMQ_HOME=/home/ubuntu/activemq
|
||||
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Downloading ActiveMQ..."
|
||||
wget https://dlcdn.apache.org/activemq/$ACTIVEMQ_VERSION/apache-activemq-$ACTIVEMQ_VERSION-bin.tar.gz -O /tmp/apache-activemq-$ACTIVEMQ_VERSION-bin.tar.gz
|
||||
|
||||
echo "Extracting ActiveMQ..."
|
||||
sudo mkdir -p $ACTIVEMQ_HOME
|
||||
sudo tar xzvf /tmp/apache-activemq-$ACTIVEMQ_VERSION-bin.tar.gz -C $ACTIVEMQ_HOME --strip-components=1
|
||||
|
||||
echo "Setting permissions for ActiveMQ directories..."
|
||||
sudo chown -R $ACTIVEMQ_USER:$ACTIVEMQ_GROUP $ACTIVEMQ_HOME
|
||||
sudo chmod -R 755 $ACTIVEMQ_HOME
|
||||
|
||||
echo "Creating ActiveMQ systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/activemq.service
|
||||
[Unit]
|
||||
Description=Apache ActiveMQ
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
User=$ACTIVEMQ_USER
|
||||
Group=$ACTIVEMQ_GROUP
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
Environment="ACTIVEMQ_HOME=$ACTIVEMQ_HOME"
|
||||
Environment="ACTIVEMQ_BASE=$ACTIVEMQ_HOME"
|
||||
Environment="ACTIVEMQ_CONF=$ACTIVEMQ_HOME/conf"
|
||||
Environment="ACTIVEMQ_DATA=$ACTIVEMQ_HOME/data"
|
||||
|
||||
ExecStart=$ACTIVEMQ_HOME/bin/activemq start
|
||||
ExecStop=$ACTIVEMQ_HOME/bin/activemq stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting ActiveMQ service..."
|
||||
sudo systemctl start activemq
|
||||
|
||||
echo "Stopping ActiveMQ service..."
|
||||
sudo systemctl stop activemq
|
||||
|
||||
echo "Enabling ActiveMQ service to start on boot..."
|
||||
sudo systemctl enable activemq
|
||||
|
||||
echo "Apache ActiveMQ installation and setup completed successfully!"
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# URLs of the resources to be downloaded
|
||||
URLS=(
|
||||
"https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-content-services-community-distribution/23.2.1/alfresco-content-services-community-distribution-23.2.1.zip"
|
||||
"https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-search-services/2.0.9.1/alfresco-search-services-2.0.9.1.zip"
|
||||
"https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-transform-core-aio/5.1.0/alfresco-transform-core-aio-5.1.0.jar"
|
||||
)
|
||||
|
||||
|
||||
# Directory to save the downloaded files
|
||||
DOWNLOAD_DIR="./downloads"
|
||||
|
||||
# Create the download directory if it does not exist
|
||||
mkdir -p "$DOWNLOAD_DIR"
|
||||
|
||||
# Function to download a file
|
||||
download_file() {
|
||||
local url=$1
|
||||
local dest_dir=$2
|
||||
local filename=$(basename "$url")
|
||||
|
||||
echo "Downloading $filename..."
|
||||
curl -L -o "$dest_dir/$filename" -w "\nHTTP Status: %{http_code}\n" "$url"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Downloaded $filename successfully."
|
||||
else
|
||||
echo "Failed to download $filename."
|
||||
fi
|
||||
|
||||
# Check if the file size is greater than 0 bytes
|
||||
if [ ! -s "$dest_dir/$filename" ]; then
|
||||
echo "Warning: Downloaded file $filename is empty."
|
||||
fi
|
||||
}
|
||||
|
||||
# Loop through each URL and download the file
|
||||
for url in "${URLS[@]}"; do
|
||||
download_file "$url" "$DOWNLOAD_DIR"
|
||||
done
|
||||
|
||||
echo "All downloads are complete."
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Install unzip command"
|
||||
sudo apt -y install unzip
|
||||
|
||||
echo "Create support folders and configuration in Tomcat"
|
||||
mkdir -p /home/ubuntu/tomcat/shared/classes && mkdir -p /home/ubuntu/tomcat/shared/lib
|
||||
sed -i 's|^shared.loader=$|shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar|' /home/ubuntu/tomcat/conf/catalina.properties
|
||||
|
||||
echo "Unzip Alfresco ZIP Distribution File"
|
||||
mkdir /tmp/alfresco
|
||||
unzip downloads/alfresco-content-services-community-distribution-23.2.1.zip -d /tmp/alfresco
|
||||
|
||||
echo "Copy JDBC driver"
|
||||
cp /tmp/alfresco/web-server/lib/postgresql-42.6.0.jar /home/ubuntu/tomcat/shared/lib/
|
||||
|
||||
echo "Configure JAR Addons deployment"
|
||||
mkdir -p /home/ubuntu/modules/platform && mkdir -p /home/ubuntu/modules/share && mkdir -p /home/ubuntu/tomcat/conf/Catalina/localhost
|
||||
cp /tmp/alfresco/web-server/conf/Catalina/localhost/* /home/ubuntu/tomcat/conf/Catalina/localhost/
|
||||
|
||||
echo "Install Web Applications"
|
||||
cp /tmp/alfresco/web-server/webapps/* /home/ubuntu/tomcat/webapps/
|
||||
|
||||
echo "Apply configuration"
|
||||
cp -r /tmp/alfresco/web-server/shared/classes/* /home/ubuntu/tomcat/shared/classes/
|
||||
mkdir /home/ubuntu/keystore && cp -r /tmp/alfresco/keystore/* /home/ubuntu/keystore/
|
||||
mkdir /home/ubuntu/alf_data
|
||||
cat <<EOL | tee /home/ubuntu/tomcat/shared/classes/alfresco-global.properties
|
||||
#
|
||||
# Custom content and index data location
|
||||
#
|
||||
dir.root=/home/ubuntu/alf_data
|
||||
dir.keystore=/home/ubuntu/keystore/
|
||||
|
||||
#
|
||||
# Database connection properties
|
||||
#
|
||||
db.username=alfresco
|
||||
db.password=alfresco
|
||||
db.driver=org.postgresql.Driver
|
||||
db.url=jdbc:postgresql://localhost:5432/alfresco
|
||||
|
||||
#
|
||||
# Solr Configuration
|
||||
#
|
||||
solr.secureComms=secret
|
||||
solr.sharedSecret=secret
|
||||
solr.host=localhost
|
||||
solr.port=8983
|
||||
index.subsystem.name=solr6
|
||||
|
||||
#
|
||||
# Transform Configuration
|
||||
#
|
||||
localTransform.core-aio.url=http://localhost:8090/
|
||||
|
||||
#
|
||||
# Events Configuration
|
||||
#
|
||||
messaging.broker.url=failover:(nio://localhost:61616)?timeout=3000&jms.useCompression=true
|
||||
|
||||
#
|
||||
# URL Generation Parameters
|
||||
#-------------
|
||||
alfresco.context=alfresco
|
||||
alfresco.host=localhost
|
||||
alfresco.port=8080
|
||||
alfresco.protocol=http
|
||||
share.context=share
|
||||
share.host=localhost
|
||||
share.port=8080
|
||||
share.protocol=http
|
||||
EOL
|
||||
|
||||
echo "Apply AMPs"
|
||||
mkdir /home/ubuntu/amps && cp -r /tmp/alfresco/amps/* /home/ubuntu/amps/
|
||||
mkdir /home/ubuntu/bin && cp -r /tmp/alfresco/bin/* /home/ubuntu/bin/
|
||||
java -jar /home/ubuntu/bin/alfresco-mmt.jar install /home/ubuntu/amps /home/ubuntu/tomcat/webapps/alfresco.war -directory
|
||||
java -jar /home/ubuntu/bin/alfresco-mmt.jar list /home/ubuntu/tomcat/webapps/alfresco.war
|
||||
|
||||
echo "Modify alfresco and share logs directory"
|
||||
mkdir /home/ubuntu/tomcat/webapps/alfresco && unzip /home/ubuntu/tomcat/webapps/alfresco.war -d /home/ubuntu/tomcat/webapps/alfresco
|
||||
mkdir /home/ubuntu/tomcat/webapps/share && unzip /home/ubuntu/tomcat/webapps/share.war -d /home/ubuntu/tomcat/webapps/share
|
||||
sed -i 's|^appender\.rolling\.fileName=alfresco\.log|appender.rolling.fileName=/home/ubuntu/tomcat/logs/alfresco.log|' /home/ubuntu/tomcat/webapps/alfresco/WEB-INF/classes/log4j2.properties
|
||||
sed -i 's|^appender\.rolling\.fileName=share\.log|appender.rolling.fileName=/home/ubuntu/tomcat/logs/share.log|' /home/ubuntu/tomcat/webapps/share/WEB-INF/classes/log4j2.properties
|
||||
|
||||
|
||||
echo "Alfresco has been configured"
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Unzip SOLR ZIP Distribution File"
|
||||
mkdir /tmp/solr
|
||||
unzip downloads/alfresco-search-services-2.0.9.1.zip -d /tmp/solr
|
||||
mv /tmp/solr/alfresco-search-services /home/ubuntu
|
||||
|
||||
# Variables
|
||||
SOLR_USER=ubuntu
|
||||
SOLR_GROUP=ubuntu
|
||||
SOLR_HOME=/home/ubuntu/alfresco-search-services
|
||||
|
||||
echo "Creating SOLR systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/solr.service
|
||||
[Unit]
|
||||
Description=Apache SOLR Web Application Container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
User=$SOLR_USER
|
||||
Group=$SOLR_GROUP
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
|
||||
ExecStart=/home/ubuntu/alfresco-search-services/solr/bin/solr start -a "-Dcreate.alfresco.defaults=alfresco,archive -Dalfresco.secureComms=secret -Dalfresco.secureComms.secret=secret"
|
||||
ExecStop=/home/ubuntu/alfresco-search-services/solr/bin/solr stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Solr service..."
|
||||
sudo systemctl start solr
|
||||
|
||||
echo "Stopping Solr service..."
|
||||
sudo systemctl stop solr
|
||||
|
||||
echo "Enabling Solr service to start on boot..."
|
||||
sudo systemctl enable solr
|
||||
|
||||
echo "SOLR has been configured"
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Install Transform dependencies"
|
||||
sudo apt-get update &&
|
||||
sudo apt install -y imagemagick &&
|
||||
sudo apt install -y libreoffice &&
|
||||
sudo apt install -y exiftool
|
||||
|
||||
curl -L -o /tmp/alfresco-pdf-renderer-1.2-linux.tgz https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-pdf-renderer/1.2/alfresco-pdf-renderer-1.2-linux.tgz &&
|
||||
sudo tar xf /tmp/alfresco-pdf-renderer-1.2-linux.tgz -C /usr/bin
|
||||
|
||||
echo "Configure Transform server"
|
||||
mkdir /home/ubuntu/transform
|
||||
cp downloads/alfresco-transform-core-aio-5.1.0.jar /home/ubuntu/transform
|
||||
|
||||
# Variables
|
||||
TRANSFORM_USER=ubuntu
|
||||
TRANSFORM_GROUP=ubuntu
|
||||
TRANSFORM_HOME=/home/ubuntu/transform
|
||||
|
||||
echo "Creating Transform systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/transform.service
|
||||
[Unit]
|
||||
Description=Transform Application Container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
User=$TRANSFORM_USER
|
||||
Group=$TRANSFORM_GROUP
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
Environment="LIBREOFFICE_HOME=/usr/lib/libreoffice"
|
||||
|
||||
ExecStart=java -jar /home/ubuntu/transform/alfresco-transform-core-aio-5.1.0.jar
|
||||
ExecStop=/bin/kill -15 $MAINPID
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Transform service..."
|
||||
sudo systemctl start transform
|
||||
|
||||
echo "Stopping Transform service..."
|
||||
sudo systemctl stop transform
|
||||
|
||||
echo "Enabling Transform service to start on boot..."
|
||||
sudo systemctl enable transform
|
||||
|
||||
echo "Transform has been configured"
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Install Node.js and npm (LTS version)
|
||||
echo "Installing Node.js and npm..."
|
||||
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
|
||||
sudo apt install -y nodejs
|
||||
|
||||
# Verify Node.js and npm installation
|
||||
echo "Verifying Node.js and npm installation..."
|
||||
node -v
|
||||
npm -v
|
||||
|
||||
# Clone the Alfresco Content App repository
|
||||
git clone https://github.com/Alfresco/alfresco-content-app.git
|
||||
cd alfresco-content-app
|
||||
|
||||
# Checkout to the specific version 4.4.1
|
||||
git checkout tags/4.4.1 -b 4.4.1
|
||||
|
||||
# Install project dependencies
|
||||
npm install
|
||||
|
||||
# Build the application for production
|
||||
npm run build
|
||||
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit script on any error
|
||||
set -e
|
||||
|
||||
# Update and upgrade the system
|
||||
echo "Updating system..."
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
|
||||
# Install Nginx
|
||||
echo "Installing Nginx..."
|
||||
sudo apt install -y nginx
|
||||
|
||||
# Create directory for the Alfresco Content App
|
||||
echo "Creating directory for Alfresco Content App..."
|
||||
sudo mkdir -p /var/www/alfresco-content-app
|
||||
sudo cp -r /home/ubuntu/alfresco-content-app/dist/content-ce/* /var/www/alfresco-content-app
|
||||
|
||||
echo "Creating nginx systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/nginx.service
|
||||
[Unit]
|
||||
Description=A high performance web server and a reverse proxy server
|
||||
Documentation=man:nginx(8)
|
||||
After=network.target remote-fs.target nss-lookup.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile=/run/nginx.pid
|
||||
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
|
||||
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
|
||||
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
|
||||
ExecStop=/bin/kill -s QUIT $MAINPID
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Enabling nginx service to start on boot..."
|
||||
sudo systemctl enable nginx
|
||||
|
||||
# Configure Nginx to serve the Alfresco Content App
|
||||
echo "Configuring Nginx..."
|
||||
cat <<EOL | sudo tee /etc/nginx/sites-available/alfresco-content-app
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
set \$allowOriginSite *;
|
||||
proxy_pass_request_headers on;
|
||||
proxy_pass_header Set-Cookie;
|
||||
|
||||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
proxy_set_header Host \$host:\$server_port;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_pass_header Set-Cookie;
|
||||
|
||||
root /var/www/alfresco-content-app;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files \$uri \$uri/ /index.html;
|
||||
}
|
||||
|
||||
location /alfresco/ {
|
||||
proxy_pass http://localhost:8080;
|
||||
}
|
||||
|
||||
location /share/ {
|
||||
proxy_pass http://localhost:8080;
|
||||
}
|
||||
}
|
||||
EOL
|
||||
|
||||
|
||||
# Enable the new Nginx configuration
|
||||
echo "Enabling Nginx configuration..."
|
||||
sudo ln -s /etc/nginx/sites-available/alfresco-content-app /etc/nginx/sites-enabled/
|
||||
sudo nginx -t
|
||||
sudo systemctl restart nginx
|
||||
|
||||
sudo systemctl stop nginx
|
||||
|
||||
# Instructions to transfer the built files
|
||||
echo "Nginx setup complete."
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
## RECOMMENDATION: run this sequence of commands manually, waiting between one command and the next one to ensure service dependencies are met.
|
||||
|
||||
echo "Starting postgresql"
|
||||
sudo systemctl start postgresql
|
||||
|
||||
echo "Starting activemq"
|
||||
sudo systemctl start activemq
|
||||
|
||||
echo "Starting transform"
|
||||
sudo systemctl start transform
|
||||
|
||||
echo "Starting tomcat"
|
||||
sudo systemctl start tomcat
|
||||
|
||||
echo "Starting solr"
|
||||
sudo systemctl start solr
|
||||
|
||||
echo "Starting nginx"
|
||||
sudo systemctl start nginx
|
||||
|
||||
|
||||
echo "Services have been started successfully!"
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+109
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Überprüfung des Betriebssystems
|
||||
function check_os() {
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
echo "Red Hat Derivat erkannt"
|
||||
OS="redhat"
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
echo "Debian/Ubuntu erkannt"
|
||||
OS="debian"
|
||||
else
|
||||
echo "Betriebssystem nicht unterstützt"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Automatische Ermittlung von Systeminformationen
|
||||
function get_system_info() {
|
||||
HOSTNAME=$(hostname)
|
||||
IP_ADDR=$(hostname -I | awk '{print $1}')
|
||||
CPU_CORES=$(nproc)
|
||||
TOTAL_MEM=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||
echo "Systeminformationen:"
|
||||
echo "Hostname: $HOSTNAME"
|
||||
echo "IP-Adresse: $IP_ADDR"
|
||||
echo "CPU-Kerne: $CPU_CORES"
|
||||
echo "Speicher (kB): $TOTAL_MEM"
|
||||
}
|
||||
|
||||
# Installation der notwendigen Pakete auf Debian/Ubuntu
|
||||
function install_debian_dependencies() {
|
||||
echo "Installiere Abhängigkeiten auf Debian/Ubuntu..."
|
||||
sudo apt update
|
||||
sudo apt install -y openjdk-11-jdk postgresql postgresql-contrib libreoffice curl wget unzip
|
||||
}
|
||||
|
||||
# Installation der notwendigen Pakete auf Red Hat Derivaten
|
||||
function install_redhat_dependencies() {
|
||||
echo "Installiere Abhängigkeiten auf Red Hat..."
|
||||
sudo yum update -y
|
||||
sudo yum install -y java-11-openjdk postgresql-server postgresql-contrib libreoffice curl wget unzip
|
||||
}
|
||||
|
||||
# Alfresco herunterladen
|
||||
function download_alfresco() {
|
||||
echo "Lade Alfresco herunter..."
|
||||
wget https://download.alfresco.com/cloudfront/release/community/202210-GA-build-411/alfresco-content-services-community-distribution-202210.zip -O alfresco.zip
|
||||
#wget https://nexus.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/alfresco-content-services-community-distribution/23.1.0/alfresco-content-services-community-distribution-23.1.0.zip -O alfresco.zip
|
||||
unzip alfresco.zip -d /opt/alfresco
|
||||
chmod -R 755 /opt/alfresco
|
||||
}
|
||||
|
||||
# Datenbank konfigurieren (PostgreSQL)
|
||||
function configure_database() {
|
||||
echo "Konfiguriere PostgreSQL..."
|
||||
sudo postgresql-setup initdb
|
||||
sudo systemctl start postgresql
|
||||
sudo systemctl enable postgresql
|
||||
sudo -u postgres psql -c "CREATE USER alfresco WITH PASSWORD 'alfresco';"
|
||||
sudo -u postgres psql -c "CREATE DATABASE alfresco WITH OWNER alfresco;"
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE alfresco TO alfresco;"
|
||||
}
|
||||
|
||||
# Alfresco konfigurieren
|
||||
function configure_alfresco() {
|
||||
echo "Konfiguriere Alfresco..."
|
||||
ALFRESCO_GLOBAL_PROPERTIES="/opt/alfresco/web-server/shared/classes/alfresco-global.properties"
|
||||
cp /opt/alfresco/web-server/shared/classes/alfresco-global.properties.sample $ALFRESCO_GLOBAL_PROPERTIES
|
||||
|
||||
cat <<EOL >> $ALFRESCO_GLOBAL_PROPERTIES
|
||||
db.driver=org.postgresql.Driver
|
||||
db.username=alfresco
|
||||
db.password=alfresco
|
||||
db.url=jdbc:postgresql://localhost:5432/alfresco
|
||||
alfresco.host=$IP_ADDR
|
||||
alfresco.port=8080
|
||||
share.host=$IP_ADDR
|
||||
share.port=8080
|
||||
index.subsystem.name=solr6
|
||||
EOL
|
||||
}
|
||||
|
||||
# Alfresco Dienst starten
|
||||
function start_alfresco() {
|
||||
echo "Starte Alfresco..."
|
||||
/opt/alfresco/alfresco.sh start
|
||||
}
|
||||
|
||||
# Hauptfunktion zur Installation und Konfiguration von Alfresco
|
||||
function install_alfresco() {
|
||||
check_os
|
||||
get_system_info
|
||||
|
||||
if [ "$OS" == "debian" ]; then
|
||||
install_debian_dependencies
|
||||
elif [ "$OS" == "redhat" ]; then
|
||||
install_redhat_dependencies
|
||||
fi
|
||||
|
||||
download_alfresco
|
||||
configure_database
|
||||
configure_alfresco
|
||||
start_alfresco
|
||||
|
||||
echo "Alfresco Installation und Konfiguration abgeschlossen!"
|
||||
}
|
||||
|
||||
# Skript starten
|
||||
install_alfresco
|
||||
+666
@@ -0,0 +1,666 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Detect the OS
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
OS="RHEL"
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
OS="Ubuntu"
|
||||
else
|
||||
echo "Unsupported OS"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#MAIN
|
||||
download_files() {
|
||||
# Array von URLs
|
||||
URLS=(
|
||||
"https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-content-services-community-distribution/23.2.1/alfresco-content-services-community-distribution-23.2.1.zip"
|
||||
"https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-search-services/2.0.9.1/alfresco-search-services-2.0.9.1.zip"
|
||||
"https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-transform-core-aio/5.1.0/alfresco-transform-core-aio-5.1.0.jar"
|
||||
)
|
||||
|
||||
# Verzeichnis, in das die Dateien heruntergeladen werden sollen
|
||||
DEST_DIR="/tmp/downloads"
|
||||
|
||||
# Erstelle das Verzeichnis, falls es nicht existiert
|
||||
mkdir -p "$DEST_DIR"
|
||||
|
||||
# Herunterladen der Dateien
|
||||
for URL in "${URLS[@]}"; do
|
||||
echo "Downloading $URL..."
|
||||
# Extrahiere den Dateinamen aus der URL
|
||||
FILE_NAME=$(basename "$URL")
|
||||
# Lade die Datei herunter und speichere sie im Zielverzeichnis
|
||||
curl -L "$URL" -o "$DEST_DIR/$FILE_NAME"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully downloaded $FILE_NAME"
|
||||
else
|
||||
echo "Failed to download $FILE_NAME"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Functions for RHEL
|
||||
install_postgresql_rhel() {
|
||||
echo "Updating package list..."
|
||||
sudo yum update -y
|
||||
|
||||
echo "Installing PostgreSQL 16..."
|
||||
#sudo yum install -y https://download.postgresql.org/pub/repos/yum/16/redhat/rhel-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
|
||||
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
|
||||
sudo dnf -qy module disable postgresql
|
||||
sudo yum install -y postgresql16-server postgresql16-contrib
|
||||
|
||||
echo "Initializing PostgreSQL database..."
|
||||
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
|
||||
|
||||
echo "Enable local connections"
|
||||
sudo sed -i 's/peer/trust/' /var/lib/pgsql/16/data/pg_hba.conf
|
||||
sudo sed -i 's/ident/md5/' /var/lib/pgsql/16/data/pg_hba.conf
|
||||
|
||||
echo "Starting PostgreSQL service..."
|
||||
sudo systemctl start postgresql-16
|
||||
|
||||
echo "Configuring Alfresco database..."
|
||||
sudo -u postgres psql -c "CREATE USER alfresco WITH PASSWORD 'alfresco';"
|
||||
sudo -u postgres psql -c "CREATE DATABASE alfresco OWNER alfresco ENCODING 'UTF8';"
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE alfresco TO alfresco;"
|
||||
|
||||
echo "Stopping PostgreSQL service..."
|
||||
sudo systemctl stop postgresql-16
|
||||
|
||||
echo "Enabling PostgreSQL to start on boot..."
|
||||
sudo systemctl enable postgresql-16
|
||||
|
||||
echo "PostgreSQL installation and setup completed successfully!"
|
||||
}
|
||||
install_java_rhel() {
|
||||
echo "Updating package list..."
|
||||
sudo dnf update -y
|
||||
|
||||
echo "Installing the latest Java JDK and development tools..."
|
||||
# Install Java JDK and development tools (java-17-openjdk and java-17-openjdk-devel)
|
||||
sudo dnf install -y java-17-openjdk java-17-openjdk-devel
|
||||
|
||||
echo "Setting Java as the default version..."
|
||||
# Update alternatives to ensure the correct Java version is used
|
||||
sudo alternatives --install /usr/bin/java java /usr/lib/jvm/java-17-openjdk-*/bin/java 1
|
||||
sudo alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-17-openjdk-*/bin/javac 1
|
||||
|
||||
echo "Checking the installed Java version..."
|
||||
java -version
|
||||
|
||||
# Automatically select the correct version
|
||||
echo "Selecting the Java alternative..."
|
||||
# Hier die Nummer der gewünschten Java-Version setzen. Ersetze "1" durch die entsprechende Nummer.
|
||||
echo "1" | sudo alternatives --config java
|
||||
|
||||
echo "Selecting the javac alternative..."
|
||||
# Hier die Nummer der gewünschten javac-Version setzen. Ersetze "1" durch die entsprechende Nummer.
|
||||
echo "1" | sudo alternatives --config javac
|
||||
|
||||
echo "Verifying Java installation..."
|
||||
java -version
|
||||
javac -version
|
||||
|
||||
echo "Java JDK installation and setup completed successfully!"
|
||||
}
|
||||
install_tomcat_rhel() {
|
||||
# Tomcat installation for RHEL
|
||||
echo "Updating package list..."
|
||||
sudo yum update -y
|
||||
|
||||
echo "Installing Tomcat 10..."
|
||||
sudo yum install -y tomcat tomcat-webapps tomcat-admin-webapps
|
||||
|
||||
echo "Starting Tomcat service..."
|
||||
sudo systemctl start tomcat
|
||||
|
||||
echo "Enabling Tomcat to start on boot..."
|
||||
sudo systemctl enable tomcat
|
||||
|
||||
echo "Tomcat installation and setup completed successfully!"
|
||||
}
|
||||
install_activemq_rhel() {
|
||||
echo "Updating package list..."
|
||||
sudo yum update -y
|
||||
|
||||
echo "Downloading ActiveMQ..."
|
||||
wget https://dlcdn.apache.org/activemq/6.1.3/apache-activemq-6.1.3-bin.tar.gz -O /tmp/apache-activemq-6.1.3-bin.tar.gz
|
||||
|
||||
echo "Extracting ActiveMQ..."
|
||||
sudo mkdir /opt/activemq
|
||||
sudo tar xzvf /tmp/apache-activemq-6.1.3-bin.tar.gz -C /opt/activemq --strip-components=1
|
||||
|
||||
echo "Setting permissions for ActiveMQ directories..."
|
||||
sudo useradd activemq
|
||||
sudo chown -R activemq:activemq /opt/activemq
|
||||
sudo chmod -R 755 /opt/activemq
|
||||
|
||||
echo "Creating ActiveMQ systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/activemq.service
|
||||
[Unit]
|
||||
Description=Apache ActiveMQ
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
User=activemq
|
||||
Group=activemq
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
Environment="ACTIVEMQ_HOME=/opt/activemq"
|
||||
Environment="ACTIVEMQ_BASE=/opt/activemq"
|
||||
Environment="ACTIVEMQ_CONF=/opt/activemq/conf"
|
||||
Environment="ACTIVEMQ_DATA=/opt/activemq/data"
|
||||
|
||||
ExecStart=/opt/activemq/bin/activemq start
|
||||
ExecStop=/opt/activemq/bin/activemq stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting ActiveMQ service..."
|
||||
sudo systemctl start activemq
|
||||
|
||||
echo "Enabling ActiveMQ service to start on boot..."
|
||||
sudo systemctl enable activemq
|
||||
|
||||
echo "Apache ActiveMQ installation and setup completed successfully!"
|
||||
}
|
||||
install_alfresco_rhel(){
|
||||
|
||||
echo "Create support folders and configuration in Tomcat"
|
||||
mkdir -p /etc/tomcat/shared/classes && mkdir -p /etc/tomcat/shared/lib
|
||||
sed -i 's|^shared.loader=$|shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar|' /etc/tomcat/catalina.properties
|
||||
|
||||
echo "Unzip Alfresco ZIP Distribution File"
|
||||
mkdir /tmp/downloads/alfresco
|
||||
|
||||
echo "Copy JDBC driver"
|
||||
cp /tmp/downloads/alfresco/web-server/lib/postgresql-42.6.0.jar /etc/tomcat/shared/lib/
|
||||
|
||||
echo "Configure JAR Addons deployment"
|
||||
mkdir -p /etc/modules/platform && mkdir -p /opt/modules/share && mkdir -p /opt/tomcat/conf/Catalina/localhost
|
||||
cp /tmp/downloads/alfresco/web-server/conf/Catalina/localhost/* /opt/tomcat/conf/Catalina/localhost/
|
||||
|
||||
echo "Install Web Applications"
|
||||
cp /tmp/downloads/alfresco/web-server/webapps/* /etc/tomcat/webapps/
|
||||
|
||||
echo "Apply configuration"
|
||||
cp -r /tmp/downloads/alfresco/web-server/shared/classes/* /etc/tomcat/shared/classes/
|
||||
mkdir /opt/keystore && cp -r /tmp/downloads/alfresco/keystore/* /opt/keystore/
|
||||
mkdir /opt/alf_data
|
||||
cat <<EOL | tee /etc/tomcat/shared/classes/alfresco-global.properties
|
||||
#
|
||||
# Custom content and index data location
|
||||
#
|
||||
dir.root=/opt/alf_data
|
||||
dir.keystore=/opt/keystore/
|
||||
|
||||
#
|
||||
# Database connection properties
|
||||
#
|
||||
db.username=alfresco
|
||||
db.password=alfresco
|
||||
db.driver=org.postgresql.Driver
|
||||
db.url=jdbc:postgresql://localhost:5432/alfresco
|
||||
|
||||
#
|
||||
# Solr Configuration
|
||||
#
|
||||
solr.secureComms=secret
|
||||
solr.sharedSecret=secret
|
||||
solr.host=localhost
|
||||
solr.port=8983
|
||||
index.subsystem.name=solr6
|
||||
|
||||
#
|
||||
# Transform Configuration
|
||||
#
|
||||
localTransform.core-aio.url=http://localhost:8090/
|
||||
|
||||
#
|
||||
# Events Configuration
|
||||
#
|
||||
messaging.broker.url=failover:(nio://localhost:61616)?timeout=3000&jms.useCompression=true
|
||||
|
||||
#
|
||||
# URL Generation Parameters
|
||||
#-------------
|
||||
alfresco.context=alfresco
|
||||
alfresco.host=localhost
|
||||
alfresco.port=8080
|
||||
alfresco.protocol=http
|
||||
share.context=share
|
||||
share.host=localhost
|
||||
share.port=8080
|
||||
share.protocol=http
|
||||
EOL
|
||||
|
||||
echo "Apply AMPs"
|
||||
mkdir /opt/amps && cp -r /tmp/downloads/alfresco/amps/* /opt/amps/
|
||||
mkdir /opt/bin && cp -r /tmp/downloads/alfresco/bin/* /opt/bin/
|
||||
java -jar /opt/bin/alfresco-mmt.jar install /opt/amps /etc/tomcat/webapps/alfresco.war -directory
|
||||
java -jar /opt/bin/alfresco-mmt.jar list /etc/tomcat/webapps/alfresco.war
|
||||
|
||||
echo "Modify alfresco and share logs directory"
|
||||
mkdir /etc/tomcat/webapps/alfresco && unzip /etc/tomcat/webapps/alfresco.war -d /etc/tomcat/webapps/alfresco
|
||||
mkdir /etc/tomcat/webapps/share && unzip /etc/tomcat/webapps/share.war -d /etc/tomcat/webapps/share
|
||||
sed -i 's|^appender\.rolling\.fileName=alfresco\.log|appender.rolling.fileName=/opt/tomcat/logs/alfresco.log|' /etc/tomcat/webapps/alfresco/WEB-INF/classes/log4j2.properties
|
||||
sed -i 's|^appender\.rolling\.fileName=share\.log|appender.rolling.fileName=/opt/tomcat/logs/share.log|' /etc/tomcat/webapps/share/WEB-INF/classes/log4j2.properties
|
||||
|
||||
|
||||
echo "Alfresco has been configured"
|
||||
}
|
||||
|
||||
install_solr_rhel() {
|
||||
echo "Unzip SOLR ZIP Distribution File"
|
||||
mkdir /tmp/solr
|
||||
unzip /tmp/downloads/alfresco-search-services-2.0.9.1.zip -d /tmp/solr
|
||||
mv /tmp/solr/alfresco-search-services /opt/solr/alfresco-search-services
|
||||
echo "creating user ..."
|
||||
sudo useradd solr
|
||||
echo "Creating SOLR systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/solr.service
|
||||
[Unit]
|
||||
Description=Apache SOLR Web Application Container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
User=solr
|
||||
Group=solr
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk"
|
||||
|
||||
ExecStart=/opt/solr/alfresco-search-services/solr/bin/solr start -a "-Dcreate.alfresco.defaults=alfresco,archive -Dalfresco.secureComms=secret -Dalfresco.secureComms.secret=secret"
|
||||
ExecStop=/opt/solr/alfresco-search-services/solr/bin/solr stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "SELinux anpassungen werden durchgeführt...."
|
||||
ausearch -c '(solr)' --raw | audit2allow -M my-solr
|
||||
semodule -X 300 -i my-solr.pp
|
||||
|
||||
echo "Permission für für solr werden gesetzt...."
|
||||
chmod -R 755 /opt/solr/alfresco-search-services/solr/server/../../logs
|
||||
chown -R solr:solr /opt/solr/alfresco-search-services/solr/server/../../logs
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Solr service..."
|
||||
sudo systemctl start solr
|
||||
|
||||
echo "Enabling Solr service to start on boot..."
|
||||
sudo systemctl enable solr
|
||||
|
||||
echo "SOLR has been configured"
|
||||
}
|
||||
|
||||
install_transform_rhel() {
|
||||
echo "Install Repo Dependency..."
|
||||
sudo subscription-manager repos --enable codeready-builder-for-rhel-8-$(arch)-rpms
|
||||
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
|
||||
|
||||
echo "Install Transform dependencies"
|
||||
sudo dnf install -y GraphicsMagick libreoffice perl-Image-ExifTool
|
||||
|
||||
curl -L -o /tmp/downloads/alfresco-pdf-renderer-1.2-linux.tgz https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-pdf-renderer/1.2/alfresco-pdf-renderer-1.2-linux.tgz
|
||||
sudo tar xf /tmp/downloads/alfresco-pdf-renderer-1.2-linux.tgz -C /usr/bin
|
||||
|
||||
echo "Configure Transform server"
|
||||
mkdir /opt/transform
|
||||
cp /tmp/downloads/alfresco-transform-core-aio-5.1.0.jar /opt/transform
|
||||
|
||||
echo " User wird angelegt..."
|
||||
sudo useradd transform
|
||||
|
||||
echo "Creating Transform systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/transform.service
|
||||
|
||||
[Unit]
|
||||
Description=Transform Application Container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
User=transform
|
||||
Group=transform
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk"
|
||||
Environment="LIBREOFFICE_HOME=/usr/lib/libreoffice"
|
||||
|
||||
ExecStart=java -jar /opt/transform/alfresco-transform-core-aio-5.1.0.jar
|
||||
ExecStop=/bin/kill -15 $MAINPID
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Transform service..."
|
||||
sudo systemctl start transform
|
||||
|
||||
echo "Enabling Transform service to start on boot..."
|
||||
sudo systemctl enable transform
|
||||
|
||||
echo "Transform has been configured"
|
||||
}
|
||||
|
||||
install_nginx_rhel() {
|
||||
echo "Updating system..."
|
||||
sudo yum update -y
|
||||
|
||||
echo "Installing Nginx..."
|
||||
sudo yum install -y nginx
|
||||
|
||||
echo "Creating directory for Alfresco Content App..."
|
||||
sudo mkdir -p /var/www/alfresco-content-app
|
||||
sudo cp -r /tmp/downloads/alfresco-content-app/dist/content-ce/* /var/www/alfresco-content-app
|
||||
|
||||
echo "Creating nginx systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/nginx.service
|
||||
[Unit]
|
||||
Description=NGINX web server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
ExecStart=/usr/sbin/nginx
|
||||
ExecReload=/usr/sbin/nginx -s reload
|
||||
ExecStop=/usr/sbin/nginx -s stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Nginx service..."
|
||||
sudo systemctl start nginx
|
||||
|
||||
echo "Enabling Nginx to start on boot..."
|
||||
sudo systemctl enable nginx
|
||||
|
||||
echo "Nginx installation and configuration completed successfully!"
|
||||
}
|
||||
|
||||
# Functions for Ubuntu
|
||||
install_postgresql_ubuntu() {
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Installing PostgreSQL 16..."
|
||||
sudo apt install -y wget ca-certificates
|
||||
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs) pgdg" | sudo tee /etc/apt/sources.list.d/pgdg.list
|
||||
sudo apt update
|
||||
sudo apt install -y postgresql-16 postgresql-client-16
|
||||
|
||||
echo "Enable local connections"
|
||||
sudo sed -i 's/peer/trust/' /etc/postgresql/16/main/pg_hba.conf
|
||||
sudo sed -i 's/ident/md5/' /etc/postgresql/16/main/pg_hba.conf
|
||||
|
||||
echo "Starting PostgreSQL service..."
|
||||
sudo systemctl start postgresql
|
||||
|
||||
echo "Configuring Alfresco database..."
|
||||
sudo -u postgres psql -c "CREATE USER alfresco WITH PASSWORD 'alfresco';"
|
||||
sudo -u postgres psql -c "CREATE DATABASE alfresco OWNER alfresco ENCODING 'UTF8';"
|
||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE alfresco TO alfresco;"
|
||||
|
||||
echo "Stopping PostgreSQL service..."
|
||||
sudo systemctl stop postgresql
|
||||
|
||||
echo "Enabling PostgreSQL to start on boot..."
|
||||
sudo systemctl enable postgresql
|
||||
|
||||
echo "PostgreSQL installation and setup completed successfully!"
|
||||
}
|
||||
|
||||
install_java_ubuntu() {
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Installing Java JDK 17..."
|
||||
sudo apt install -y openjdk-17-jdk
|
||||
|
||||
echo "Checking Java version..."
|
||||
java -version
|
||||
|
||||
echo "Java JDK 17 installation and setup completed successfully!"
|
||||
}
|
||||
|
||||
install_tomcat_ubuntu() {
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Installing Tomcat 10..."
|
||||
sudo apt install -y tomcat10 tomcat10-admin tomcat10-common tomcat10-examples
|
||||
|
||||
echo "Starting Tomcat service..."
|
||||
sudo systemctl start tomcat10
|
||||
|
||||
echo "Enabling Tomcat to start on boot..."
|
||||
sudo systemctl enable tomcat10
|
||||
|
||||
echo "Tomcat installation and setup completed successfully!"
|
||||
}
|
||||
|
||||
install_activemq_ubuntu() {
|
||||
echo "Updating package list..."
|
||||
sudo apt update
|
||||
|
||||
echo "Downloading ActiveMQ..."
|
||||
wget https://dlcdn.apache.org/activemq/5.18.5/apache-activemq-5.18.5-bin.tar.gz -O /tmp/apache-activemq-5.18.5-bin.tar.gz
|
||||
|
||||
echo "Extracting ActiveMQ..."
|
||||
sudo mkdir -p /home/ubuntu/activemq
|
||||
sudo tar xzvf /tmp/apache-activemq-5.18.5-bin.tar.gz -C /home/ubuntu/activemq --strip-components=1
|
||||
|
||||
echo "Setting permissions for ActiveMQ directories..."
|
||||
sudo chown -R ubuntu:ubuntu /home/ubuntu/activemq
|
||||
sudo chmod -R 755 /home/ubuntu/activemq
|
||||
|
||||
echo "Creating ActiveMQ systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/activemq.service
|
||||
[Unit]
|
||||
Description=Apache ActiveMQ
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
User=ubuntu
|
||||
Group=ubuntu
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
Environment="ACTIVEMQ_HOME=/home/ubuntu/activemq"
|
||||
Environment="ACTIVEMQ_BASE=/home/ubuntu/activemq"
|
||||
Environment="ACTIVEMQ_CONF=/home/ubuntu/activemq/conf"
|
||||
Environment="ACTIVEMQ_DATA=/home/ubuntu/activemq/data"
|
||||
|
||||
ExecStart=/home/ubuntu/activemq/bin/activemq start
|
||||
ExecStop=/home/ubuntu/activemq/bin/activemq stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting ActiveMQ service..."
|
||||
sudo systemctl start activemq
|
||||
|
||||
echo "Enabling ActiveMQ service to start on boot..."
|
||||
sudo systemctl enable activemq
|
||||
|
||||
echo "Apache ActiveMQ installation and setup completed successfully!"
|
||||
}
|
||||
|
||||
install_solr_ubuntu() {
|
||||
echo "Unzip SOLR ZIP Distribution File"
|
||||
mkdir /tmp/solr
|
||||
unzip downloads/alfresco-search-services-2.0.9.1.zip -d /tmp/solr
|
||||
mv /tmp/solr/alfresco-search-services /home/ubuntu
|
||||
|
||||
echo "Creating SOLR systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/solr.service
|
||||
[Unit]
|
||||
Description=Apache SOLR Web Application Container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
User=ubuntu
|
||||
Group=ubuntu
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
|
||||
ExecStart=/home/ubuntu/alfresco-search-services/solr/bin/solr start -a "-Dcreate.alfresco.defaults=alfresco,archive -Dalfresco.secureComms=secret -Dalfresco.secureComms.secret=secret"
|
||||
ExecStop=/home/ubuntu/alfresco-search-services/solr/bin/solr stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Solr service..."
|
||||
sudo systemctl start solr
|
||||
|
||||
echo "Enabling Solr service to start on boot..."
|
||||
sudo systemctl enable solr
|
||||
|
||||
echo "SOLR has been configured"
|
||||
}
|
||||
|
||||
install_transform_ubuntu() {
|
||||
echo "Install Transform dependencies"
|
||||
sudo apt install -y imagemagick libreoffice exiftool
|
||||
|
||||
curl -L -o /tmp/alfresco-pdf-renderer-1.2-linux.tgz https://nexus.alfresco.com/nexus/repository/releases/org/alfresco/alfresco-pdf-renderer/1.2/alfresco-pdf-renderer-1.2-linux.tgz
|
||||
sudo tar xf /tmp/alfresco-pdf-renderer-1.2-linux.tgz -C /usr/bin
|
||||
|
||||
echo "Configure Transform server"
|
||||
mkdir /home/ubuntu/transform
|
||||
cp downloads/alfresco-transform-core-aio-5.1.0.jar /home/ubuntu/transform
|
||||
|
||||
echo "Creating Transform systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/transform.service
|
||||
[Unit]
|
||||
Description=Transform Application Container
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
User=ubuntu
|
||||
Group=ubuntu
|
||||
|
||||
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
|
||||
Environment="LIBREOFFICE_HOME=/usr/lib/libreoffice"
|
||||
|
||||
ExecStart=java -jar /home/ubuntu/transform/alfresco-transform-core-aio-5.1.0.jar
|
||||
ExecStop=/bin/kill -15 $MAINPID
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Transform service..."
|
||||
sudo systemctl start transform
|
||||
|
||||
echo "Enabling Transform service to start on boot..."
|
||||
sudo systemctl enable transform
|
||||
|
||||
echo "Transform has been configured"
|
||||
}
|
||||
|
||||
install_nginx_ubuntu() {
|
||||
echo "Updating system..."
|
||||
sudo apt update
|
||||
|
||||
echo "Installing Nginx..."
|
||||
sudo apt install -y nginx
|
||||
|
||||
echo "Creating directory for Alfresco Content App..."
|
||||
sudo mkdir -p /var/www/alfresco-content-app
|
||||
sudo cp -r /home/ubuntu/alfresco-content-app/dist/content-ce/* /var/www/alfresco-content-app
|
||||
|
||||
echo "Creating nginx systemd service file..."
|
||||
cat <<EOL | sudo tee /etc/systemd/system/nginx.service
|
||||
[Unit]
|
||||
Description=NGINX web server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
|
||||
ExecStart=/usr/sbin/nginx
|
||||
ExecReload=/usr/sbin/nginx -s reload
|
||||
ExecStop=/usr/sbin/nginx -s stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
echo "Reloading systemd daemon..."
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
echo "Starting Nginx service..."
|
||||
sudo systemctl start nginx
|
||||
|
||||
echo "Enabling Nginx to start on boot..."
|
||||
sudo systemctl enable nginx
|
||||
|
||||
echo "Nginx installation and configuration completed successfully!"
|
||||
}
|
||||
|
||||
# Run the appropriate installation based on the OS
|
||||
if [ "$OS" == "RHEL" ]; then
|
||||
#download_files
|
||||
#install_postgresql_rhel
|
||||
#install_java_rhel
|
||||
#install_tomcat_rhel
|
||||
#install_activemq_rhel
|
||||
install_alfresco_rhel
|
||||
#install_solr_rhel
|
||||
#install_transform_rhel
|
||||
#install_nginx_rhel
|
||||
elif [ "$OS" == "Ubuntu" ]; then
|
||||
download_files
|
||||
install_postgresql_ubuntu
|
||||
install_java_ubuntu
|
||||
install_tomcat_ubuntu
|
||||
install_activemq_ubuntu
|
||||
install_solr_ubuntu
|
||||
install_transform_ubuntu
|
||||
install_nginx_ubuntu
|
||||
else
|
||||
echo "Unsupported OS"
|
||||
fi
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Farben für die Ausgabe
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Funktion zur Überprüfung des Linux-Derivats
|
||||
check_distro() {
|
||||
if [ -f /etc/debian_version ]; then
|
||||
echo "Debian/Ubuntu erkannt."
|
||||
DISTRO="debian"
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
echo "RedHat/CentOS erkannt."
|
||||
DISTRO="redhat"
|
||||
else
|
||||
echo -e "${RED}Unbekanntes Linux-Derivat. Das Skript unterstützt nur Debian/Ubuntu und RedHat/CentOS.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zur Installation von Openfire auf Debian/Ubuntu
|
||||
install_openfire_debian() {
|
||||
echo -e "${GREEN}Installation von Openfire auf Debian/Ubuntu...${NC}"
|
||||
wget -O openfire.deb https://www.igniterealtime.org/downloadServlet?filename=openfire/openfire_4.6.0_all.deb
|
||||
sudo dpkg -i openfire.deb
|
||||
sudo apt-get install -f -y # Um Abhängigkeiten zu installieren
|
||||
sudo systemctl enable openfire
|
||||
sudo systemctl start openfire
|
||||
}
|
||||
|
||||
# Funktion zur Installation von Openfire auf RedHat/CentOS
|
||||
install_openfire_redhat() {
|
||||
echo -e "${GREEN}Installation von Openfire auf RedHat/CentOS...${NC}"
|
||||
wget -O openfire.rpm https://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-4.6.0-1.noarch.rpm
|
||||
sudo yum install -y openfire.rpm
|
||||
sudo systemctl enable openfire
|
||||
sudo systemctl start openfire
|
||||
}
|
||||
|
||||
# Funktion zur Konfiguration als Publisher
|
||||
configure_publisher() {
|
||||
echo -e "${GREEN}Konfiguration als Publisher...${NC}"
|
||||
read -p "Geben Sie die JID des Publishers ein (z.B. publisher@deinserver.com): " PUBLISHER_JID
|
||||
read -sp "Geben Sie das Passwort des Publishers ein: " PUBLISHER_PASSWORD
|
||||
echo ""
|
||||
read -p "Geben Sie den PubSub-Server ein (z.B. pubsub.deinserver.com): " PUBSUB_SERVER
|
||||
read -p "Geben Sie den PubSub-Node ein (z.B. mynode): " PUBSUB_NODE
|
||||
|
||||
# Erstelle ein Bash-Skript für den Publisher
|
||||
cat <<EOL > publisher.sh
|
||||
#!/bin/bash
|
||||
|
||||
JID="$PUBLISHER_JID"
|
||||
PASSWORD="$PUBLISHER_PASSWORD"
|
||||
SERVER="$PUBSUB_SERVER"
|
||||
NODE="$PUBSUB_NODE"
|
||||
MESSAGE="Dies ist eine Testnachricht vom Publisher"
|
||||
|
||||
echo "\$MESSAGE" | sendxmpp -t -u "\$JID" -p "\$PASSWORD" -j "\$SERVER" "\$NODE"
|
||||
EOL
|
||||
|
||||
chmod +x publisher.sh
|
||||
echo -e "${GREEN}Publisher-Skript 'publisher.sh' erstellt.${NC}"
|
||||
}
|
||||
|
||||
# Funktion zur Konfiguration als Subscriber
|
||||
configure_subscriber() {
|
||||
echo -e "${GREEN}Konfiguration als Subscriber...${NC}"
|
||||
read -p "Geben Sie die JID des Subscribers ein (z.B. subscriber@deinserver.com): " SUBSCRIBER_JID
|
||||
read -sp "Geben Sie das Passwort des Subscribers ein: " SUBSCRIBER_PASSWORD
|
||||
echo ""
|
||||
read -p "Geben Sie den PubSub-Server ein (z.B. pubsub.deinserver.com): " PUBSUB_SERVER
|
||||
read -p "Geben Sie den PubSub-Node ein (z.B. mynode): " PUBSUB_NODE
|
||||
|
||||
# Erstelle ein Bash-Skript für den Subscriber
|
||||
cat <<EOL > subscriber.sh
|
||||
#!/bin/bash
|
||||
|
||||
JID="$SUBSCRIBER_JID"
|
||||
PASSWORD="$SUBSCRIBER_PASSWORD"
|
||||
SERVER="$PUBSUB_SERVER"
|
||||
NODE="$PUBSUB_NODE"
|
||||
|
||||
profanity --server "\$SERVER" --username "\$JID" --password "\$PASSWORD" --join "\$NODE"
|
||||
EOL
|
||||
|
||||
chmod +x subscriber.sh
|
||||
echo -e "${GREEN}Subscriber-Skript 'subscriber.sh' erstellt.${NC}"
|
||||
}
|
||||
|
||||
# Auswahlmenü für die Konfiguration
|
||||
show_menu() {
|
||||
echo -e "${GREEN}Openfire wurde erfolgreich installiert!${NC}"
|
||||
echo "Wählen Sie die gewünschte Rolle:"
|
||||
echo "1) Publisher konfigurieren"
|
||||
echo "2) Subscriber konfigurieren"
|
||||
echo "3) Abbrechen"
|
||||
|
||||
read -p "Option [1-3]: " OPTION
|
||||
case $OPTION in
|
||||
1)
|
||||
configure_publisher
|
||||
;;
|
||||
2)
|
||||
configure_subscriber
|
||||
;;
|
||||
3)
|
||||
echo -e "${RED}Abbruch.${NC}"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Ungültige Option.${NC}"
|
||||
show_menu
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Hauptskript
|
||||
check_distro
|
||||
|
||||
if [ "$DISTRO" == "debian" ]; then
|
||||
install_openfire_debian
|
||||
elif [ "$DISTRO" == "redhat" ]; then
|
||||
install_openfire_redhat
|
||||
fi
|
||||
|
||||
show_menu
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Funktion zur Installation erforderlicher Pakete
|
||||
install_packages() {
|
||||
local DISTRO=$1
|
||||
case $DISTRO in
|
||||
"debian"|"ubuntu")
|
||||
apt-get update
|
||||
apt-get install -y realmd samba-common samba-common-bin krb5-user sssd adcli packagekit
|
||||
;;
|
||||
"rhel"|"centos"|"fedora")
|
||||
yum install -y realmd samba samba-common samba-common-tools krb5-workstation sssd adcli
|
||||
;;
|
||||
"arch")
|
||||
pacman -Syu --noconfirm realmd samba krb5 sssd adcli
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported distribution: $DISTRO"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Funktion zum Joinen der Domäne
|
||||
join_domain() {
|
||||
local DOMAIN=$1
|
||||
local USER=$2
|
||||
local PASSWORD=$3
|
||||
|
||||
echo "Konfiguriere Domain-Join für Domain: $DOMAIN"
|
||||
|
||||
# Realm beitreten
|
||||
echo "$PASSWORD" | realm join --user="$USER" "$DOMAIN" --password
|
||||
|
||||
# Überprüfen, ob der Join erfolgreich war
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Domain join erfolgreich!"
|
||||
else
|
||||
echo "Fehler beim Domain Join."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Automatische Anmeldung aktivieren
|
||||
if [ -f /etc/pam.d/common-session ]; then
|
||||
sed -i 's/^.*pam_sssd.so/#&/' /etc/pam.d/common-session
|
||||
sed -i 's/^.*pam_sssd.so/#&/' /etc/pam.d/common-session-noninteractive
|
||||
sed -i '/common-session/a session required pam_mkhomedir.so skel=/etc/skel umask=0022' /etc/pam.d/common-session
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zur Erkennung der Distribution
|
||||
get_distro() {
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
echo "$ID"
|
||||
else
|
||||
echo "Unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# Hauptskript
|
||||
main() {
|
||||
if [ "$#" -ne 3 ]; then
|
||||
echo "Usage: $0 <domain> <username> <password>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local DOMAIN=$1
|
||||
local USER=$2
|
||||
local PASSWORD=$3
|
||||
|
||||
local DISTRO=$(get_distro)
|
||||
|
||||
install_packages "$DISTRO"
|
||||
join_domain "$DOMAIN" "$USER" "$PASSWORD"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Executable
+547
@@ -0,0 +1,547 @@
|
||||
#!/bin/bash
|
||||
# Variablen
|
||||
# Konfiguration für den Zugriff auf die Synology DiskStation
|
||||
SYNOLOGY_HOST="9.99.50.10"
|
||||
SYNOLOGY_USERNAME="Madzone"
|
||||
SYNOLOGY_PASSWORD="P@ssw0rd"
|
||||
SSH_PRIVATE_KEY="$HOME/.ssh/id_rsa_synology"
|
||||
host=$(nslookup 9.99.50.10)
|
||||
# Zielpfad für das Full-Chain-Zertifikat
|
||||
FULLCHAIN_CERT="fullchain.${HOST_FQDN}.crt"
|
||||
HOST_FQDN=$(hostname -f)
|
||||
HOST_NORMAL=$(hostname -s)
|
||||
DOMAIN=$(hostname -d)
|
||||
REMOTE_DIR="/volume1/HEIMLAN/HEIMLAN"
|
||||
NFS_MOUNT="/mnt/CSR"
|
||||
SSH_PRIVATE_KEY="$HOME/.ssh/id_rsa_synology"
|
||||
TMP="/tmp"
|
||||
|
||||
# Name der Zertifikatsdateien
|
||||
ROOT_CERT="CERT_HEIMLAN_RootCA.crt"
|
||||
SUBCA_CERT="CERT_HEIMLAN_SubCA.crt"
|
||||
SERVER_CERT="CERT_${HOST_FQDN}.crt"
|
||||
|
||||
# Globale Variablen für das Betriebssystem
|
||||
OS=""
|
||||
distro=""
|
||||
version=""
|
||||
codename=""
|
||||
|
||||
# Globale Variablen für OPENSSL
|
||||
CSR_DIR="/tmp"
|
||||
KEY_DIR="/tmp"
|
||||
SSL_DIR=""
|
||||
PKI_DIR=""
|
||||
|
||||
# Extrahiere OU (Organizational Unit) und O (Organization) und wandele sie in Großbuchstaben um
|
||||
OU=$(echo "${DOMAIN%%.*}" | tr '[:lower:]' '[:upper:]')
|
||||
O=$(echo "${DOMAIN#*.}" | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
# Read IP address dynamically from active network interface
|
||||
IP_ADDRESS=$(nmcli -t -f IP4.ADDRESS device show | awk -F: '{split($2,a,"/"); print a[1]; exit}')
|
||||
echo "IP Address: $IP_ADDRESS"
|
||||
|
||||
# GLobale SSH Variablen
|
||||
KEY_PATH="$HOME/.ssh/id_rsa_synology" # Pfad zum SSH-Schlüssel
|
||||
NAS_HOME="/var/services/homes/$SYNOLOGY_USERNAME" # Angepasstes Home-Verzeichnis auf der NAS
|
||||
dnf install sshpass nfs-utils -y
|
||||
|
||||
#*********************************************************************
|
||||
#echo "SSH KEY wird im System implemntiert..."
|
||||
#sudo ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_synology
|
||||
#echo "SSH KEY wurde Erfolgreich im System implemntiert"
|
||||
#echo "SSH Verbindung wird in die .ssh eingetragen...."
|
||||
#sudo ssh-copy-id -i ~/.ssh/id_rsa_synology.pub ${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}${SYNOLOGY_PASSWORD}
|
||||
#echo "SSH Verbindung wurde Erfolgreich in die .ssh eingetragen !!!"
|
||||
|
||||
|
||||
colourmsg(){
|
||||
echo -e "\033[0;36m$1\033[0m"
|
||||
}
|
||||
# Funktion zum Erstellen eines Ordners mit Unterordnern über SSH mit sshpass
|
||||
create_remote_folders() {
|
||||
|
||||
# SSH-Befehl zum Erstellen des Ordners mit Unterordnern mit sshpass
|
||||
echo sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CSR"
|
||||
sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CSR"
|
||||
echo sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CERT"
|
||||
sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/CERT"
|
||||
echo sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/KEY"
|
||||
sshpass -p $SYNOLOGY_PASSWORD ssh "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" "mkdir -p ${REMOTE_DIR}/${HOST_FQDN}/KEY"
|
||||
echo "Ordner ${REMOTE_DIR}/$HOST_FQDN/ wurde auf ${host} erstellt."
|
||||
}
|
||||
|
||||
# Funktion zum Erstellen von SSH-Schlüsseln
|
||||
generate_ssh_key() {
|
||||
if [ ! -f "$KEY_PATH" ]; then
|
||||
echo "Erstelle SSH-Schlüssel..."
|
||||
ssh-keygen -t rsa -b 4096 -N "" -f "$KEY_PATH"
|
||||
else
|
||||
echo "SSH-Schlüssel existieren bereits."
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren des öffentlichen Schlüssels zur NAS
|
||||
copy_ssh_key_to_nas() {
|
||||
echo "Kopiere den öffentlichen Schlüssel zur NAS..."
|
||||
#cat ${KEY_PATH}.pub | ssh -o StrictHostKeyChecking=no $SYNOLOGY_USERNAME@$SYNOLOGY_HOST "tee -a $NAS_HOME/.ssh/authorized_keys && chmod 600 $NAS_HOME/.ssh/authorized_keys"
|
||||
cat ${KEY_PATH}.pub | sshpass -p "$SYNOLOGY_PASSWORD" ssh -o StrictHostKeyChecking=no $SYNOLOGY_USERNAME@$SYNOLOGY_HOST "tee -a $NAS_HOME/.ssh/authorized_keys && chmod 600 $NAS_HOME/.ssh/authorized_keys"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Öffentlicher Schlüssel erfolgreich zur NAS kopiert."
|
||||
else
|
||||
echo "Fehler beim Kopieren des öffentlichen Schlüssels zur NAS."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren der Datei von der NAS zum lokalen Rechner
|
||||
copy_file_from_nas() {
|
||||
echo "Kopiere die Datei von der NAS zum lokalen Rechner..."
|
||||
scp -i "$KEY_PATH" $SYNOLOGY_USERNAME@SYNOLOGY_HOST:$NAS_HOME "$KEY_PATH"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Datei erfolgreich kopiert."
|
||||
else
|
||||
echo "Fehler beim Kopieren der Datei."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Funktion zum Ermitteln des Betriebssystems
|
||||
detect_os() {
|
||||
echo "Das installierte Derivat wird ermittelt...."
|
||||
OS=$(uname -s)
|
||||
|
||||
case $OS in
|
||||
Linux*)
|
||||
# Überprüfen, ob lsb_release verfügbar ist
|
||||
if command -v lsb_release &> /dev/null; then
|
||||
# Verwende lsb_release, wenn es verfügbar ist
|
||||
distro=$(lsb_release -si)
|
||||
version=$(lsb_release -sr)
|
||||
codename=$(lsb_release -sc)
|
||||
else
|
||||
# Überprüfe /etc/os-release
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
distro=$NAME
|
||||
version=$VERSION_ID
|
||||
codename=$VERSION_CODENAME
|
||||
# Überprüfe /etc/lsb-release
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
. /etc/lsb-release
|
||||
distro=$DISTRIB_ID
|
||||
version=$DISTRIB_RELEASE
|
||||
codename=$DISTRIB_CODENAME
|
||||
# Überprüfe /etc/debian_version
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
distro="Debian"
|
||||
version=$(cat /etc/debian_version)
|
||||
codename=$(uname -r)
|
||||
# Überprüfe /etc/redhat-release
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
distro=$(cat /etc/redhat-release)
|
||||
version=$(uname -r)
|
||||
codename=$(uname -r)
|
||||
else
|
||||
distro="Unbekannte Distribution"
|
||||
version="Unbekannte Version"
|
||||
codename="Unbekannter Codename"
|
||||
fi
|
||||
fi
|
||||
# Ausgabe der ermittelten Informationen
|
||||
echo "\n\n"
|
||||
echo "Distribution: $distro"
|
||||
echo "Version: $version"
|
||||
echo "Codename: $codename"
|
||||
echo "\n\n"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OS: $OS"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${distro} wurde ....... Ausgewählt......."
|
||||
}
|
||||
install_requierments(){
|
||||
echo "Erstellen des Zertifikatsrequests..."
|
||||
echo " Funktion create_certificate_request() wert der Variable distro: $distro"
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
echo "" Alle Noetigen Kompomenten werden Installiert....
|
||||
apt install sudo sshpass nfs-common -y
|
||||
;;
|
||||
CentOS)
|
||||
echo "" Alle Noetigen Kompomenten werden Installiert....
|
||||
dnf install sudo sshpass nfs-utils -y
|
||||
;;
|
||||
"Red Hat Enterprise Linux")
|
||||
echo "" Alle Noetigen Kompomenten werden Installiert....
|
||||
dnf install sudo sshpass nfs-utils -y
|
||||
;;
|
||||
*)
|
||||
echo "Das Betriebssystem wird nicht unterstützt für Zertifikatsrequest.";;
|
||||
esac
|
||||
}
|
||||
# Funktion zum Erstellen des Zertifikatsrequests
|
||||
create_certificate_request() {
|
||||
echo "Erstellen des Zertifikatsrequests..."
|
||||
echo " Funktion create_certificate_request() wert der Variable distro: $distro"
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
apt install sudo sshpass nfs-common -y
|
||||
# Debian / Ubuntu spezifische Pfade
|
||||
#KEY_DIR="/etc/ssl/private/"
|
||||
# Erstellen des privaten Schlüssels
|
||||
openssl genrsa -out "${KEY_DIR}/KEY_${HOST_FQDN}.pem" 4096
|
||||
echo "Privater Schlüssel wurde erstellt: private.key"
|
||||
# CSR erstellen
|
||||
#CSR_DIR="/tmp"
|
||||
openssl req -new -key "${KEY_DIR}/KEY_${HOST_FQDN}.pem" -out "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -subj "/C=DE/ST=TH/L=ILM/O=${O}/OU=${OU}/CN=${HOST_FQDN}/emailAddress=admin@$DOMAIN"
|
||||
echo "Zertifikatsrequest wurde erstellt: request.csr"
|
||||
# CSR anzeigen
|
||||
echo "Inhalt des erstellten Zertifikatsrequests: DEBIAN|UBUNTU......."
|
||||
openssl req -in "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -text -noout
|
||||
;;
|
||||
CentOS)
|
||||
# CentOS spezifische Pfade
|
||||
#KEY_DIR="/etc/pki/tls/private/"
|
||||
# Erstellen des privaten Schlüssels
|
||||
openssl genrsa -out "${KEY_DIR}KEY_${HOST_FQDN}.pem" 4096
|
||||
echo "Privater Schlüssel wurde erstellt und gespeichert unter: ${KEY_DIR}KEY_${HOST_FQDN}.key"
|
||||
# CSR erstellen
|
||||
#CSR_DIR="/tmp"
|
||||
openssl req -new -key "${KEY_DIR}/KEY_${HOST_FQDN}.pem" -out "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -subj "/C=DE/ST=TH/L=ILM/O=HEIMLAN/OU=HEIMLAN/CN=${HOST_FQDN}/emailAddress=admin@$DOMAIN"
|
||||
echo "Zertifikatsrequest wurde erstellt und gespeichert unter: ${CSR_DIR}/CSR_${HOST_FQDN}.csr"
|
||||
# CSR anzeigen
|
||||
echo "Inhalt des erstellten Zertifikatsrequests: CENTOS....."
|
||||
openssl req -in "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -text -noout
|
||||
;;
|
||||
"Red Hat Enterprise Linux")
|
||||
# CentOS spezifische Pfade
|
||||
#KEY_DIR="/etc/pki/tls/private/"
|
||||
# Erstellen des privaten Schlüssels
|
||||
openssl genrsa -out "${KEY_DIR}/KEY_${HOST_FQDN}.pem" 4096
|
||||
echo "Privater Schlüssel wurde erstellt und gespeichert unter: ${KEY_DIR}KEY_${HOST_FQDN}.key"
|
||||
# CSR erstellen
|
||||
#CSR_DIR="/tmp"
|
||||
openssl req -new -key "${KEY_DIR}/KEY_${HOST_FQDN}.pem" -out "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -subj "/C=DE/ST=TH/L=ILM/O=HEIMLAN/OU=HEIMLAN/CN=${HOST_FQDN}/emailAddress=admin@$DOMAIN"
|
||||
echo "Zertifikatsrequest wurde erstellt und gespeichert unter: ${CSR_DIR}/CSR_${HOST_FQDN}.csr"
|
||||
# CSR anzeigen
|
||||
echo "Inhalt des erstellten Zertifikatsrequests: RHEL ....."
|
||||
openssl req -in "${CSR_DIR}/CSR_${HOST_FQDN}.csr" -text -noout
|
||||
;;
|
||||
*)
|
||||
echo "Das Betriebssystem wird nicht unterstützt für Zertifikatsrequest.";;
|
||||
esac
|
||||
}
|
||||
|
||||
# Funktion zum Erstellen des SSH-Schlüsselpaars und Hinzufügen zur Synology
|
||||
setup_ssh_keys() {
|
||||
echo "=== Einrichten von SSH-Schlüsseln ==="
|
||||
|
||||
# Überprüfen, ob der private Schlüssel bereits vorhanden ist
|
||||
if [ ! -f "${SSH_PRIVATE_KEY}" ]; then
|
||||
echo "Erstelle SSH-Schlüsselpaar..."
|
||||
ssh-keygen -t rsa -b 4096 -f "${SSH_PRIVATE_KEY}" -N "" -C "Synology SSH key"
|
||||
echo "SSH-Schlüsselpaar wurde erstellt: ${SSH_PRIVATE_KEY}"
|
||||
else
|
||||
echo "SSH-Schlüsselpaar ist bereits vorhanden: ${SSH_PRIVATE_KEY}"
|
||||
fi
|
||||
|
||||
# SSH-Schlüssel zur Synology hinzufügen
|
||||
echo "Füge den öffentlichen Schlüssel zur Synology hinzu..."
|
||||
ssh-copy-id -i "${SSH_PRIVATE_KEY}.pub" "${SYNOLOGY_USER}@${SYNOLOGY_HOST}"
|
||||
echo "Öffentlicher Schlüssel wurde zur Synology hinzugefügt."
|
||||
}
|
||||
|
||||
# Funktion zum Hochladen des Requests zur Synology
|
||||
upload_certificate_request() {
|
||||
echo "Hochladen des Zertifikatsrequests zur Synology..."
|
||||
# Mounten der NFS-Freigabe mit Benutzername und Passwort
|
||||
sudo mkdir -p ${NFS_MOUNT}
|
||||
echo "sudo mkdir $NFS_MOUNT"
|
||||
#sudo mkdir -p ${NFS_MOUNT}
|
||||
#sleep 10
|
||||
#ls /mnt/CSR/
|
||||
#sudo mount -t nfs -o username="${SYNOLOGY_USER}",password="${SYNOLOGY_PASSWORD}" "${SYNOLOGY_HOST}:${REMOTE_DIR}/$HOST_NORMAL/CSR" "${NFS_MOUNT}"
|
||||
sudo mount -t nfs -o nfsvers=3 "${SYNOLOGY_HOST}:${REMOTE_DIR}" "${NFS_MOUNT}"
|
||||
ls -lha /mnt/CSR/
|
||||
#echo "TEST WARTE ZEIT 30 SEKUNDEN......"
|
||||
#sleep 30
|
||||
# Überprüfen, ob das Mount erfolgreich war
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "NFS-Freigabe erfolgreich eingebunden: ${NFS_MOUNT}"
|
||||
# Kopieren der Datei auf die NFS-Freigabe
|
||||
ls -lha /mnt/CSR/
|
||||
sleep 5
|
||||
sudo cp "${CSR_DIR}/CSR_${HOST_FQDN}.csr" "${NFS_MOUNT}/${HOST_FQDN}/CSR/"
|
||||
sudo cp "${KEY_DIR}/KEY_${HOST_FQDN}.pem" "${NFS_MOUNT}/${HOST_FQDN}/KEY/"
|
||||
sleep 5
|
||||
ls -lha /mnt/CSR/
|
||||
echo "Datei erfolgreich auf die NFS-Freigabe hochgeladen."
|
||||
#echo "2. TEST WARTE ZEIT 30 SEKUNDEN......"
|
||||
#sleep 30
|
||||
else
|
||||
echo "Fehler beim Einbinden der NFS-Freigabe: ${NFS_MOUNT}"
|
||||
fi
|
||||
echo "Zertifikatsrequest wurde zur Synology hochgeladen."
|
||||
}
|
||||
umountNFS(){
|
||||
# NFS-Freigabe wieder aushängen
|
||||
sudo umount "${NFS_MOUNT}"
|
||||
cd /mnt
|
||||
rmdir CSR/
|
||||
echo "NFS-Freigabe erfolgreich ausgehängt."
|
||||
}
|
||||
# Funktion zum Herunterladen von Root-Zertifikat, Sub-CA-Zertifikat und Server-Zertifikat
|
||||
download_certificates() {
|
||||
echo "Herunterladen von Root-Zertifikat, Sub-CA-Zertifikat und Server-Zertifikat..."
|
||||
echo "=== Überprüfen und Herunterladen der Datei von der Synology ==="
|
||||
|
||||
# SSH-Befehl, um die Existenz der Datei auf der Synology zu überprüfen
|
||||
ssh -i "$KEY_PATH" "${SYNOLOGY_USERNAME}@${SYNOLOGY_HOST}" test -f "${REMOTE_DIR}/${HOST_FQDN}/CERT/$SERVER_CERT"
|
||||
|
||||
# Prüfen des Rückgabewerts von test (-f) und Entscheidung treffen
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Datei CERT_${HOST_FQDN}.crt auf der Synology gefunden. Beginne mit dem Download..."
|
||||
cp "${NFS_MOUNT}/${HOST_FQDN}/CERT/$SERVER_CERT" "${TMP}/$SERVER_CERT"
|
||||
cp "${NFS_MOUNT}/RootCA/$ROOT_CERT" "${TMP}/$ROOT_CERT"
|
||||
cp "${NFS_MOUNT}/SubCA/$SUBCA_CERT" "${TMP}/$SUBCA_CERT"
|
||||
echo "Datei erfolgreich heruntergeladen nach ${TMP}"
|
||||
else
|
||||
#echo "Datei $SERVER_CERT nicht auf der Synology gefunden. Warte 300 Sekunden..."
|
||||
#sleep 300
|
||||
echo "Datei $SERVER_CERT nicht auf der Synology gefunden. Warte 300 Sekunden..."
|
||||
|
||||
# Timer mit Countdown anzeigen
|
||||
for ((i=300; i>0; i--)); do
|
||||
echo -ne "Noch $i Sekunden warten...\r"
|
||||
sleep 1
|
||||
done
|
||||
echo
|
||||
download_certificates # Rekursiver Aufruf, um erneut zu prüfen
|
||||
fi
|
||||
echo "Zertifikate wurden heruntergeladen."
|
||||
}
|
||||
|
||||
# Funktion zum Erstellen des Full-Chain-Zertifikats und Umbenennen
|
||||
create_fullchain_certificate() {
|
||||
echo "Erstellen des Full-Chain-Zertifikats..."
|
||||
# Zielpfad für das Full-Chain-Zertifikat
|
||||
FULLCHAIN_CERT="/tmp/fullchain.crt"
|
||||
|
||||
# Full-Chain-Zertifikat erstellen
|
||||
cat "$TMP/$SERVER_CERT" "$TMP/$SUBCA_CERT" "$TMP/$ROOT_CERT" > "$FULLCHAIN_CERT"
|
||||
|
||||
echo "Full-Chain-Zertifikat wurde erstellt: $FULLCHAIN_CERT"
|
||||
|
||||
# Server-Zertifikat nach Hostnamen benennen
|
||||
HOSTNAME=$(hostname)
|
||||
mv "$FULLCHAIN_CERT" "$TMP/fullchain_$HOST_FQDN.crt"
|
||||
|
||||
echo "Full-Chain-Zertifikat umbenannt zu fullchain_$HOST_FQDN.crt"
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren der Zertifikate in die richtigen Pfade je nach Derivat und Typ
|
||||
copy_certificates() {
|
||||
echo "Kopieren der Zertifikate in die richtigen Pfade..."
|
||||
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
# Debian / Ubuntu spezifische Pfade
|
||||
SSL_DIR="/usr/local/share/ca-certificates/"
|
||||
KEY_STORE="usr/local/share/ca-certificates/"
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR/$SERVER_CERT"
|
||||
# Server Key kopieren
|
||||
cp "$TMP/KEY_${HOST_FQDN}.pem" "$KEY_STORE/KEY_${HOST_FQDN}.pem"
|
||||
echo "Zertifikate wurden nach $SSL_DIR kopiert."
|
||||
update-ca-certificates
|
||||
;;
|
||||
CentOS|"Red Hat Enterprise Linux")
|
||||
# CentOS spezifische Pfade
|
||||
SSL_DIR="/etc/pki/tls/certs/"
|
||||
KEY_STORE="etc/pki/tls/private/"
|
||||
PKI_DIR="/etc/pki/ca-trust/source/anchors/"
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR/$ROOT_CERT"
|
||||
cp "$TMP/$ROOT_CERT" "$PKI_DIR/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR/$SUBCA_CERT"
|
||||
cp "$TMP/$SUBCA_CERT" "$PKI_DIR/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR/$SERVER_CERT"
|
||||
cp "$TMP/$SERVER_CERT" "$PKI_DIR/$SERVER_CERT"
|
||||
# Server Key kopieren
|
||||
cp "$TMP/KEY_${HOST_FQDN}.pem" "$KEY_STORE/KEY_${HOST_FQDN}.pem"
|
||||
echo "Zertifikate wurden nach $SSL_DIR und nach $PKI_DIR kopiert."
|
||||
update-ca-trust
|
||||
;;
|
||||
*)
|
||||
echo "Das Betriebssystem $OS wird nicht unterstützt für Zertifikate-Kopieren."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Funktion zum Kopieren der Zertifikate in die richtigen Pfade je nach WebServer Ty
|
||||
copy_web_certificates() {
|
||||
echo "Kopieren der Zertifikate in die richtigen Pfade und Aktualisieren der Konfigurationsdateien..."
|
||||
|
||||
case $distro in
|
||||
Debian|Ubuntu)
|
||||
# Debian / Ubuntu spezifische Pfade
|
||||
SSL_DIR_APACHE="/etc/ssl/certs/"
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
|
||||
# Prüfen, ob Apache installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/apache2/apache2.conf" ]; then
|
||||
SSL_DIR_APACHE="/etc/apache2/ssl/"
|
||||
fi
|
||||
|
||||
# Prüfen, ob Nginx installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
fi
|
||||
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_APACHE/$ROOT_CERT"
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_NGINX/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_APACHE/$SUBCA_CERT"
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_NGINX/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_CERT"
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_CERT"
|
||||
|
||||
echo "Zertifikate wurden nach $SSL_DIR_APACHE und $SSL_DIR_NGINX kopiert."
|
||||
|
||||
# Aktualisieren der Apache-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/apache2/apache2.conf" ]; then
|
||||
update_apache_config "$SSL_DIR_APACHE/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_KEY"
|
||||
fi
|
||||
|
||||
# Aktualisieren der Nginx-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
update_nginx_config "$SSL_DIR_NGINX/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_KEY"
|
||||
fi
|
||||
;;
|
||||
CentOS|"Red Hat Enterprise Linux")
|
||||
# CentOS spezifische Pfade
|
||||
SSL_DIR_APACHE="/etc/pki/tls/certs/"
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
|
||||
# Prüfen, ob Apache installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/httpd/conf/httpd.conf" ]; then
|
||||
SSL_DIR_APACHE="/etc/httpd/ssl/"
|
||||
fi
|
||||
|
||||
# Prüfen, ob Nginx installiert ist und den SSL-Pfad anpassen
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
SSL_DIR_NGINX="/etc/nginx/ssl/"
|
||||
fi
|
||||
|
||||
# Root-Zertifikat kopieren
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_APACHE/$ROOT_CERT"
|
||||
cp "$TMP/$ROOT_CERT" "$SSL_DIR_NGINX/$ROOT_CERT"
|
||||
# Sub-CA-Zertifikat kopieren
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_APACHE/$SUBCA_CERT"
|
||||
cp "$TMP/$SUBCA_CERT" "$SSL_DIR_NGINX/$SUBCA_CERT"
|
||||
# Server-Zertifikat kopieren
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_CERT"
|
||||
cp "$TMP/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_CERT"
|
||||
|
||||
echo "Zertifikate wurden nach $SSL_DIR_APACHE und $SSL_DIR_NGINX kopiert."
|
||||
|
||||
# Aktualisieren der Apache-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/httpd/conf/httpd.conf" ]; then
|
||||
update_apache_config "$SSL_DIR_APACHE/$SERVER_CERT" "$SSL_DIR_APACHE/$SERVER_KEY"
|
||||
fi
|
||||
|
||||
# Aktualisieren der Nginx-Konfiguration, falls vorhanden
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
update_nginx_config "$SSL_DIR_NGINX/$SERVER_CERT" "$SSL_DIR_NGINX/$SERVER_KEY"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Es ist kein WEbServer auf diesen System Installiert"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Funktion zum Aktualisieren der Apache-Konfiguration
|
||||
update_apache_config() {
|
||||
local cert_file="$1"
|
||||
local key_file="$2"
|
||||
|
||||
echo "Aktualisiere Apache-Konfiguration für SSL-Zertifikate..."
|
||||
|
||||
# Konfigurationsdatei für SSL-Zertifikate finden und bearbeiten
|
||||
local apache_config_file=$(find /etc/apache2 -name "ssl.conf" -o -name "httpd.conf" 2>/dev/null | head -1)
|
||||
if [ -n "$apache_config_file" ]; then
|
||||
# SSLCertificateFile aktualisieren
|
||||
sed -i "s|^\( *SSLCertificateFile *\).*|\1$cert_file|" "$apache_config_file"
|
||||
# SSLCertificateKeyFile aktualisieren
|
||||
sed -i "s|^\( *SSLCertificateKeyFile *\).*|\1$key_file|" "$apache_config_file"
|
||||
echo "Apache-Konfiguration aktualisiert."
|
||||
else
|
||||
echo "Apache-Konfigurationsdatei nicht gefunden oder nicht aktualisiert."
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Aktualisieren der Nginx-Konfiguration
|
||||
update_nginx_config() {
|
||||
local cert_file="$1"
|
||||
local key_file="$2"
|
||||
|
||||
echo "Aktualisiere Nginx-Konfiguration für SSL-Zertifikate..."
|
||||
|
||||
# Konfigurationsdatei für SSL-Zertifikate finden und bearbeiten
|
||||
local nginx_config_file="/etc/nginx/nginx.conf"
|
||||
if [ -f "$nginx_config_file" ]; then
|
||||
# SSL Zertifikat und Key aktualisieren
|
||||
sed -i "s|^\( *ssl_certificate *\).*|\1$cert_file;|" "$nginx_config_file"
|
||||
sed -i "s|^\( *ssl_certificate_key *\).*|\1$key_file;|" "$nginx_config_file"
|
||||
echo "Nginx-Konfiguration aktualisiert."
|
||||
else
|
||||
echo "Nginx-Konfigurationsdatei nicht gefunden oder nicht aktualisiert."
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Ermitteln des installierten Webserver-Dienstes
|
||||
detect_webserver() {
|
||||
if [ -f "/etc/apache2/apache2.conf" ]; then
|
||||
echo "Apache Webserver ist installiert."
|
||||
fi
|
||||
if [ -f "/etc/httpd/conf/httpd.conf" ]; then
|
||||
echo "Apache Webserver ist installiert."
|
||||
fi
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
echo "Nginx Webserver ist installiert."
|
||||
fi
|
||||
}
|
||||
|
||||
echo
|
||||
# Hauptprogramm
|
||||
detect_os
|
||||
install_requierments
|
||||
generate_ssh_key
|
||||
copy_ssh_key_to_nas
|
||||
create_certificate_request
|
||||
create_remote_folders
|
||||
#Wird nicht genutz
|
||||
#setup_ssh_keys
|
||||
upload_certificate_request
|
||||
download_certificates
|
||||
create_fullchain_certificate
|
||||
copy_certificates
|
||||
|
||||
# Funktionen fue WebServer Zertifiakte
|
||||
detect_webserver
|
||||
copy_web_certificates
|
||||
#umountNFS
|
||||
echo "Prozess abgeschlossen."
|
||||
Reference in New Issue
Block a user