This commit is contained in:
Alexey Berezhok
2026-05-11 23:28:47 +03:00
parent adef1a98bb
commit 9d1afcdf28
3 changed files with 38 additions and 11 deletions

View File

@@ -52,8 +52,32 @@ SSL_CERT_PATH = ARGV[0] || nil # First argument: SSL certificate path
SSL_KEY_PATH = ARGV[1] || nil # Second argument: SSL key path
# Generate secure passwords (meeting BunkerWeb password policy requirements)
API_PASSWORD = SecureRandom.alphanumeric(24) + "!@#"
ADMIN_PASSWORD = SecureRandom.alphanumeric(24) + "!@#"
api_env_file = "/etc/bunkerweb/api.env"
api_password = nil
if File.exist?(api_env_file)
File.foreach(api_env_file) do |line|
if line =~ /^\s*API_PASSWORD=(.*)/
val = $1.strip
api_password = val unless val.empty?
break
end
end
end
specials = '!@#$%^&*()-_=+[]{}|;:,.<>?'
API_PASSWORD = api_password || (SecureRandom.alphanumeric(24) + specials.chars.sample(3).join).chars.shuffle.join
ui_env_file = "/etc/bunkerweb/ui.env"
admin_password = nil
if File.exist?(ui_env_file)
File.foreach(ui_env_file) do |line|
if line =~ /^\s*ADMIN_PASSWORD=(.*)/
val = $1.strip
admin_password = val unless val.empty?
break
end
end
end
ADMIN_PASSWORD = admin_password || (SecureRandom.alphanumeric(24) + specials.chars.sample(3).join).chars.shuffle.join
puts "[INFO] Get server IP address"
@@ -225,6 +249,8 @@ system("systemctl enable bunkerweb-api")
puts "[INFO] Starting bunkerweb-api service..."
system("systemctl start bunkerweb-api")
sleep(30)
# Wait for the service to be ready (max 30 seconds)
puts "[INFO] Waiting for bunkerweb-api service to be running..."
max_attempts = 60 # Wait up to 30 seconds (check every half second)
@@ -341,7 +367,7 @@ DEFAULT_SERVICES = [
ssl: "no",
reverse_proxy_host: "http://127.0.0.1:7000",
use_template: "ui",
reverse_proxy_url: "/bw",
reverse_proxy_url: "/kormilo",
use_reverse_proxy: "yes"
}
},
@@ -414,9 +440,9 @@ begin
puts ""
puts "Web UI is now accessible at:"
if ui_ssl_enabled == "yes"
puts " https://#{server_ip_addr}/bw"
puts " https://#{server_ip_addr}/kormilo"
else
puts " http://#{server_ip_addr}/bw"
puts " http://#{server_ip_addr}/kormilo"
end
puts ""
puts "API URL: #{API_URL}"