startup.go 4.2 KB

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