|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: bvdberg01 |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | + |
| 7 | +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" |
| 8 | +color |
| 9 | +verb_ip6 |
| 10 | +catch_errors |
| 11 | +setting_up_container |
| 12 | +network_check |
| 13 | +update_os |
| 14 | + |
| 15 | +msg_info "Installing Dependencies" |
| 16 | +$STD apt-get install -y \ |
| 17 | + curl \ |
| 18 | + sudo \ |
| 19 | + mc \ |
| 20 | + gnupg2\ |
| 21 | + postgresql \ |
| 22 | + apache2 \ |
| 23 | + lsb-release |
| 24 | +msg_ok "Installed Dependencies" |
| 25 | + |
| 26 | +msg_info "Setup PHP8.4 Repository" |
| 27 | +$STD curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb |
| 28 | +$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb |
| 29 | +$STD sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' |
| 30 | +$STD apt-get update |
| 31 | +msg_ok "Setup PHP8.4 Repository" |
| 32 | + |
| 33 | +msg_info "Setup PHP" |
| 34 | +$STD apt-get install -y \ |
| 35 | + php8.4 \ |
| 36 | + php8.4-{apcu,ctype,curl,dom,fileinfo,gd,iconv,intl,mbstring,pgsql} \ |
| 37 | + libapache2-mod-php8.4 \ |
| 38 | + composer |
| 39 | +msg_info "Setup PHP" |
| 40 | + |
| 41 | +msg_info "Setting up PostgreSQL" |
| 42 | +DB_NAME=koillection |
| 43 | +DB_USER=koillection |
| 44 | +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) |
| 45 | +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" |
| 46 | +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMPLATE template0;" |
| 47 | +{ |
| 48 | +echo "Koillection Credentials" |
| 49 | +echo "Koillection Database User: $DB_USER" |
| 50 | +echo "Koillection Database Password: $DB_PASS" |
| 51 | +echo "Koillection Database Name: $DB_NAME" |
| 52 | +} >> ~/koillection.creds |
| 53 | +msg_ok "Set up PostgreSQL" |
| 54 | + |
| 55 | +msg_info "Setting up Node.js/Yarn" |
| 56 | +mkdir -p /etc/apt/keyrings |
| 57 | +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg |
| 58 | +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list |
| 59 | +$STD apt-get update |
| 60 | +$STD apt-get install -y nodejs |
| 61 | +$STD npm install -g npm@latest |
| 62 | +$STD npm install -g yarn |
| 63 | +msg_ok "Installed Node.js/Yarn" |
| 64 | + |
| 65 | +msg_info "Installing Koillection" |
| 66 | +RELEASE=$(curl -s https://api.github.com/repos/benjaminjonard/koillection/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') |
| 67 | +cd /opt |
| 68 | +wget -q "https://github.com/benjaminjonard/koillection/archive/refs/tags/${RELEASE}.zip" |
| 69 | +unzip -q "${RELEASE}.zip" |
| 70 | +mv "/opt/koillection-${RELEASE}" /opt/koillection |
| 71 | +cd /opt/koillection |
| 72 | +cp /opt/koillection/.env /opt/koillection/.env.local |
| 73 | +APP_SECRET=$(openssl rand -base64 32) |
| 74 | +sed -i -e "s|^APP_ENV=.*|APP_ENV=prod|" \ |
| 75 | + -e "s|^APP_DEBUG=.*|APP_DEBUG=0|" \ |
| 76 | + -e "s|^APP_SECRET=.*|APP_SECRET=${APP_SECRET}|" \ |
| 77 | + -e "s|^DB_NAME=.*|DB_NAME=${DB_NAME}|" \ |
| 78 | + -e "s|^DB_USER=.*|DB_USER=${DB_USER}|" \ |
| 79 | + -e "s|^DB_PASSWORD=.*|DB_PASSWORD=${DB_PASS}|" \ |
| 80 | + /opt/koillection/.env.local |
| 81 | +export COMPOSER_ALLOW_SUPERUSER=1 |
| 82 | +$STD composer install --no-dev -o --no-interaction --classmap-authoritative |
| 83 | +$STD php bin/console doctrine:migrations:migrate --no-interaction |
| 84 | +$STD php bin/console app:translations:dump |
| 85 | +cd assets/ |
| 86 | +$STD yarn install |
| 87 | +$STD yarn build |
| 88 | +chown -R www-data:www-data /opt/koillection/public/uploads |
| 89 | +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt |
| 90 | +msg_ok "Installed Koillection" |
| 91 | + |
| 92 | +msg_info "Creating Service" |
| 93 | +cat <<EOF >/etc/apache2/sites-available/koillection.conf |
| 94 | +<VirtualHost *:80> |
| 95 | + ServerName koillection |
| 96 | + DocumentRoot /opt/koillection/public |
| 97 | + <Directory /opt/koillection/public> |
| 98 | + Options Indexes FollowSymLinks |
| 99 | + AllowOverride All |
| 100 | + Require all granted |
| 101 | + RewriteEngine On |
| 102 | + RewriteCond %{REQUEST_FILENAME} !-f |
| 103 | + RewriteCond %{REQUEST_FILENAME} !-d |
| 104 | + RewriteRule ^(.*)$ index.php/\$1 [L] |
| 105 | + </Directory> |
| 106 | +
|
| 107 | + ErrorLog /var/log/apache2/koillection_error.log |
| 108 | + CustomLog /var/log/apache2/koillection_access.log combined |
| 109 | +</VirtualHost> |
| 110 | +EOF |
| 111 | +$STD a2ensite koillection |
| 112 | +$STD a2enmod rewrite |
| 113 | +$STD a2dissite 000-default.conf |
| 114 | +$STD systemctl reload apache2 |
| 115 | +msg_ok "Created Service" |
| 116 | + |
| 117 | +motd_ssh |
| 118 | +customize |
| 119 | + |
| 120 | +msg_info "Cleaning up" |
| 121 | +rm -rf "/opt/${RELEASE}.zip" |
| 122 | +$STD apt-get -y autoremove |
| 123 | +$STD apt-get -y autoclean |
| 124 | +msg_ok "Cleaned" |
0 commit comments