startup.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package main
  2. /*
  3. System Startup Script for ArOZ Online System
  4. author: tobychui
  5. */
  6. import (
  7. "fmt"
  8. "log"
  9. "os"
  10. db "imuslab.com/arozos/mod/database"
  11. "imuslab.com/arozos/mod/filesystem"
  12. fs "imuslab.com/arozos/mod/filesystem"
  13. )
  14. func RunStartup() {
  15. //1. Initiate the main system database
  16. //Check if system or web both not exists and web.tar.gz exists. Unzip it for the user
  17. if (!fs.FileExists("system/") || !fs.FileExists("web/")) && fs.FileExists("./web.tar.gz") {
  18. log.Println("Unzipping system critical files from archive")
  19. extErr := filesystem.ExtractTarGzipFile("./web.tar.gz", "./")
  20. if extErr != nil {
  21. //Extract failed
  22. fmt.Println("▒▒ ERROR: UNABLE TO EXTRACT CRITICAL SYSTEM FOLDERS ▒▒")
  23. fmt.Println(extErr)
  24. panic("Unable to extract content from web.tar.gz to fix the missing system / web folder. Please unzip the web.tar.gz manually.")
  25. }
  26. //Extract success
  27. extErr = os.Remove("./web.tar.gz")
  28. if extErr != nil {
  29. log.Println("Unable to remove web.tar.gz: ", extErr)
  30. }
  31. }
  32. if !fs.FileExists("system/") {
  33. fmt.Println("▒▒ ERROR: SYSTEM FOLDER NOT FOUND ▒▒")
  34. panic("This error occurs because the system folder is missing. Please follow the installation guide and don't just download a binary and run it.")
  35. }
  36. if !fs.FileExists("web/") {
  37. fmt.Println("▒▒ ERROR: WEB FOLDER NOT FOUND ▒▒")
  38. panic("This error occurs because the web folder is missing. Please follow the installation guide and don't just download a binary and run it.")
  39. }
  40. dbconn, err := db.NewDatabase("system/ao.db", false)
  41. if err != nil {
  42. panic(err)
  43. }
  44. sysdb = dbconn
  45. //2. Initiate the auth Agent
  46. AuthInit() //See auth.go
  47. //3. Start Permission Management Module
  48. permissionNewHandler() //See permission.go
  49. //4. Mount and create the storage system base
  50. StorageInit() //See storage.go
  51. //5. Startup user and permission sytem
  52. UserSystemInit() //See user.go
  53. permissionInit() //Register permission interface after user
  54. RegisterSystemInit() //See register.go
  55. GroupStoragePoolInit() //Register permission groups's storage pool, require permissionInit()
  56. BridgeStoragePoolInit() //Register the bridged storage pool based on mounted storage pools
  57. //6. Start Modules and Package Manager
  58. ModuleServiceInit() //Module Handler
  59. PackagManagerInit() //Start APT service agent
  60. //7. Kickstart the File System and Desktop
  61. NightlyTasksInit() //Start Nightly task scheduler
  62. FileSystemInit() //Start FileSystem
  63. DesktopInit() //Start Desktop
  64. //StorageDaemonInit() //Start File System handler daemon (for backup and other sync process)
  65. //8 Start AGI and Subservice modules (Must start after module)
  66. AGIInit() //ArOZ Javascript Gateway Interface, must start after fs
  67. SchedulerInit() //Start System Scheudler
  68. SubserviceInit() //Subservice Handler
  69. //9. Initiate System Settings Handlers
  70. SystemSettingInit() //Start System Setting Core
  71. DiskQuotaInit() //Disk Quota Management
  72. DiskServiceInit() //Start Disk Services
  73. DeviceServiceInit() //Client Device Management
  74. SystemInfoInit() //System Information UI
  75. SystemIDInit() //System UUID Manager
  76. AuthSettingsInit() //Authentication Settings Handler, must be start after user Handler
  77. AdvanceSettingInit() //System Advance Settings
  78. StartupFlagsInit() //System BootFlag settibg
  79. HardwarePowerInit() //Start host power manager
  80. RegisterStorageSettings() //Storage Settings
  81. //10. Startup network services and schedule services
  82. NetworkServiceInit() //Initalize network serves (ssdp / mdns etc)
  83. WiFiInit() //Inialize WiFi management module
  84. //ARSM Moved to scheduler, remote support is rewrite pending
  85. //ArsmInit() //Inialize ArOZ Remote Support & Management Framework
  86. //11. Other stuffs
  87. util_init()
  88. system_resetpw_init()
  89. mediaServer_init()
  90. security_init()
  91. backup_init()
  92. OAuthInit() //Oauth system init
  93. ldapInit() //LDAP system init
  94. notificationInit() //Notification system init
  95. //Start High Level Services that requires full arozos architectures
  96. FTPServerInit() //Start FTP Server Endpoints
  97. WebDAVInit() //Start WebDAV Endpoint
  98. ClusterInit() //Start Cluster Services
  99. IoTHubInit() //Inialize ArozOS IoT Hub module
  100. ModuleInstallerInit() //Start Module Installer
  101. //Finally
  102. moduleHandler.ModuleSortList() //Sort the system module list
  103. }