Skip to content

Commit 0f1db8c

Browse files
authored
Refactor: 2FAuth (#9582)
* Refactor * Update * Update
1 parent fc2f72b commit 0f1db8c

File tree

2 files changed

+14
-34
lines changed

2 files changed

+14
-34
lines changed

ct/2fauth.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ function update_script() {
4040
msg_ok "Backup Created"
4141

4242
if ! dpkg -l | grep -q 'php8.3'; then
43-
$STD apt-get install -y \
44-
lsb-release \
45-
gnupg2
46-
PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli" PHP_FPM="YES" setup_php
43+
PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli,tokenizer,dom,redis,session,openssl" PHP_FPM="YES" setup_php
4744
sed -i 's/php8.2/php8.3/g' /etc/nginx/conf.d/2fauth.conf
4845
fi
4946
fetch_and_deploy_gh_release "2fauth" "Bubka/2FAuth"

install/2fauth-install.sh

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,26 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt install -y \
18-
lsb-release \
19-
nginx
17+
$STD apt install -y nginx
2018
msg_ok "Installed Dependencies"
2119

22-
PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli" PHP_FPM="YES" setup_php
20+
PHP_VERSION="8.3" PHP_MODULE="common,ctype,fileinfo,mysql,cli,tokenizer,dom,redis,session,openssl" PHP_FPM="YES" setup_php
2321
setup_composer
2422
setup_mariadb
25-
26-
msg_info "Setting up Database"
27-
DB_NAME=2fauth_db
28-
DB_USER=2fauth
29-
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
30-
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
31-
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
32-
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
33-
{
34-
echo "2FAuth Credentials"
35-
echo "Database User: $DB_USER"
36-
echo "Database Password: $DB_PASS"
37-
echo "Database Name: $DB_NAME"
38-
} >>~/2FAuth.creds
39-
msg_ok "Set up Database"
40-
23+
MARIADB_DB_NAME="2fauth_db" MARIADB_DB_USER="2fauth" setup_mariadb_db
24+
import_local_ip
4125
fetch_and_deploy_gh_release "2fauth" "Bubka/2FAuth"
4226

4327
msg_info "Setup 2FAuth"
44-
cd /opt/2fauth || exit
28+
cd /opt/2fauth
4529
cp .env.example .env
46-
IPADDRESS=$(hostname -I | awk '{print $1}')
47-
sed -i -e "s|^APP_URL=.*|APP_URL=http://$IPADDRESS|" \
48-
-e "s|^DB_CONNECTION=$|DB_CONNECTION=mysql|" \
49-
-e "s|^DB_DATABASE=$|DB_DATABASE=$DB_NAME|" \
50-
-e "s|^DB_HOST=$|DB_HOST=127.0.0.1|" \
51-
-e "s|^DB_PORT=$|DB_PORT=3306|" \
52-
-e "s|^DB_USERNAME=$|DB_USERNAME=$DB_USER|" \
53-
-e "s|^DB_PASSWORD=$|DB_PASSWORD=$DB_PASS|" .env
30+
sed -i -e "s|^APP_URL=.*|APP_URL=http://$LOCAL_IP|" \
31+
-e "s|^DB_CONNECTION=$|DB_CONNECTION=mysql|" \
32+
-e "s|^DB_DATABASE=$|DB_DATABASE=$MARIADB_DB_NAME|" \
33+
-e "s|^DB_HOST=$|DB_HOST=127.0.0.1|" \
34+
-e "s|^DB_PORT=$|DB_PORT=3306|" \
35+
-e "s|^DB_USERNAME=$|DB_USERNAME=$MARIADB_DB_USER|" \
36+
-e "s|^DB_PASSWORD=$|DB_PASSWORD=$MARIADB_DB_PASS|" .env
5437
export COMPOSER_ALLOW_SUPERUSER=1
5538
$STD composer update --no-plugins --no-scripts
5639
$STD composer install --no-dev --prefer-dist --no-plugins --no-scripts
@@ -68,7 +51,7 @@ cat <<EOF >/etc/nginx/conf.d/2fauth.conf
6851
server {
6952
listen 80;
7053
root /opt/2fauth/public;
71-
server_name $IPADDRESS;
54+
server_name $LOCAL_IP;
7255
index index.php;
7356
charset utf-8;
7457

0 commit comments

Comments
 (0)