|
| 1 | +#!/usr/bin/env bash |
| 2 | +SCRIPT_DIR="$(dirname "$0")" |
| 3 | +source "$SCRIPT_DIR/../core/build.func" |
| 4 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 5 | +# Author: jkrgr0 |
| 6 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 7 | +# Source: https://docs.2fauth.app/ |
| 8 | + |
| 9 | +APP="2FAuth" |
| 10 | +var_tags="${var_tags:-2fa;authenticator}" |
| 11 | +var_cpu="${var_cpu:-1}" |
| 12 | +var_ram="${var_ram:-512}" |
| 13 | +var_disk="${var_disk:-2}" |
| 14 | +var_os="${var_os:-debian}" |
| 15 | +var_version="${var_version:-12}" |
| 16 | +var_unprivileged="${var_unprivileged:-1}" |
| 17 | + |
| 18 | +header_info "$APP" |
| 19 | +variables |
| 20 | +color |
| 21 | +catch_errors |
| 22 | + |
| 23 | +function update_script() { |
| 24 | + header_info |
| 25 | + check_container_storage |
| 26 | + check_container_resources |
| 27 | + |
| 28 | + if [[ ! -d "/opt/2fauth" ]]; then |
| 29 | + msg_error "No ${APP} Installation Found!" |
| 30 | + exit |
| 31 | + fi |
| 32 | + if check_for_gh_release "2fauth" "Bubka/2FAuth"; then |
| 33 | + $STD apt-get update |
| 34 | + $STD apt-get -y upgrade |
| 35 | + |
| 36 | + msg_info "Creating Backup" |
| 37 | + mv "/opt/2fauth" "/opt/2fauth-backup" |
| 38 | + if ! dpkg -l | grep -q 'php8.3'; then |
| 39 | + cp /etc/nginx/conf.d/2fauth.conf /etc/nginx/conf.d/2fauth.conf.bak |
| 40 | + fi |
| 41 | + msg_ok "Backup Created" |
| 42 | + |
| 43 | + if ! dpkg -l | grep -q 'php8.3'; then |
| 44 | + $STD apt-get install -y \ |
| 45 | + lsb-release \ |
| 46 | + gnupg2 |
| 47 | + PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli" PHP_FPM="YES" setup_php |
| 48 | + sed -i 's/php8.2/php8.3/g' /etc/nginx/conf.d/2fauth.conf |
| 49 | + fi |
| 50 | + fetch_and_deploy_gh_release "2fauth" "Bubka/2FAuth" |
| 51 | + setup_composer |
| 52 | + mv "/opt/2fauth-backup/.env" "/opt/2fauth/.env" |
| 53 | + mv "/opt/2fauth-backup/storage" "/opt/2fauth/storage" |
| 54 | + cd "/opt/2fauth" || return |
| 55 | + chown -R www-data: "/opt/2fauth" |
| 56 | + chmod -R 755 "/opt/2fauth" |
| 57 | + export COMPOSER_ALLOW_SUPERUSER=1 |
| 58 | + $STD composer install --no-dev --prefer-source |
| 59 | + php artisan 2fauth:install |
| 60 | + $STD systemctl restart nginx |
| 61 | + |
| 62 | + msg_info "Cleaning Up" |
| 63 | + if dpkg -l | grep -q 'php8.2'; then |
| 64 | + $STD apt-get remove --purge -y php8.2* |
| 65 | + fi |
| 66 | + $STD apt-get -y autoremove |
| 67 | + $STD apt-get -y autoclean |
| 68 | + msg_ok "Cleanup Completed" |
| 69 | + msg_ok "Updated Successfully" |
| 70 | + fi |
| 71 | + exit |
| 72 | +} |
| 73 | + |
| 74 | +start |
| 75 | +build_container |
| 76 | +description |
| 77 | + |
| 78 | +msg_ok "Completed Successfully!\n" |
| 79 | +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" |
| 80 | +echo -e "${INFO}${YW} Access it using the following URL:${CL}" |
| 81 | +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:80${CL}" |
0 commit comments