main.flags.go 6.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. apt "imuslab.com/arozos/mod/apt"
  6. auth "imuslab.com/arozos/mod/auth"
  7. db "imuslab.com/arozos/mod/database"
  8. permission "imuslab.com/arozos/mod/permission"
  9. user "imuslab.com/arozos/mod/user"
  10. "imuslab.com/arozos/mod/www"
  11. )
  12. /*
  13. System Flags
  14. */
  15. //=========== SYSTEM PARAMTERS ==============
  16. var sysdb *db.Database //System database
  17. var authAgent *auth.AuthAgent //System authentication agent
  18. var permissionHandler *permission.PermissionHandler
  19. var userHandler *user.UserHandler //User Handler
  20. var packageManager *apt.AptPackageManager //Manager for package auto installation
  21. var userWwwHandler *www.Handler //User Webroot handler
  22. var subserviceBasePort = 12810 //Next subservice port
  23. // =========== SYSTEM BUILD INFORMATION ==============
  24. var build_version = "development" //System build flag, this can be either {development / production / stable}
  25. var internal_version = "0.1.114" //Internal build version, please follow git commit counter for setting this value. max value \[0-9].[0-9][0-9].[0-9][0-9][0-9]\
  26. var deviceUUID string //The device uuid of this host
  27. var deviceVendor = "IMUSLAB.INC" //Vendor of the system
  28. var deviceVendorURL = "http://imuslab.com" //Vendor contact information
  29. var deviceModel = "AR100" //Hardware Model of the system
  30. var deviceModelDesc = "General Purpose Cloud Platform" //Device Model Description
  31. var iconVendor = "img/vendor/vendor_icon.png" //Vendor icon location
  32. var iconSystem = "img/vendor/system_icon.png" //System icon location
  33. // =========== RUNTTIME RELATED ================S
  34. var max_upload_size int64 = 8192 << 20 //Maxmium upload size, default 8GB
  35. var sudo_mode bool = (os.Geteuid() == 0 || os.Geteuid() == -1) //Check if the program is launched as sudo mode or -1 on windows
  36. // =========== SYSTEM FLAGS ==============
  37. //Flags related to System startup
  38. var listen_port = flag.Int("port", 8080, "Listening port for HTTP server")
  39. var tls_listen_port = flag.Int("tls_port", 8443, "Listening port for HTTPS server")
  40. var show_version = flag.Bool("version", false, "Show system build version")
  41. var host_name = flag.String("hostname", "My ArOZ", "Default name for this host")
  42. var system_uuid = flag.String("uuid", "", "System UUID for clustering and distributed computing. Only need to config once for first time startup. Leave empty for auto generation.")
  43. var disable_subservices = flag.Bool("disable_subservice", false, "Disable subservices completely")
  44. //Flags related to Networking
  45. var allow_upnp = flag.Bool("allow_upnp", false, "Enable uPNP service, recommended for host under NAT router")
  46. var allow_ssdp = flag.Bool("allow_ssdp", true, "Enable SSDP service, disable this if you do not want your device to be scanned by Windows's Network Neighborhood Page")
  47. var allow_mdns = flag.Bool("allow_mdns", true, "Enable MDNS service. Allow device to be scanned by nearby ArOZ Hosts")
  48. var disable_ip_resolve_services = flag.Bool("disable_ip_resolver", false, "Disable IP resolving if the system is running under reverse proxy environment")
  49. var enable_gzip = flag.Bool("gzip", true, "Enable gzip compress on file server")
  50. //Flags related to Security
  51. var use_tls = flag.Bool("tls", false, "Enable TLS on HTTP serving (HTTPS Mode)")
  52. var disable_http = flag.Bool("disable_http", false, "Disable HTTP server, require tls=true")
  53. var tls_cert = flag.String("cert", "localhost.crt", "TLS certificate file (.crt)")
  54. var session_key = flag.String("session_key", "", "Session key, must be 16, 24 or 32 bytes long (AES-128, AES-192 or AES-256). Leave empty for auto generated.")
  55. var tls_key = flag.String("key", "localhost.key", "TLS key file (.key)")
  56. //Flags related to hardware or interfaces
  57. var allow_hardware_management = flag.Bool("enable_hwman", true, "Enable hardware management functions in system")
  58. var wpa_supplicant_path = flag.String("wpa_supplicant_config", "/etc/wpa_supplicant/wpa_supplicant.conf", "Path for the wpa_supplicant config")
  59. var wan_interface_name = flag.String("wlan_interface_name", "wlan0", "The default wireless interface for connecting to an AP")
  60. //Flags related to files and uploads
  61. var max_upload = flag.Int("max_upload_size", 8192, "Maxmium upload size in MB. Must not exceed the available ram on your system")
  62. var upload_buf = flag.Int("upload_buf", 25, "Upload buffer memory in MB. Any file larger than this size will be buffered to disk (slower).")
  63. var storage_config_file = flag.String("storage_config", "./system/storage.json", "File location of the storage config file")
  64. var tmp_directory = flag.String("tmp", "./", "Temporary storage, can be access via tmp:/. A tmp/ folder will be created in this path. Recommend fast storage devices like SSD")
  65. var root_directory = flag.String("root", "./files/", "User root directories")
  66. var file_opr_buff = flag.Int("iobuf", 1024, "Amount of buffer memory for IO operations")
  67. var enable_dir_listing = flag.Bool("dir_list", true, "Enable directory listing")
  68. var enable_asyncFileUpload = flag.Bool("upload_async", false, "Enable file upload buffering to run in async mode (Faster upload, require RAM >= 8GB)")
  69. //Flags related to compatibility or testing
  70. var enable_beta_scanning_support = flag.Bool("beta_scan", false, "Allow compatibility to ArOZ Online Beta Clusters")
  71. var enable_console = flag.Bool("console", false, "Enable the debugging console.")
  72. //Flags related to running on Cloud Environment or public domain
  73. var allow_public_registry = flag.Bool("public_reg", false, "Enable public register interface for account creation")
  74. var allow_autologin = flag.Bool("allow_autologin", true, "Allow RESTFUL login redirection that allow machines like billboards to login to the system on boot")
  75. var demo_mode = flag.Bool("demo_mode", false, "Run the system in demo mode. All directories and database are read only.")
  76. var allow_package_autoInstall = flag.Bool("allow_pkg_install", true, "Allow the system to install package using Advanced Package Tool (aka apt or apt-get)")
  77. var allow_homepage = flag.Bool("homepage", true, "Enable user homepage. Accessible via /www/{username}/")
  78. //Scheduling and System Service Related
  79. var nightlyTaskRunTime = flag.Int("ntt", 3, "Nightly tasks execution time. Default 3 = 3 am in the morning")
  80. var maxTempFileKeepTime = flag.Int("tmp_time", 86400, "Time before tmp file will be deleted in seconds. Default 86400 seconds = 24 hours")
  81. //Flags related to ArozOS Cluster services
  82. var allow_clustering = flag.Bool("allow_cluster", true, "Enable cluster operations within LAN. Require allow_mdns=true flag")
  83. var allow_iot = flag.Bool("allow_iot", true, "Enable IoT related APIs and scanner. Require MDNS enabled")