Initialer Import der Synology Scripts

This commit is contained in:
root
2026-08-05 08:43:57 +02:00
commit 5e32a7c411
404 changed files with 79932 additions and 0 deletions
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"
+26
View File
@@ -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!"
+109
View File
@@ -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
View File
@@ -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
View File
@@ -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
+78
View File
@@ -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 "$@"