main.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "strconv"
  6. "imuslab.com/bokofs/bokofsd/mod/bokofs"
  7. "imuslab.com/bokofs/bokofsd/mod/bokofs/bokoworker"
  8. )
  9. func main() {
  10. httpPort := flag.Int("p", 80, "Port to serve on (Plain HTTP)")
  11. serveSecure := flag.Bool("s", false, "Serve HTTPS. Default false")
  12. flag.Parse()
  13. //Create a test worker register at /test
  14. testWorker, err := bokoworker.GetDefaultWorker("/teacat")
  15. if err != nil {
  16. panic(err)
  17. }
  18. webdavHandler, err := bokofs.NewWebdavInterfaceServer(bokofs.Options{
  19. ListeningAddress: ":" + strconv.Itoa(*httpPort),
  20. SecureServe: *serveSecure,
  21. })
  22. if err != nil {
  23. panic(err)
  24. }
  25. webdavHandler.AddWorker(testWorker)
  26. err = webdavHandler.Start()
  27. if err != nil {
  28. panic(err)
  29. }
  30. fmt.Println("Bokofs daemon started")
  31. select {}
  32. }
  33. /*
  34. //Get all the devices under /dev that is either sd or nvme
  35. deviceFiles, err := os.ReadDir("/dev")
  36. if err != nil {
  37. panic(err)
  38. }
  39. for _, deviceFile := range deviceFiles {
  40. if deviceFile.IsDir() {
  41. continue
  42. }
  43. fullPath := "/dev/" + deviceFile.Name()
  44. if !smart.IsRootDisk(fullPath) {
  45. continue
  46. }
  47. if !smart.IsDiskSupportedType(fullPath) {
  48. fmt.Println("Unsupported disk type")
  49. continue
  50. }
  51. fmt.Println(fullPath)
  52. //Get the SMART data printout in json
  53. smartdata, err := smart.GetSMARTData(fullPath)
  54. if err != nil {
  55. fmt.Println(err)
  56. }
  57. js, _ := json.MarshalIndent(smartdata, "", " ")
  58. fmt.Println(string(js))
  59. }
  60. */