|
| 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" PHP_MODULE="mysql" PHP_APACHE="YES" PHP_FPM="YES" setup_php |
| 17 | +setup_mariadb |
| 18 | + |
| 19 | +msg_info "Setting up Database" |
| 20 | +DB_NAME=leantime |
| 21 | +DB_USER=leantime |
| 22 | +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) |
| 23 | +$STD mysql -u root -e "CREATE DATABASE $DB_NAME;" |
| 24 | +$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" |
| 25 | +$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" |
| 26 | +{ |
| 27 | + echo "Leantime Credentials" |
| 28 | + echo "Database User: $DB_USER" |
| 29 | + echo "Database Password: $DB_PASS" |
| 30 | + echo "Database Name: $DB_NAME" |
| 31 | +} >>~/leantime.creds |
| 32 | +msg_ok "Set up Database" |
| 33 | + |
| 34 | +fetch_and_deploy_gh_release "leantime" "Leantime/leantime" "prebuild" "latest" "/opt/leantime" Leantime*.tar.gz |
| 35 | + |
| 36 | +msg_info "Setup Leantime" |
| 37 | +chown -R www-data:www-data "/opt/leantime" |
| 38 | +chmod -R 750 "/opt/leantime" |
| 39 | +cat <<EOF >/etc/apache2/sites-enabled/000-default.conf |
| 40 | +<VirtualHost *:80> |
| 41 | + ServerAdmin webmaster@localhost |
| 42 | + DocumentRoot /opt/leantime/public |
| 43 | + DirectoryIndex index.php index.html index.cgi index.pl index.xhtml |
| 44 | + Options +ExecCGI |
| 45 | +
|
| 46 | + <Directory /opt/leantime/> |
| 47 | + Options FollowSymLinks |
| 48 | + Require all granted |
| 49 | + AllowOverride All |
| 50 | + </Directory> |
| 51 | +
|
| 52 | + <Location /> |
| 53 | + Require all granted |
| 54 | + </Location> |
| 55 | +
|
| 56 | + ErrorLog /var/log/apache2/error.log |
| 57 | + CustomLog /var/log/apache2/access.log combined |
| 58 | +</VirtualHost> |
| 59 | +EOF |
| 60 | +mv "/opt/leantime/config/sample.env" "/opt/leantime/config/.env" |
| 61 | +sed -i -e "s|^LEAN_DB_DATABASE.*|LEAN_DB_DATABASE = '$DB_NAME'|" \ |
| 62 | + -e "s|^LEAN_DB_USER.*|LEAN_DB_USER = '$DB_USER'|" \ |
| 63 | + -e "s|^LEAN_DB_PASSWORD.*|LEAN_DB_PASSWORD = '$DB_PASS'|" \ |
| 64 | + -e "s|^LEAN_SESSION_PASSWORD.*|LEAN_SESSION_PASSWORD = '$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)'|" \ |
| 65 | + "/opt/leantime/config/.env" |
| 66 | +$STD a2enmod -q proxy_fcgi setenvif rewrite |
| 67 | +$STD a2enconf -q "php8.4-fpm" |
| 68 | +sed -i -e "s/^;extension.\(curl\|fileinfo\|gd\|intl\|ldap\|mbstring\|exif\|mysqli\|odbc\|openssl\|pdo_mysql\)/extension=\1/g" "/etc/php/8.4/apache2/php.ini" |
| 69 | +systemctl restart apache2 |
| 70 | +msg_ok "Setup leantime" |
| 71 | + |
| 72 | +motd_ssh |
| 73 | +customize |
| 74 | + |
| 75 | +msg_info "Cleaning up" |
| 76 | +$STD apt-get -y autoremove |
| 77 | +$STD apt-get -y autoclean |
| 78 | +msg_ok "Cleaned" |
0 commit comments