|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: Slaviša Arežina (tremor021) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/wger-project/wger |
| 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 | +msg_info "Installing Dependencies" |
| 17 | +$STD apt-get install -y \ |
| 18 | + curl \ |
| 19 | + sudo \ |
| 20 | + mc \ |
| 21 | + git \ |
| 22 | + gnupg \ |
| 23 | + apache2 \ |
| 24 | + libapache2-mod-wsgi-py3 |
| 25 | +msg_ok "Installed Dependencies" |
| 26 | + |
| 27 | +msg_info "Installing Python" |
| 28 | +$STD apt-get install -y python3-pip |
| 29 | +rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED |
| 30 | +msg_ok "Installed Python" |
| 31 | + |
| 32 | +msg_info "Setting up Node.js Repository" |
| 33 | +mkdir -p /etc/apt/keyrings |
| 34 | +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg |
| 35 | +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 |
| 36 | +msg_ok "Set up Node.js Repository" |
| 37 | + |
| 38 | +msg_info "Installing Node.js" |
| 39 | +$STD apt-get update |
| 40 | +$STD apt-get install -y nodejs |
| 41 | +$STD npm install -g yarn sass |
| 42 | +msg_ok "Installed Node.js" |
| 43 | + |
| 44 | +msg_info "Setting up wger" |
| 45 | +$STD adduser wger --disabled-password --gecos "" |
| 46 | +mkdir /home/wger/db |
| 47 | +touch /home/wger/db/database.sqlite |
| 48 | +chown :www-data -R /home/wger/db |
| 49 | +chmod g+w /home/wger/db /home/wger/db/database.sqlite |
| 50 | +mkdir /home/wger/{static,media} |
| 51 | +chmod o+w /home/wger/media |
| 52 | +temp_dir=$(mktemp -d) |
| 53 | +cd $temp_dir |
| 54 | +RELEASE=$(curl -s https://api.github.com/repos/wger-project/wger/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') |
| 55 | +wget -q "https://github.com/wger-project/wger/archive/refs/tags/$RELEASE.tar.gz" |
| 56 | +tar xzf $RELEASE.tar.gz |
| 57 | +mv wger-$RELEASE /home/wger/src |
| 58 | +cd /home/wger/src |
| 59 | +$STD pip install -r requirements_prod.txt |
| 60 | +$STD pip install -e . |
| 61 | +$STD wger create-settings --database-path /home/wger/db/database.sqlite |
| 62 | +sed -i "s#home/wger/src/media#home/wger/media#g" /home/wger/src/settings.py |
| 63 | +sed -i "/MEDIA_ROOT = '\/home\/wger\/media'/a STATIC_ROOT = '/home/wger/static'" /home/wger/src/settings.py |
| 64 | +$STD wger bootstrap |
| 65 | +$STD python3 manage.py collectstatic |
| 66 | +echo "${RELEASE}" >/opt/wger_version.txt |
| 67 | +msg_ok "Finished setting up wger" |
| 68 | + |
| 69 | +msg_info "Creating Service" |
| 70 | +cat <<EOF >/etc/apache2/sites-available/wger.conf |
| 71 | +<Directory /home/wger/src> |
| 72 | + <Files wsgi.py> |
| 73 | + Require all granted |
| 74 | + </Files> |
| 75 | +</Directory> |
| 76 | +
|
| 77 | +<VirtualHost *:80> |
| 78 | + WSGIApplicationGroup %{GLOBAL} |
| 79 | + WSGIDaemonProcess wger python-path=/home/wger/src python-home=/home/wger |
| 80 | + WSGIProcessGroup wger |
| 81 | + WSGIScriptAlias / /home/wger/src/wger/wsgi.py |
| 82 | + WSGIPassAuthorization On |
| 83 | +
|
| 84 | + Alias /static/ /home/wger/static/ |
| 85 | + <Directory /home/wger/static> |
| 86 | + Require all granted |
| 87 | + </Directory> |
| 88 | +
|
| 89 | + Alias /media/ /home/wger/media/ |
| 90 | + <Directory /home/wger/media> |
| 91 | + Require all granted |
| 92 | + </Directory> |
| 93 | +
|
| 94 | + ErrorLog /var/log/apache2/wger-error.log |
| 95 | + CustomLog /var/log/apache2/wger-access.log combined |
| 96 | +</VirtualHost> |
| 97 | +EOF |
| 98 | +$STD a2dissite 000-default.conf |
| 99 | +$STD a2ensite wger |
| 100 | +systemctl restart apache2 |
| 101 | +cat <<EOF >/etc/systemd/system/wger.service |
| 102 | +[Unit] |
| 103 | +Description=wger Service |
| 104 | +After=network.target |
| 105 | +
|
| 106 | +[Service] |
| 107 | +Type=simple |
| 108 | +User=root |
| 109 | +ExecStart=/usr/local/bin/wger start -a 0.0.0.0 -p 3000 |
| 110 | +Restart=always |
| 111 | +
|
| 112 | +[Install] |
| 113 | +WantedBy=multi-user.target |
| 114 | +EOF |
| 115 | +systemctl enable -q --now wger |
| 116 | +msg_ok "Created Service" |
| 117 | + |
| 118 | +motd_ssh |
| 119 | +customize |
| 120 | + |
| 121 | +msg_info "Cleaning up" |
| 122 | +rm -rf $temp_dir |
| 123 | +$STD apt-get -y autoremove |
| 124 | +$STD apt-get -y autoclean |
| 125 | +msg_ok "Cleaned" |
| 126 | + |
| 127 | +motd_ssh |
| 128 | +customize |
0 commit comments