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
+86
View File
@@ -0,0 +1,86 @@
#!/bin/bash
# Set variables
EJBCA_VERSION="7.9.0.2" # Ändern Sie dies entsprechend der gewünschten Version
WILDFLY_VERSION="32.0.1.Final" # Ändern Sie dies entsprechend der gewünschten Version
JAVA_VERSION="11" # Ändern Sie dies entsprechend der gewünschten Version
INSTALL_DIR="/opt/ejbca"
WILDFLY_DIR="/opt/wildfly"
JAVA_DIR="/opt/java"
DB_USER="ejbcauser"
DB_PASS="ejbcapassword"
DB_NAME="ejbca"
DB_HOST="localhost"
# Update package list and install prerequisites
echo "Updating package list and installing prerequisites..."
sudo dnf update -y
sudo dnf install -y wget unzip mariadb-server
# Enable and start MariaDB
echo "Enabling and starting MariaDB..."
sudo systemctl enable mariadb
sudo systemctl start mariadb
# Install Java
echo "Installing Java..."
wget https://download.java.net/java/GA/jdk${JAVA_VERSION}/9/GPL/openjdk-${JAVA_VERSION}_linux-x64_bin.tar.gz
sudo tar -xzf openjdk-${JAVA_VERSION}_linux-x64_bin.tar.gz -C /opt/
sudo ln -s /opt/jdk-${JAVA_VERSION} $JAVA_DIR
export JAVA_HOME=$JAVA_DIR
export PATH=$JAVA_HOME/bin:$PATH
# Install WildFly
echo "Installing WildFly..."
wget https://download.jboss.org/wildfly/${WILDFLY_VERSION}/wildfly-${WILDFLY_VERSION}.zip
sudo unzip wildfly-${WILDFLY_VERSION}.zip -d /opt/
sudo ln -s /opt/wildfly-${WILDFLY_VERSION} $WILDFLY_DIR
# Install EJBCA
echo "Installing EJBCA..."
wget https://sourceforge.net/projects/ejbca/files/ejbca/${EJBCA_VERSION}/ejbca_ce_${EJBCA_VERSION}.tar.gz
sudo tar -xzf ejbca_ce_${EJBCA_VERSION}.tar.gz -C /opt/
sudo ln -s /opt/ejbca_ce-$EJBCA_VERSION $INSTALL_DIR
# Configure WildFly for EJBCA
echo "Configuring WildFly for EJBCA..."
sudo cp $INSTALL_DIR/doc/install/wildfly/jboss/standalone-full.xml $WILDFLY_DIR/standalone/configuration/
sudo cp $INSTALL_DIR/doc/install/wildfly/jboss/ejbca.xml $WILDFLY_DIR/standalone/deployments/
# Start WildFly
echo "Starting WildFly..."
sudo $WILDFLY_DIR/bin/standalone.sh -c standalone-full.xml &
# Wait for WildFly to start
sleep 20
# Setup EJBCA
echo "Setting up EJBCA..."
cd $INSTALL_DIR
sudo ./bin/ejbca.sh install wildfly
# Configure Database
echo "Configuring Database..."
sudo mysql -u root -e "CREATE DATABASE $DB_NAME;"
sudo mysql -u root -e "CREATE USER '$DB_USER'@'$DB_HOST' IDENTIFIED BY '$DB_PASS';"
sudo mysql -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'$DB_HOST';"
sudo mysql -u root -e "FLUSH PRIVILEGES;"
# Update EJBCA configuration for MySQL
echo "Updating EJBCA configuration for MySQL..."
sudo sed -i "s/localhost/$DB_HOST/g" $INSTALL_DIR/conf/database.properties
sudo sed -i "s/ejbcauser/$DB_USER/g" $INSTALL_DIR/conf/database.properties
sudo sed -i "s/ejbcapassword/$DB_PASS/g" $INSTALL_DIR/conf/database.properties
# Restart WildFly to apply changes
echo "Restarting WildFly..."
sudo pkill -f 'wildfly'
sudo $WILDFLY_DIR/bin/standalone.sh -c standalone-full.xml &
# Final setup for EJBCA
echo "Final setup for EJBCA..."
cd $INSTALL_DIR
sudo ./bin/ejbca.sh ca init --dn "CN=EJBCA,O=My Organization,C=US" --caname "ManagementCA" --tokenType "soft" --keytype "RSA" --keyspec "2048" --password "changeit"
# Print completion message
echo "EJBCA installation and configuration completed successfully."