2025-11-13 19:38:23 +00:00
|
|
|
package main
|
|
|
|
|
|
2025-11-14 11:12:15 +00:00
|
|
|
import (
|
|
|
|
|
"log"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/Snider/Borg/pkg/website"
|
|
|
|
|
)
|
2025-11-13 19:38:23 +00:00
|
|
|
|
|
|
|
|
func main() {
|
2025-11-14 11:12:15 +00:00
|
|
|
log.Println("Collecting website...")
|
|
|
|
|
|
|
|
|
|
// Download and package the website.
|
|
|
|
|
dn, err := website.DownloadAndPackageWebsite("https://example.com", 2, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("Failed to collect website: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Serialize the DataNode to a tarball.
|
|
|
|
|
tarball, err := dn.ToTar()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("Failed to serialize datanode to tar: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write the tarball to a file.
|
|
|
|
|
err = os.WriteFile("website.dat", tarball, 0644)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("Failed to write datanode file: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Println("Successfully created website.dat")
|
2025-11-13 19:38:23 +00:00
|
|
|
}
|