|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: Nícolas Pastorello (opastorello) |
| 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 | + git \ |
| 21 | + software-properties-common \ |
| 22 | + apt-transport-https \ |
| 23 | + ca-certificates \ |
| 24 | + gnupg \ |
| 25 | + php8.2 \ |
| 26 | + php8.2-{common,cli,gd,mysql,mbstring,bcmath,xml,fpm,curl,zip} \ |
| 27 | + mariadb-server \ |
| 28 | + nginx \ |
| 29 | + redis-server |
| 30 | +$STD curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer |
| 31 | +msg_ok "Installed Dependencies" |
| 32 | + |
| 33 | +msg_info "Installing Paymenter" |
| 34 | +RELEASE=$(curl -s https://api.github.com/repos/paymenter/paymenter/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/') |
| 35 | +echo "${RELEASE}" >/opt/${APP}_version.txt |
| 36 | +mkdir -p /opt/paymenter |
| 37 | +cd /opt/paymenter |
| 38 | +wget -q "https://github.com/paymenter/paymenter/releases/download/${RELEASE}/paymenter.tar.gz" |
| 39 | +$STD tar -xzvf paymenter.tar.gz |
| 40 | +chmod -R 755 storage/* bootstrap/cache/ |
| 41 | +msg_ok "Installed Paymenter" |
| 42 | + |
| 43 | +msg_info "Setting up database" |
| 44 | +DB_NAME=paymenter |
| 45 | +DB_USER=paymenter |
| 46 | +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) |
| 47 | +mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql |
| 48 | +mysql -u root -e "CREATE DATABASE $DB_NAME;" |
| 49 | +mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" |
| 50 | +mysql -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost' WITH GRANT OPTION;" |
| 51 | +{ |
| 52 | + echo "Paymenter Database Credentials" |
| 53 | + echo "Database: $DB_NAME" |
| 54 | + echo "Username: $DB_USER" |
| 55 | + echo "Password: $DB_PASS" |
| 56 | +} >> ~/paymenter_db.creds |
| 57 | +cp .env.example .env |
| 58 | +$STD composer install --no-dev --optimize-autoloader --no-interaction |
| 59 | +$STD php artisan key:generate --force |
| 60 | +$STD php artisan storage:link |
| 61 | +sed -i "s/^DB_DATABASE=.*/DB_DATABASE=${DB_NAME}/" .env |
| 62 | +sed -i "s/^DB_USERNAME=.*/DB_USERNAME=${DB_USER}/" .env |
| 63 | +sed -i "s/^DB_PASSWORD=.*/DB_PASSWORD=${DB_PASS}/" .env |
| 64 | +$STD php artisan migrate --force --seed |
| 65 | +msg_ok "Set up database" |
| 66 | + |
| 67 | +msg_info "Creating Admin User" |
| 68 | +$STD php artisan p:user:create <<EOF |
| 69 | + |
| 70 | +paymenter |
| 71 | +admin |
| 72 | +paymenter |
| 73 | +0 |
| 74 | +EOF |
| 75 | +msg_ok "Created Admin User" |
| 76 | + |
| 77 | +msg_info "Configuring Nginx" |
| 78 | +cat <<EOF >/etc/nginx/sites-available/paymenter.conf |
| 79 | +server { |
| 80 | + listen 80; |
| 81 | + listen [::]:80; |
| 82 | + server_name localhost; |
| 83 | + root /opt/paymenter/public; |
| 84 | +
|
| 85 | + index index.php; |
| 86 | +
|
| 87 | + location / { |
| 88 | + try_files \$uri \$uri/ /index.php?\$query_string; |
| 89 | + } |
| 90 | +
|
| 91 | + location ~ \.php\$ { |
| 92 | + include snippets/fastcgi-php.conf; |
| 93 | + fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; |
| 94 | + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; |
| 95 | + include fastcgi_params; |
| 96 | + } |
| 97 | +
|
| 98 | + location ~ /\.ht { |
| 99 | + deny all; |
| 100 | + } |
| 101 | +} |
| 102 | +EOF |
| 103 | +ln -s /etc/nginx/sites-available/paymenter.conf /etc/nginx/sites-enabled/ |
| 104 | +rm -f /etc/nginx/sites-enabled/default |
| 105 | +$STD systemctl reload nginx |
| 106 | +chown -R www-data:www-data /opt/paymenter/* |
| 107 | +msg_ok "Configured Nginx" |
| 108 | + |
| 109 | +msg_info "Setting up Cronjob" |
| 110 | +echo "* * * * * php /opt/paymenter/artisan schedule:run >> /dev/null 2>&1" | crontab - |
| 111 | +msg_ok "Setup Cronjob" |
| 112 | + |
| 113 | +msg_info "Setting up Service" |
| 114 | +cat <<EOF >/etc/systemd/system/paymenter.service |
| 115 | +[Unit] |
| 116 | +Description=Paymenter Queue Worker |
| 117 | +
|
| 118 | +[Service] |
| 119 | +User=www-data |
| 120 | +Group=www-data |
| 121 | +Restart=always |
| 122 | +ExecStart=/usr/bin/php /opt/paymenter/artisan queue:work |
| 123 | +StartLimitInterval=180 |
| 124 | +StartLimitBurst=30 |
| 125 | +RestartSec=5s |
| 126 | +
|
| 127 | +[Install] |
| 128 | +WantedBy=multi-user.target |
| 129 | +EOF |
| 130 | +$STD systemctl enable --now paymenter.service |
| 131 | +msg_ok "Setup Service" |
| 132 | + |
| 133 | +msg_info "Cleaning up" |
| 134 | +rm -rf /opt/paymenter/paymenter.tar.gz |
| 135 | +$STD apt-get -y autoremove |
| 136 | +$STD apt-get -y autoclean |
| 137 | +msg_ok "Cleaned" |
| 138 | + |
| 139 | +motd_ssh |
| 140 | +customize |
0 commit comments