Add script for seting up media center

This commit is contained in:
Artur Gurgul 2025-08-11 10:20:07 +02:00
parent 8789922ba6
commit c08110ae38
6 changed files with 161 additions and 0 deletions

View file

@ -0,0 +1,21 @@
module VirtualMachine
ISO_URLS = {
debian: {
arm64: {
install: "https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-13.0.0-arm64-netinst.iso"
},
x86_64: {
install: "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.0.0-amd64-netinst.iso",
live: "https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-13.0.0-amd64-standard.iso"
}
},
archlinux: {
x86_64: {
live: "https://geo.mirror.pkgbuild.com/iso/2025.08.01/archlinux-x86_64.iso"
}
}
}
end

21
lib/downloader.rb Normal file
View file

@ -0,0 +1,21 @@
require 'uri'
require 'addressable/uri'
module Downloader
# use_cache => save in the home and return path to it
# forced => download even if the file exists in the cache, saves to chace if use_cache == true
def self.get(url, use_cache = true, forced = false)
puts "downloading..."
puts url
uri = Addressable::URI.parse(url)
path = File.join("#{ENV["HOME"]}/.cache/dat/downloads/", uri.domain, uri.path)
#uri = URI.parse(url)
#file_name = File.basename(uri.path)
puts "Download path: #{path}"
yield path
end
end

16
lib/virtual-machine.rb Normal file
View file

@ -0,0 +1,16 @@
require 'downloader'
require_relative 'data/resources/iso-images'
module VirtualMachine
def self.distro(name, arch, type = :install)
ISO_URLS[:debian][:arm64][:install]
end
def self.setup(options)
distro = options[:distro]
arch = :arm64
type = :install
url = distro(name, arch, type)
Downloader.get(url)
end
end