refactor(2fauth): 🎨 Changed from variables to static as requested

This commit is contained in:
Janek 2024-12-23 09:45:54 +00:00
parent 9a7c59605f
commit 291fe8fe87
2 changed files with 9 additions and 8 deletions

View File

@ -52,10 +52,11 @@ function update_script() {
msg_info "Updating $APP to v${RELEASE}" msg_info "Updating $APP to v${RELEASE}"
wget -q "https://github.com/Bubka/2FAuth/archive/refs/tags/${RELEASE}.zip" wget -q "https://github.com/Bubka/2FAuth/archive/refs/tags/${RELEASE}.zip"
unzip -q "${RELEASE}.zip" unzip -q "${RELEASE}.zip"
mv "${APPLICATION}-${RELEASE//v}/" "/opt/${APPLICATION}" mv "2FAuth-${RELEASE//v}/" "/opt/2fauth"
mv "/opt/2fauth-backup/.env" "/opt/2fauth/.env" mv "/opt/2fauth-backup/.env" "/opt/2fauth/.env"
mv "/opt/2fauth-backup/storage" "/opt/2fauth/storage" mv "/opt/2fauth-backup/storage" "/opt/2fauth/storage"
cd "/opt/2fauth" || return cd "/opt/2fauth" || return
msg_ok "Updated $APP to v${RELEASE}"
chown -R www-data: "/opt/2fauth" chown -R www-data: "/opt/2fauth"
chmod -R 755 "/opt/2fauth" chmod -R 755 "/opt/2fauth"
@ -74,7 +75,7 @@ function update_script() {
msg_ok "Cleanup Completed" msg_ok "Cleanup Completed"
# Last Action # Last Action
echo "${RELEASE}" >/opt/${APP}_version.txt echo "${RELEASE}" >/opt/2fauth_version.txt
msg_ok "Update Successful" msg_ok "Update Successful"
else else
msg_ok "No update required. ${APP} is already at v${RELEASE}" msg_ok "No update required. ${APP} is already at v${RELEASE}"

View File

@ -35,19 +35,19 @@ $STD mysql -u root -e "CREATE DATABASE $DB_NAME;"
$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" $STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');"
$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" $STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
{ {
echo "${APPLICATION} Credentials" echo "2FAuth Credentials"
echo "Database User: $DB_USER" echo "Database User: $DB_USER"
echo "Database Password: $DB_PASS" echo "Database Password: $DB_PASS"
echo "Database Name: $DB_NAME" echo "Database Name: $DB_NAME"
} >> ~/${APPLICATION}.creds } >> ~/2FAuth.creds
msg_ok "Set up Database" msg_ok "Set up Database"
# Setup App # Setup App
msg_info "Setup ${APPLICATION}" msg_info "Setup 2FAuth"
RELEASE=$(curl -s https://api.github.com/repos/Bubka/2FAuth/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') RELEASE=$(curl -s https://api.github.com/repos/Bubka/2FAuth/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
wget -q "https://github.com/Bubka/2FAuth/archive/refs/tags/${RELEASE}.zip" wget -q "https://github.com/Bubka/2FAuth/archive/refs/tags/${RELEASE}.zip"
unzip -q "${RELEASE}.zip" unzip -q "${RELEASE}.zip"
mv "${APPLICATION}-${RELEASE//v}/" /opt/2fauth mv "2FAuth-${RELEASE//v}/" /opt/2fauth
cd "/opt/2fauth" || return cd "/opt/2fauth" || return
cp .env.example .env cp .env.example .env
@ -75,8 +75,8 @@ $STD php artisan config:cache
chown -R www-data: /opt/2fauth chown -R www-data: /opt/2fauth
chmod -R 755 /opt/2fauth chmod -R 755 /opt/2fauth
echo "${RELEASE}" >"/opt/${app}_version.txt" echo "${RELEASE}" >"/opt/2fauth_version.txt"
msg_ok "Setup ${app}" msg_ok "Setup 2fauth"
# Configure Service (NGINX) # Configure Service (NGINX)
msg_info "Configure Service" msg_info "Configure Service"