Refactor: 2FAuth (#5184)

* Refactor: 2fauth

* Update
This commit is contained in:
Slaviša Arežina
2025-06-16 17:00:14 +02:00
committed by GitHub
parent 5e649d7cb1
commit 13b1c684ee
2 changed files with 10 additions and 46 deletions

View File

@ -15,17 +15,12 @@ update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
lsb-release
curl -fsSL https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /usr/share/keyrings/deb.sury.org-php.gpg
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" >/etc/apt/sources.list.d/php.list
$STD apt-get update
$STD apt-get install -y \
nginx \
composer \
php8.3-{bcmath,common,ctype,curl,fileinfo,fpm,gd,intl,mbstring,mysql,xml,cli}
lsb-release \
nginx
msg_ok "Installed Dependencies"
PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,fpm,mysql,cli" install_php
install_composer
install_mariadb
msg_info "Setting up Database"
@ -43,16 +38,12 @@ $STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUS
} >>~/2FAuth.creds
msg_ok "Set up Database"
msg_info "Setup 2FAuth"
RELEASE=$(curl -fsSL https://api.github.com/repos/Bubka/2FAuth/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/Bubka/2FAuth/archive/refs/tags/${RELEASE}.zip" -o "${RELEASE}.zip"
$STD unzip "${RELEASE}.zip"
mv "2FAuth-${RELEASE//v/}/" /opt/2fauth
fetch_and_deploy_gh_release "Bubka/2FAuth"
cd "/opt/2fauth" || return
msg_info "Setup 2FAuth"
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|" \
@ -60,22 +51,16 @@ sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \
-e "s|^DB_PORT=$|DB_PORT=3306|" \
-e "s|^DB_USERNAME=$|DB_USERNAME=$DB_USER|" \
-e "s|^DB_PASSWORD=$|DB_PASSWORD=$DB_PASS|" .env
export COMPOSER_ALLOW_SUPERUSER=1
$STD composer update --no-plugins --no-scripts
$STD composer install --no-dev --prefer-source --no-plugins --no-scripts
$STD php artisan key:generate --force
$STD php artisan migrate:refresh
$STD php artisan passport:install -q -n
$STD php artisan storage:link
$STD php artisan config:cache
chown -R www-data: /opt/2fauth
chmod -R 755 /opt/2fauth
echo "${RELEASE}" >"/opt/2fauth_version.txt"
msg_ok "Setup 2fauth"
msg_info "Configure Service"
@ -107,7 +92,6 @@ server {
}
}
EOF
systemctl reload nginx
msg_ok "Configured Service"
@ -115,7 +99,6 @@ motd_ssh
customize
msg_info "Cleaning up"
rm -f "/opt/v${RELEASE}.zip"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"