This commit is contained in:
MintHCM-admin 2025-12-18 10:07:52 +01:00
parent a827025d1e
commit b9534031c3
2 changed files with 46 additions and 113 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/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 # Copyright (c) 2021-2025 minthcm
# Author: MintHCM # Author: MintHCM
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
@ -18,16 +18,12 @@ header_info "$APP"
variables variables
color color
catch_errors catch_errors
function update_script() { function update_script() {
header_info "$APP" header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /var/www/MintHCM ]]; then
INSTALL_DIR="/var/www/MintHCM" msg_error "No ${APP} Installation Found!"
if [[ ! -d "${INSTALL_DIR}" ]] || [[ ! -d "${INSTALL_DIR}/.git" ]]; then
msg_error "No ${APP} installation found in ${INSTALL_DIR}!"
exit exit
fi fi
msg_error "Currently we don't provide an update function for this ${APP}." msg_error "Currently we don't provide an update function for this ${APP}."
@ -40,5 +36,5 @@ description
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" 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}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

View File

@ -13,88 +13,43 @@ setting_up_container
network_check network_check
update_os update_os
APP_NAME="MintHCM"
MINT_REPO="https://github.com/minthcm/minthcm.git" 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 "Setting up PHP 8.2"
msg_info "Installing base packages" PHP_APACHE="YES" PHP_VERSION="8.2" PHP_MODULE="mysql,cli,redis" PHP_FPM="YES" setup_php
$STD apt-get install -y git curl cron msg_ok "Set up PHP 8.2"
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 Composer" msg_info "Setting up Composer"
setup_composer || msg_error "Failed to setup Composer" setup_composer
msg_ok "Composer setup completed" msg_ok "Set up Composer"
msg_info "Enabling Apache modules (rewrite, headers)" msg_info "Enabling Apache modules (rewrite, headers)"
$STD a2enmod rewrite $STD a2enmod rewrite
$STD a2enmod headers $STD a2enmod headers
msg_ok "Apache2 with rewrite and headers modules configured" msg_ok "Enabled Apache modules (rewrite, headers)"
# MintHCM configuration files fetch_and_deploy_gh_release "MintHCM" "minthcm/minthcm" "tarball" "latest" "/var/www/MintHCM"
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"
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" msg_info "Setting ownership and permissions for MintHCM directory"
git config --global --add safe.directory "${MINT_DIR}" git config --global --add safe.directory /var/www/MintHCM
chown -R www-data:www-data "${MINT_DIR}" chown -R www-data:www-data /var/www/MintHCM
find "${MINT_DIR}" -type d -exec chmod 755 {} \; find /var/www/MintHCM -type d -exec chmod 755 {} \;
find "${MINT_DIR}" -type f -exec chmod 644 {} \; find /var/www/MintHCM -type f -exec chmod 644 {} \;
msg_ok "Ownership and permissions for MintHCM directory set" msg_ok "Set up ownership and permissions for MintHCM directory"
# Restart Apache2 to apply all new configuration msg_info "Restarting Apache2"
msg_info "Restarting Apache2 with new configuration" $STD systemctl restart apache2
$STD systemctl restart apache2 || msg_error "Failed to restart Apache2" msg_ok "Restarted Apache2"
msg_ok "Apache2 restarted"
# Elasticsearch
msg_info "Setting up Elasticsearch" msg_info "Setting up Elasticsearch"
setup_deb822_repo \ setup_deb822_repo \
"elasticsearch" \ "elasticsearch" \
@ -103,55 +58,39 @@ setup_deb822_repo \
"stable" \ "stable" \
"main" "main"
$STD apt install -y elasticsearch || msg_error "Failed to install Elasticsearch" $STD apt install -y elasticsearch
echo "-Xms2g" >>/etc/elasticsearch/jvm.options echo "-Xms2g" >>/etc/elasticsearch/jvm.options
echo "-Xmx2g" >>/etc/elasticsearch/jvm.options echo "-Xmx2g" >>/etc/elasticsearch/jvm.options
$STD /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment -b \ $STD /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment -b
|| msg_error "Failed to install Elasticsearch ingest-attachment plugin"
systemctl enable -q elasticsearch systemctl enable -q --now elasticsearch
systemctl restart -q elasticsearch msg_ok "Set up Elasticsearch"
msg_ok "Elasticsearch setup completed"
# MariaDB
msg_info "Setting up 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=''"; $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" msg_info "Configuring database for MintHCM"
DB_USER="minthcm"
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
$STD mariadb -u root -e "CREATE USER 'minthcm'@'localhost' IDENTIFIED BY '${DB_PASS}';"
$STD mariadb -u root -e "CREATE USER '${DB_USER}'@'localhost' IDENTIFIED BY '${DB_PASS}';" $STD mariadb -u root -e "GRANT ALL ON *.* TO 'minthcm'@'localhost'; FLUSH PRIVILEGES;"
$STD mariadb -u root -e "GRANT ALL ON *.* TO '${DB_USER}'@'localhost'; FLUSH PRIVILEGES;"
msg_ok "Configured MariaDB for MintHCM" msg_ok "Configured MariaDB for MintHCM"
#MintHCM config generate
msg_info "Downloading generate_config.php script" msg_info "Downloading generate_config.php script"
mkdir -p /var/www/script mkdir -p /var/www/script
cp /var/www/MintHCM/docker/script/generate_config.php /var/www/script/generate_config.php
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"
chown -R www-data:www-data /var/www/script 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 cp /var/www/MintHCM/docker/.env /var/www/script/.env
export DB_NAME=minthcm sed -i 's/^DB_HOST=.*/DB_HOST=localhost/' /var/www/script/.env
export DB_PORT=3306 sed -i 's/^DB_USER=.*/DB_USER=minthcm/' /var/www/script/.env
export DB_USER=minthcm sed -i "s/^DB_PASS=.*/DB_PASS=${DB_PASS}/" /var/www/script/.env
export DB_PASS=$DB_PASS sed -i 's/^ELASTICSEARCH_HOST=.*/ELASTICSEARCH_HOST=localhost/' /var/www/script/.env
export MINT_URL=localhost
export MINT_USER=admin
export MINT_PASS=minthcm
export ELASTICSEARCH_HOST=localhost
{ {
echo "MintHCM DB Credentials" 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" msg_error "Error: Failed to generate configMint4 - please check the configuration"
exit 1 exit 1
fi fi
msg_ok "configMint4 generated" msg_ok "Generated MintHCM configuration file (configMint4)"
#MintHCM installation
msg_info "Starting MintHCM installation..." 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 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 fi
msg_ok "${APP_NAME} has been installed. Make sure to configure the database and other parameters according to the MintHCM documentation."
motd_ssh motd_ssh
customize customize
cleanup_lxc cleanup_lxc