|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: Stroopwafe1 |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://leantime.io |
| 7 | + |
| 8 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
| 9 | +color |
| 10 | +verb_ip6 |
| 11 | +catch_errors |
| 12 | +setting_up_container |
| 13 | +network_check |
| 14 | +update_os |
| 15 | + |
| 16 | +PHP_VERSION=8.4 |
| 17 | +PHP_MODULE=mysql |
| 18 | +PHP_APACHE=YES |
| 19 | +PHP_FPM=YES |
| 20 | + |
| 21 | +msg_info "Installing Apache2" |
| 22 | +$STD apt-get install -y \ |
| 23 | + apache2 |
| 24 | +msg_ok "Installed Apache2" |
| 25 | + |
| 26 | +setup_php |
| 27 | + |
| 28 | +msg_info "Installing Apache2 mod for PHP" |
| 29 | +$STD apt-get install -y \ |
| 30 | + "libapache2-mod-php${PHP_VERSION}" |
| 31 | +msg_ok "Installed Apache2 mod" |
| 32 | + |
| 33 | +setup_mariadb |
| 34 | + |
| 35 | +msg_ok "Installed Dependencies" |
| 36 | + |
| 37 | +msg_info "Setting up Database" |
| 38 | +systemctl enable -q --now mariadb |
| 39 | +DB_NAME=leantime |
| 40 | +DB_USER=leantime |
| 41 | +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) |
| 42 | +$STD mysql -u root -e "CREATE DATABASE $DB_NAME;" |
| 43 | +$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" |
| 44 | +$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" |
| 45 | +{ |
| 46 | + echo "${APPLICATION} Credentials" |
| 47 | + echo "Database User: $DB_USER" |
| 48 | + echo "Database Password: $DB_PASS" |
| 49 | + echo "Database Name: $DB_NAME" |
| 50 | +} >>~/"$APPLICATION".creds |
| 51 | +msg_ok "Set up Database" |
| 52 | + |
| 53 | +msg_info "Setup ${APPLICATION}" |
| 54 | +APACHE_LOG_DIR=/var/log/apache2 |
| 55 | +fetch_and_deploy_gh_release "$APPLICATION" "Leantime/leantime" "prebuild" "latest" "/opt/${APPLICATION}" Leantime-v[0-9].[0-9].[0-9].tar.gz |
| 56 | +chown -R www-data:www-data "/opt/${APPLICATION}" |
| 57 | +chmod -R 750 "/opt/${APPLICATION}" |
| 58 | + |
| 59 | +cat <<EOF >/etc/apache2/sites-enabled/000-default.conf |
| 60 | +<VirtualHost *:80> |
| 61 | + ServerAdmin webmaster@localhost |
| 62 | + DocumentRoot /opt/${APPLICATION}/public |
| 63 | + DirectoryIndex index.php index.html index.cgi index.pl index.xhtml |
| 64 | + Options +ExecCGI |
| 65 | +
|
| 66 | + <Directory /opt/${APPLICATION}/> |
| 67 | + Options FollowSymLinks |
| 68 | + Require all granted |
| 69 | + AllowOverride All |
| 70 | + </Directory> |
| 71 | +
|
| 72 | + <Location /> |
| 73 | + Require all granted |
| 74 | + </Location> |
| 75 | +
|
| 76 | + ErrorLog ${APACHE_LOG_DIR}/error.log |
| 77 | + CustomLog ${APACHE_LOG_DIR}/access.log combined |
| 78 | +</VirtualHost> |
| 79 | +EOF |
| 80 | + |
| 81 | +mv "/opt/${APPLICATION}/config/sample.env" "/opt/${APPLICATION}/config/.env" |
| 82 | +sed -i -e "s|^LEAN_DB_DATABASE.*|LEAN_DB_DATABASE = '$DB_NAME'|" \ |
| 83 | + -e "s|^LEAN_DB_USER.*|LEAN_DB_USER = '$DB_USER'|" \ |
| 84 | + -e "s|^LEAN_DB_PASSWORD.*|LEAN_DB_PASSWORD = '$DB_PASS'|" \ |
| 85 | + -e "s|^LEAN_SESSION_PASSWORD.*|LEAN_SESSION_PASSWORD = '$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)'|" \ |
| 86 | + "/opt/${APPLICATION}/config/.env" |
| 87 | + |
| 88 | +a2enmod -q proxy_fcgi setenvif rewrite |
| 89 | +a2enconf -q "php${PHP_VERSION}-fpm" |
| 90 | + |
| 91 | +sed -i -e "s/^;extension.\(curl\|fileinfo\|gd\|intl\|ldap\|mbstring\|exif\|mysqli\|odbc\|openssl\|pdo_mysql\)/extension=\1/g" "/etc/php/${PHP_VERSION}/apache2/php.ini" |
| 92 | + |
| 93 | +systemctl restart apache2 |
| 94 | + |
| 95 | +msg_ok "Setup ${APPLICATION}" |
| 96 | + |
| 97 | +motd_ssh |
| 98 | +customize |
| 99 | + |
| 100 | +msg_info "Cleaning up" |
| 101 | +$STD apt-get -y autoremove |
| 102 | +$STD apt-get -y autoclean |
| 103 | +msg_ok "Cleaned" |
0 commit comments