public static void UpdateDB() { switch (Convert.ToInt32(GetSetting("DBSchema", "YAMS"))) { case 1: //Update from Schema 1 Database.SaveSetting("StoragePath", Core.RootFolder + @"\servers\"); Database.SaveSetting("DBSchema", "2"); goto case 2; case 2: //Update from Schema 2 Database.SaveSetting("UsageData", "true"); Database.SaveSetting("DBSchema", "3"); goto case 3; case 3: Database.SaveSetting("EnablePortForwarding", "true"); Database.SaveSetting("EnableOpenFirewall", "true"); Database.SaveSetting("YAMSListenIP", Networking.GetListenIP().ToString()); AddJob("update", -1, 0, "", 0); AddJob("backup", -1, 30, "", 1); Database.SaveSetting("DBSchema", "4"); goto case 4; //goto case 3; //etc case 4: Database.SaveSetting("DNSName", ""); Database.SaveSetting("DNSSecret", ""); Database.SaveSetting("LastExternalIP", ""); Database.SaveSetting("DBSchema", "5"); goto case 5; case 5: Database.SaveSetting("EnablePublicSite", "true"); Database.SaveSetting("DBSchema", "6"); goto case 6; case 6: Database.SaveSetting("EnableTelnet", "false"); Database.SaveSetting("TelnetPort", "56553"); Database.SaveSetting("DBSchema", "7"); goto case 7; case 7: Database.SaveSetting("BukkitBetaInstalled", "false"); Database.SaveSetting("BukkitDevInstalled", "false"); Database.SaveSetting("DBSchema", "8"); goto case 8; case 8: break; default: break; } }
//Initial Set-up for first run only public static void FirstRun() { //Grab latest server jar YAMS.AutoUpdate.UpdateIfNeeded(YAMS.AutoUpdate.strMCServerURL, YAMS.Core.RootFolder + @"\lib\minecraft_server.jar.UPDATE"); //Set our MC Defaults in the DB var NewServer = new List <KeyValuePair <string, string> >(); NewServer.Add(new KeyValuePair <string, string>("admin-slot", "true")); NewServer.Add(new KeyValuePair <string, string>("enable-health", "true")); NewServer.Add(new KeyValuePair <string, string>("hellworld", "false")); NewServer.Add(new KeyValuePair <string, string>("level-name", @"world")); NewServer.Add(new KeyValuePair <string, string>("max-players", "20")); NewServer.Add(new KeyValuePair <string, string>("motd", "Welcome to a YAMS server!")); NewServer.Add(new KeyValuePair <string, string>("online-mode", "true")); NewServer.Add(new KeyValuePair <string, string>("public", "false")); NewServer.Add(new KeyValuePair <string, string>("pvp", "true")); NewServer.Add(new KeyValuePair <string, string>("server-ip", "")); NewServer.Add(new KeyValuePair <string, string>("server-name", "My YAMS MC Server")); NewServer.Add(new KeyValuePair <string, string>("server-port", "25565")); NewServer.Add(new KeyValuePair <string, string>("spawn-animals", "true")); NewServer.Add(new KeyValuePair <string, string>("spawn-monsters", "true")); NewServer.Add(new KeyValuePair <string, string>("verify-names", "true")); NewServer.Add(new KeyValuePair <string, string>("white-list", "false")); Database.NewServer(NewServer, "My First YAMS Server"); //Set our YAMS Defaults Database.SaveSetting("UpdateJAR", "true"); Database.SaveSetting("UpdateSVC", "true"); Database.SaveSetting("UpdateGUI", "true"); Database.SaveSetting("UpdateWeb", "true"); Database.SaveSetting("UpdateAddons", "true"); Database.SaveSetting("RestartOnJarUpdate", "true"); Database.SaveSetting("RestartOnSVCUpdate", "true"); Database.SaveSetting("Memory", "1024"); Database.SaveSetting("EnableJavaOptimisations", "true"); Database.SaveSetting("AdminListenPort", "56552"); //Use an IANA legal internal port 49152 - 65535 Database.SaveSetting("PublicListenPort", Convert.ToString(Networking.TcpPort.FindNextAvailablePort(80))); //Find nearest open port to 80 for public site Database.SaveSetting("ExternalIP", Networking.GetExternalIP().ToString()); Database.SaveSetting("ListenIP", Networking.GetListenIP().ToString()); Database.SaveSetting("UpdateBranch", "live"); //Run an update now AutoUpdate.CheckUpdates(); //Tell the DB that we've run this Database.SaveSetting("FirstRun", "true"); }
public static void UpdateDB() { switch (Convert.ToInt32(GetSetting("DBSchema", "YAMS"))) { case 1: //Update from Schema 1 Database.SaveSetting("StoragePath", Core.RootFolder + @"\servers\"); Database.SaveSetting("DBSchema", "2"); goto case 2; case 2: //Update from Schema 2 Database.SaveSetting("UsageData", "true"); Database.SaveSetting("DBSchema", "3"); goto case 3; case 3: Database.SaveSetting("EnablePortForwarding", "true"); Database.SaveSetting("EnableOpenFirewall", "true"); Database.SaveSetting("YAMSListenIP", Networking.GetListenIP().ToString()); Database.SaveSetting("DBSchema", "4"); goto case 4; //goto case 3; //etc case 4: Database.SaveSetting("DNSName", ""); Database.SaveSetting("DNSSecret", ""); Database.SaveSetting("LastExternalIP", ""); Database.SaveSetting("DBSchema", "5"); goto case 5; case 5: Database.SaveSetting("EnablePublicSite", "true"); Database.SaveSetting("DBSchema", "6"); goto case 6; case 6: break; default: break; } }