mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-10 01:48:02 +02:00
Add embed Filesystem
This commit is contained in:
24
opengist.go
24
opengist.go
@ -1,9 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/rs/zerolog/log"
|
||||
"opengist/internal/config"
|
||||
"opengist/internal/git"
|
||||
"opengist/internal/models"
|
||||
"opengist/internal/ssh"
|
||||
"opengist/internal/web"
|
||||
@ -11,6 +14,9 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
//go:embed templates/*/*.html public/manifest.json public/assets/*.js public/assets/*.css public/assets/*.svg
|
||||
var embedFS embed.FS
|
||||
|
||||
func initialize() {
|
||||
configPath := flag.String("config", "config.yml", "Path to a config file in YML format")
|
||||
flag.Parse()
|
||||
@ -25,8 +31,20 @@ func initialize() {
|
||||
|
||||
config.InitLog()
|
||||
|
||||
log.Info().Msg("Opengist v" + config.OpengistVersion)
|
||||
log.Info().Msg("Using config file: " + absolutePath)
|
||||
fmt.Println("Opengist v" + config.OpengistVersion)
|
||||
fmt.Println("Using config file: " + absolutePath)
|
||||
|
||||
gitVersion, err := git.GetGitVersion()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Send()
|
||||
}
|
||||
|
||||
if ok, err := config.CheckGitVersion(gitVersion); err != nil {
|
||||
log.Fatal().Err(err).Send()
|
||||
} else if !ok {
|
||||
log.Warn().Msg("Git version may be too old, as Opengist has not been tested prior git version 2.20. " +
|
||||
"Current git version: " + gitVersion)
|
||||
}
|
||||
|
||||
homePath := config.GetHomeDir()
|
||||
log.Info().Msg("Data directory: " + homePath)
|
||||
@ -42,6 +60,8 @@ func initialize() {
|
||||
if err := models.Setup(filepath.Join(homePath, config.C.DBFilename)); err != nil {
|
||||
log.Fatal().Err(err).Msg("Failed to initialize database")
|
||||
}
|
||||
|
||||
web.EmbedFS = embedFS
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
Reference in New Issue
Block a user