From 0f1db8cc8e421030ac76785fe546fd6c2884c677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:36:44 +0100 Subject: [PATCH] Refactor: 2FAuth (#9582) * Refactor * Update * Update --- ct/2fauth.sh | 5 +---- install/2fauth-install.sh | 43 ++++++++++++--------------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/ct/2fauth.sh b/ct/2fauth.sh index 99a4eb008a..b293495cda 100644 --- a/ct/2fauth.sh +++ b/ct/2fauth.sh @@ -40,10 +40,7 @@ function update_script() { msg_ok "Backup Created" if ! dpkg -l | grep -q 'php8.3'; then - $STD apt-get install -y \ - lsb-release \ - gnupg2 - PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli" PHP_FPM="YES" setup_php + PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli,tokenizer,dom,redis,session,openssl" PHP_FPM="YES" setup_php sed -i 's/php8.2/php8.3/g' /etc/nginx/conf.d/2fauth.conf fi fetch_and_deploy_gh_release "2fauth" "Bubka/2FAuth" diff --git a/install/2fauth-install.sh b/install/2fauth-install.sh index 7e4448f9b9..0f4606db44 100644 --- a/install/2fauth-install.sh +++ b/install/2fauth-install.sh @@ -14,43 +14,26 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt install -y \ - lsb-release \ - nginx +$STD apt install -y nginx msg_ok "Installed Dependencies" -PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli" PHP_FPM="YES" setup_php +PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli,tokenizer,dom,redis,session,openssl" PHP_FPM="YES" setup_php setup_composer setup_mariadb - -msg_info "Setting up Database" -DB_NAME=2fauth_db -DB_USER=2fauth -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) -$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" -$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" -$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" -{ - echo "2FAuth Credentials" - echo "Database User: $DB_USER" - echo "Database Password: $DB_PASS" - echo "Database Name: $DB_NAME" -} >>~/2FAuth.creds -msg_ok "Set up Database" - +MARIADB_DB_NAME="2fauth_db" MARIADB_DB_USER="2fauth" setup_mariadb_db +import_local_ip fetch_and_deploy_gh_release "2fauth" "Bubka/2FAuth" msg_info "Setup 2FAuth" -cd /opt/2fauth || exit +cd /opt/2fauth cp .env.example .env -IPADDRESS=$(hostname -I | awk '{print $1}') -sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \ - -e "s|^DB_CONNECTION=$|DB_CONNECTION=mysql|" \ - -e "s|^DB_DATABASE=$|DB_DATABASE=$DB_NAME|" \ - -e "s|^DB_HOST=$|DB_HOST=127.0.0.1|" \ - -e "s|^DB_PORT=$|DB_PORT=3306|" \ - -e "s|^DB_USERNAME=$|DB_USERNAME=$DB_USER|" \ - -e "s|^DB_PASSWORD=$|DB_PASSWORD=$DB_PASS|" .env +sed -i -e "s|^APP_URL=.*|APP_URL=http://$LOCAL_IP|" \ + -e "s|^DB_CONNECTION=$|DB_CONNECTION=mysql|" \ + -e "s|^DB_DATABASE=$|DB_DATABASE=$MARIADB_DB_NAME|" \ + -e "s|^DB_HOST=$|DB_HOST=127.0.0.1|" \ + -e "s|^DB_PORT=$|DB_PORT=3306|" \ + -e "s|^DB_USERNAME=$|DB_USERNAME=$MARIADB_DB_USER|" \ + -e "s|^DB_PASSWORD=$|DB_PASSWORD=$MARIADB_DB_PASS|" .env export COMPOSER_ALLOW_SUPERUSER=1 $STD composer update --no-plugins --no-scripts $STD composer install --no-dev --prefer-dist --no-plugins --no-scripts @@ -68,7 +51,7 @@ cat </etc/nginx/conf.d/2fauth.conf server { listen 80; root /opt/2fauth/public; - server_name $IPADDRESS; + server_name $LOCAL_IP; index index.php; charset utf-8;