From b9534031c38c75ef65af41cb942e75c604e2ca41 Mon Sep 17 00:00:00 2001 From: MintHCM-admin Date: Thu, 18 Dec 2025 10:07:52 +0100 Subject: [PATCH] fix --- ct/minthcm.sh | 14 ++-- install/minthcm-install.sh | 145 +++++++++++-------------------------- 2 files changed, 46 insertions(+), 113 deletions(-) diff --git a/ct/minthcm.sh b/ct/minthcm.sh index 522b97086..c6f4c689f 100644 --- a/ct/minthcm.sh +++ b/ct/minthcm.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2025 minthcm # Author: MintHCM # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -18,16 +18,12 @@ header_info "$APP" variables color catch_errors - function update_script() { - header_info "$APP" + header_info check_container_storage check_container_resources - - INSTALL_DIR="/var/www/MintHCM" - - if [[ ! -d "${INSTALL_DIR}" ]] || [[ ! -d "${INSTALL_DIR}/.git" ]]; then - msg_error "No ${APP} installation found in ${INSTALL_DIR}!" + if [[ ! -d /var/www/MintHCM ]]; then + msg_error "No ${APP} Installation Found!" exit fi msg_error "Currently we don't provide an update function for this ${APP}." @@ -40,5 +36,5 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" -echo -e "${INFO}${YW} Access it using the following URL (after DB & installer are completed):${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" diff --git a/install/minthcm-install.sh b/install/minthcm-install.sh index 8a169a58e..b4e99ffcd 100644 --- a/install/minthcm-install.sh +++ b/install/minthcm-install.sh @@ -13,88 +13,43 @@ setting_up_container network_check update_os -APP_NAME="MintHCM" MINT_REPO="https://github.com/minthcm/minthcm.git" -MINT_DIR="/var/www/MintHCM" -PHP_VERSION="8.2" -# Install base packages required for MintHCM and system management -msg_info "Installing base packages" -$STD apt-get install -y git curl cron -msg_ok "Base packages installed" - -# PHP + Apache -msg_info "Setting up PHP ${PHP_VERSION}" -PHP_APACHE="YES" PHP_VERSION="${PHP_VERSION}" PHP_MODULE="mysql,cli,redis" PHP_FPM="YES" setup_php -msg_ok "PHP ${PHP_VERSION} and required extensions installed" +msg_info "Setting up PHP 8.2" +PHP_APACHE="YES" PHP_VERSION="8.2" PHP_MODULE="mysql,cli,redis" PHP_FPM="YES" setup_php +msg_ok "Set up PHP 8.2" msg_info "Setting up Composer" -setup_composer || msg_error "Failed to setup Composer" -msg_ok "Composer setup completed" +setup_composer +msg_ok "Set up Composer" msg_info "Enabling Apache modules (rewrite, headers)" $STD a2enmod rewrite $STD a2enmod headers -msg_ok "Apache2 with rewrite and headers modules configured" +msg_ok "Enabled Apache modules (rewrite, headers)" -# MintHCM configuration files -msg_info "Downloading PHP configuration for MintHCM" -PHP_MODS_DIR="/etc/php/${PHP_VERSION}/mods-available" -PHP_MINTHCM_INI="${PHP_MODS_DIR}/php-minthcm.ini" +fetch_and_deploy_gh_release "MintHCM" "minthcm/minthcm" "tarball" "latest" "/var/www/MintHCM" -mkdir -p "${PHP_MODS_DIR}" +msg_info "Configuring PHP and Apache2 for MintHCM" +mkdir -p /etc/php/8.2/mods-available +cp /var/www/MintHCM/docker/config/000-default.conf /etc/apache2/sites-available/000-default.conf +cp /var/www/MintHCM/docker/config/php-minthcm.ini /etc/php/8.2/mods-available/php-minthcm.ini +mkdir -p "/etc/php/8.2/cli/conf.d" "/etc/php/8.2/apache2/conf.d" +ln -s "/etc/php/8.2/mods-available/php-minthcm.ini" "/etc/php/8.2/cli/conf.d/20-minthcm.ini" +ln -s "/etc/php/8.2/mods-available/php-minthcm.ini" "/etc/php/8.2/apache2/conf.d/20-minthcm.ini" +msg_ok "Configured PHP and Apache2 for MintHCM" -curl -fsSL \ - "https://raw.githubusercontent.com/minthcm/minthcm/master/docker/config/php-minthcm.ini" \ - -o "${PHP_MINTHCM_INI}" \ - || msg_error "Failed to download php-minthcm.ini" - -mkdir -p "/etc/php/${PHP_VERSION}/cli/conf.d" "/etc/php/${PHP_VERSION}/apache2/conf.d" - -if [[ ! -e "/etc/php/${PHP_VERSION}/cli/conf.d/20-minthcm.ini" ]]; then - ln -s "${PHP_MINTHCM_INI}" "/etc/php/${PHP_VERSION}/cli/conf.d/20-minthcm.ini" \ - || msg_error "Failed to create CLI symlink for php-minthcm.ini" -fi - -if [[ ! -e "/etc/php/${PHP_VERSION}/apache2/conf.d/20-minthcm.ini" ]]; then - ln -s "${PHP_MINTHCM_INI}" "/etc/php/${PHP_VERSION}/apache2/conf.d/20-minthcm.ini" \ - || msg_error "Failed to create Apache symlink for php-minthcm.ini" -fi - -msg_ok "PHP configuration for MintHCM applied" - -# Apache VirtualHost configuration for MintHCM -msg_info "Downloading Apache VirtualHost configuration for MintHCM" -curl -fsSL \ - "https://raw.githubusercontent.com/minthcm/minthcm/master/docker/config/000-default.conf" \ - -o "/etc/apache2/sites-available/000-default.conf" \ - || msg_error "Failed to download 000-default.conf" -msg_ok "Apache VirtualHost configuration updated for MintHCM" - -# Clone MintHCM repository into the target directory -msg_info "Cloning MintHCM repository" -if [[ -d "${MINT_DIR}" ]]; then - msg_warn "Directory ${MINT_DIR} already exists, skipping clone" -else - mkdir -p "$(dirname "${MINT_DIR}")" - $STD git clone --depth=1 "${MINT_REPO}" "${MINT_DIR}" || msg_error "Failed to clone MintHCM repository" -fi -msg_ok "MintHCM repository available at ${MINT_DIR}" - -# Set ownership and permissions for MintHCM directory msg_info "Setting ownership and permissions for MintHCM directory" -git config --global --add safe.directory "${MINT_DIR}" -chown -R www-data:www-data "${MINT_DIR}" -find "${MINT_DIR}" -type d -exec chmod 755 {} \; -find "${MINT_DIR}" -type f -exec chmod 644 {} \; -msg_ok "Ownership and permissions for MintHCM directory set" +git config --global --add safe.directory /var/www/MintHCM +chown -R www-data:www-data /var/www/MintHCM +find /var/www/MintHCM -type d -exec chmod 755 {} \; +find /var/www/MintHCM -type f -exec chmod 644 {} \; +msg_ok "Set up ownership and permissions for MintHCM directory" -# Restart Apache2 to apply all new configuration -msg_info "Restarting Apache2 with new configuration" -$STD systemctl restart apache2 || msg_error "Failed to restart Apache2" -msg_ok "Apache2 restarted" +msg_info "Restarting Apache2" +$STD systemctl restart apache2 +msg_ok "Restarted Apache2" -# Elasticsearch msg_info "Setting up Elasticsearch" setup_deb822_repo \ "elasticsearch" \ @@ -103,55 +58,39 @@ setup_deb822_repo \ "stable" \ "main" -$STD apt install -y elasticsearch || msg_error "Failed to install Elasticsearch" +$STD apt install -y elasticsearch echo "-Xms2g" >>/etc/elasticsearch/jvm.options echo "-Xmx2g" >>/etc/elasticsearch/jvm.options -$STD /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment -b \ - || msg_error "Failed to install Elasticsearch ingest-attachment plugin" +$STD /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment -b -systemctl enable -q elasticsearch -systemctl restart -q elasticsearch -msg_ok "Elasticsearch setup completed" +systemctl enable -q --now elasticsearch +msg_ok "Set up Elasticsearch" -# MariaDB msg_info "Setting up MariaDB" -setup_mariadb || msg_error "Failed to setup MariaDB" +setup_mariadb $STD mariadb -u root -e "SET GLOBAL sql_mode=''"; -msg_ok "MariaDB setup completed" +msg_ok "Set up MariaDB" msg_info "Configuring database for MintHCM" -DB_USER="minthcm" + DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) - -$STD mariadb -u root -e "CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';" - -$STD mariadb -u root -e "GRANT ALL ON *.* TO '${DB_USER}'@'localhost'; FLUSH PRIVILEGES;" - +$STD mariadb -u root -e "CREATE USER 'minthcm'@'localhost' IDENTIFIED BY '${DB_PASS}';" +$STD mariadb -u root -e "GRANT ALL ON *.* TO 'minthcm'@'localhost'; FLUSH PRIVILEGES;" msg_ok "Configured MariaDB for MintHCM" -#MintHCM config generate msg_info "Downloading generate_config.php script" mkdir -p /var/www/script - -curl -fsSL \ - "https://raw.githubusercontent.com/minthcm/minthcm/master/docker/script/generate_config.php" \ - -o "/var/www/script/generate_config.php" \ - || msg_error "Failed to download generate_config.php" - +cp /var/www/MintHCM/docker/script/generate_config.php /var/www/script/generate_config.php chown -R www-data:www-data /var/www/script -msg_ok "generate_config.php script downloaded" +msg_ok "Downloading generate_config.php script" -export DB_HOST=localhost -export DB_NAME=minthcm -export DB_PORT=3306 -export DB_USER=minthcm -export DB_PASS=$DB_PASS -export MINT_URL=localhost -export MINT_USER=admin -export MINT_PASS=minthcm -export ELASTICSEARCH_HOST=localhost +cp /var/www/MintHCM/docker/.env /var/www/script/.env +sed -i 's/^DB_HOST=.*/DB_HOST=localhost/' /var/www/script/.env +sed -i 's/^DB_USER=.*/DB_USER=minthcm/' /var/www/script/.env +sed -i "s/^DB_PASS=.*/DB_PASS=${DB_PASS}/" /var/www/script/.env +sed -i 's/^ELASTICSEARCH_HOST=.*/ELASTICSEARCH_HOST=localhost/' /var/www/script/.env { echo "MintHCM DB Credentials" @@ -166,8 +105,8 @@ if [[ ! -f /var/www/MintHCM/configMint4 ]]; then msg_error "Error: Failed to generate configMint4 - please check the configuration" exit 1 fi -msg_ok "configMint4 generated" -#MintHCM installation +msg_ok "Generated MintHCM configuration file (configMint4)" + msg_info "Starting MintHCM installation..." cd /var/www/MintHCM && su -s /bin/bash -c 'php /var/www/MintHCM/MintCLI install < /var/www/MintHCM/configMint4' www-data @@ -183,8 +122,6 @@ else fi -msg_ok "${APP_NAME} has been installed. Make sure to configure the database and other parameters according to the MintHCM documentation." - motd_ssh customize cleanup_lxc