2626 apiTlsCert string
2727 apiTlsKey string
2828 manifestPath string
29+ rootPath string
2930)
3031
3132func init () {
@@ -50,6 +51,9 @@ func init() {
5051 serverCmd .Flags ().StringVarP (& manifestPath , "manifests" , "m" , "" , "load manifests from directory" )
5152 viper .BindPFlag ("manifestPath" , serverCmd .Flags ().Lookup ("manifests" ))
5253
54+ serverCmd .Flags ().StringVarP (& rootPath , "root" , "" , "" , "if not given as an absolute path, a mount's path.localDir is relative to this directory" )
55+ viper .BindPFlag ("rootPath" , serverCmd .Flags ().Lookup ("root" ))
56+
5357 rootCmd .AddCommand (serverCmd )
5458}
5559
@@ -73,7 +77,7 @@ var serverCmd = &cobra.Command{
7377 })
7478 if viper .GetString ("manifestPath" ) != "" {
7579 log .Info ().Str ("path" , viper .GetString ("manifestPath" )).Msg ("Loading manifests" )
76- _ = store .LoadFromDirectory (viper .GetString ("manifestPath" ))
80+ _ = store .LoadFromDirectory (viper .GetString ("manifestPath" ), viper . GetString ( "rootPath" ) )
7781 }
7882 store .GlobalHints .HttpPort = viper .GetInt ("http.port" )
7983 store .GlobalHints .ApiPort = viper .GetInt ("api.port" )
@@ -86,7 +90,7 @@ var serverCmd = &cobra.Command{
8690 go dhcpServer .Serve ()
8791
8892 // TFTP
89- tftpServer , err := tftpd .NewServer (store )
93+ tftpServer , err := tftpd .NewServer (store , viper . GetString ( "rootPath" ) )
9094 if err != nil {
9195 log .Fatal ().Err (err ).Msg ("Failed to create TFTP server" )
9296 }
@@ -100,7 +104,7 @@ var serverCmd = &cobra.Command{
100104 go tftpServer .Serve (connTftp )
101105
102106 // HTTP service
103- httpServer , err := httpd .NewServer (store )
107+ httpServer , err := httpd .NewServer (store , viper . GetString ( "rootPath" ) )
104108 if err != nil {
105109 log .Fatal ().Err (err ).Msg ("Failed to create HTTP server" )
106110 }
@@ -115,7 +119,7 @@ var serverCmd = &cobra.Command{
115119 log .Info ().Interface ("addr" , connHttp .Addr ()).Msg ("HTTP listening" )
116120
117121 // HTTP API service
118- apiServer , err := api .NewServer (store , viper .GetString ("api.authorization" ))
122+ apiServer , err := api .NewServer (store , viper .GetString ("api.authorization" ), viper . GetString ( "rootPath" ) )
119123 if err != nil {
120124 log .Fatal ().Err (err ).Msg ("Failed to create HTTP API server" )
121125 }
0 commit comments