#!/bin/bash

gen_random_string() {
    local length="$1"
    local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w "$length" | head -n 1)
    echo "$random_string"
}

config_after_install() {
         local config_webBasePath=$(gen_random_string 15)
         local config_username=$(gen_random_string 10)
         local config_password=$(gen_random_string 10)
         docker exec 3x-ui /app/x-ui setting -username "$config_username" -password "$config_password" -webBasePath "$config_webBasePath"

         echo -e "Login credentials:"
         echo -e "###############################################"
         echo -e "${green}Username: ${config_username}${plain}"
         echo -e "${green}Password: ${config_password}${plain}"
         echo -e "${green}webBasePath: ${config_webBasePath}${plain}"
         echo -e "###############################################"

         docker restart 3x-ui
    }

config_after_install