12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package main
- import (
- "flag"
- "fmt"
- "strconv"
- "imuslab.com/bokofs/bokofsd/mod/bokofs"
- "imuslab.com/bokofs/bokofsd/mod/bokofs/bokoworker"
- )
- func main() {
- httpPort := flag.Int("p", 80, "Port to serve on (Plain HTTP)")
- serveSecure := flag.Bool("s", false, "Serve HTTPS. Default false")
- flag.Parse()
- //Create a test worker register at /test
- testWorker, err := bokoworker.GetDefaultWorker("/teacat")
- if err != nil {
- panic(err)
- }
- webdavHandler, err := bokofs.NewWebdavInterfaceServer(bokofs.Options{
- ListeningAddress: ":" + strconv.Itoa(*httpPort),
- SecureServe: *serveSecure,
- })
- if err != nil {
- panic(err)
- }
- webdavHandler.AddWorker(testWorker)
- err = webdavHandler.Start()
- if err != nil {
- panic(err)
- }
- fmt.Println("Bokofs daemon started")
- select {}
- }
- /*
- //Get all the devices under /dev that is either sd or nvme
- deviceFiles, err := os.ReadDir("/dev")
- if err != nil {
- panic(err)
- }
- for _, deviceFile := range deviceFiles {
- if deviceFile.IsDir() {
- continue
- }
- fullPath := "/dev/" + deviceFile.Name()
- if !smart.IsRootDisk(fullPath) {
- continue
- }
- if !smart.IsDiskSupportedType(fullPath) {
- fmt.Println("Unsupported disk type")
- continue
- }
- fmt.Println(fullPath)
- //Get the SMART data printout in json
- smartdata, err := smart.GetSMARTData(fullPath)
- if err != nil {
- fmt.Println(err)
- }
- js, _ := json.MarshalIndent(smartdata, "", " ")
- fmt.Println(string(js))
- }
- */
|