Refactor: 2FAuth (#9582)

* Refactor

* Update

* Update
This commit is contained in:
Slaviša Arežina 2025-12-02 16:36:44 +01:00 committed by GitHub
parent fc2f72b2ac
commit 0f1db8cc8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 34 deletions

View File

@ -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"

View File

@ -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 <<EOF >/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;