using System; using Gtk; namespace zero { namespace netboot { class MainClass { public static void Main (string[] args) { //Console.WriteLine("[Zero NetBoot]"); string sql_file="/net/zero-net-boot/db/status.db"; if (args.Length > 0) { if (args[0].StartsWith("--gui")) { checkRoot(); try { zero.netboot.Core.getCore(); // debug mode if (args[0]=="--gui-debug") { zero.netboot.Core.getCore().debug=true; } zero.netboot.Core.getCore().startGUI(); } catch(Exception e) { Console.WriteLine(e); } } else if (args[0]=="--check-db") { zero.netboot.Core core=zero.netboot.Core.getCore(); core.sqlman.check_version("isos"); } else if (args[0]=="--check-isos") { zero.netboot.Core core=zero.netboot.Core.getCore(); core.sqlman.check_isos(); } else if (args[0]=="--check-isos-debug") { zero.netboot.Core core=zero.netboot.Core.getCore(); core.debug=true; core.sqlman.check_isos(); } else if (args[0]=="--init-db") { Console.WriteLine(" * Initializing database..."); if (!System.IO.File.Exists(sql_file)) { try { System.IO.File.Create(sql_file); } catch { Console.WriteLine("[!] Error creating db file. You might need admin privileges. [!]"); } } else { Console.WriteLine("\tDeleting old database..."); try { System.IO.File.Delete(sql_file); System.IO.File.Create(sql_file); } catch { Console.WriteLine("[!] Error creating db file. You might need admin privileges. [!]"); } } try { zero.netboot.Core.getCore().sqlman=new zero.netboot.SqlManager(); zero.netboot.Core.getCore().sqlman.create_database(); zero.netboot.Core.getCore().sqlman.create_download_database(); //zero.netboot.Core.getCore().sqlman.create_tcos_database(); } catch { Console.WriteLine("[!] Error creating db file. You might need admin privileges. [!]"); } } } else { usage(); } } private static void checkRoot() { try { Console.WriteLine("[Zero NetBoot]"); System.IO.File.Create("/etc/zero-net-boot/lock"); } catch { zero.netboot.Core.getCore().close_me=true; Application.Init(); zero.netboot.WarningDialog warning=new zero.netboot.WarningDialog(); warning.msg=Mono.Unix.Catalog.GetString("You need administration privileges to run this program."); Application.Run(); } } public static void usage() { Console.WriteLine("\t--gui\t\t\tlaunch GUI"); Console.WriteLine("\t--gui-debug\t\tlaunch GUI - Debug mode"); Console.WriteLine("\t--check-db\t\tCheck Database"); Console.WriteLine("\t--check-isos\t\tCheck ISOs"); Console.WriteLine("\t--check-isos-debug\tCheck ISOs - Debug mode"); Console.WriteLine("\t--init-db\t\tInitialize database"); } } } }