Skip to content

Commit

Permalink
Update project to include database scripts for publishing (#2736)
Browse files Browse the repository at this point in the history
* Update project to include database scripts for publishing

* Update ACE.Server.csproj

* Auto setup/init for SQL dbs

* Update VersionConstant.cs

* Update Program.cs

* Update Program.cs

* Update Program.cs

* Automatically promote first account to Admin

* Update Program.cs

* Update Program.cs

* Update Program.cs

* Update ACE.Server.csproj

* Update ACE.Server.csproj
  • Loading branch information
LtRipley36706 authored Feb 29, 2020
1 parent e7e2625 commit 8179766
Show file tree
Hide file tree
Showing 5 changed files with 362 additions and 85 deletions.
10 changes: 10 additions & 0 deletions Source/ACE.Database/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ public static void Initialize(bool autoRetry = true)
{
Authentication.Exists(true);

if (Authentication.GetListofAccountsByAccessLevel(ACE.Entity.Enum.AccessLevel.Admin).Count == 0)
{
log.Warn("Database does not contain any admin accounts. The next account to be created will automatically be promoted to an Admin account.");
AutoPromoteNextAccountToAdmin = true;
}
else
AutoPromoteNextAccountToAdmin = false;

World.Exists(true);

var playerWeenieLoadTest = World.GetCachedWeenie("human");
Expand All @@ -34,6 +42,8 @@ public static void Initialize(bool autoRetry = true)
shardDb.Exists(true);
}

public static bool AutoPromoteNextAccountToAdmin { get; set; }

public static void Start()
{
serializedShardDb.Start();
Expand Down
20 changes: 15 additions & 5 deletions Source/ACE.Server/ACE.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Config.json" />
<None Remove="log4net.config" />
<None Remove="starterGear.json" />
<None Include="..\..\LICENSE">
<Pack>True</Pack>
Expand All @@ -40,6 +38,7 @@
<ItemGroup>
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Log4Net.Async.Standard" Version="3.1.0" />
<PackageReference Include="MySql.Data" Version="8.0.19" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
</ItemGroup>
Expand Down Expand Up @@ -75,12 +74,23 @@
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
<None Include="..\..\Database\Archive\**" CopyToOutputDirectory="PreserveNewest" LinkBase="DatabaseSetupScripts\Archive\" />
<None Include="..\..\Database\Base\**" CopyToOutputDirectory="PreserveNewest" LinkBase="DatabaseSetupScripts\Base\" />
<None Include="..\..\Database\Updates\**" CopyToOutputDirectory="PreserveNewest" LinkBase="DatabaseSetupScripts\Updates\" />
<None Include="..\..\Database\Optional\**" CopyToOutputDirectory="PreserveNewest" LinkBase="DatabaseSetupScripts\Optional\" />
</ItemGroup>

<Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
<ItemGroup>
<ReferencePath Condition="'%(FileName)' == 'MySqlConnector'">
<Aliases>MySqlConnectorAlias</Aliases>
</ReferencePath>
</ItemGroup>
</Target>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="if not exist &quot;$(ProjectDir)Config.js&quot; if exist &quot;$(ProjectDir)Config.json&quot; move &quot;$(ProjectDir)Config.json&quot; &quot;$(ProjectDir)Config.js&quot;&#xD;&#xA;copy &quot;$(ProjectDir)Config.js&quot; &quot;$(TargetDir)Config.js&quot;&#xD;&#xA;if not exist &quot;$(ProjectDir)log4net.config&quot; if exist &quot;$(ProjectDir)log4net.config&quot; copy &quot;$(ProjectDir)log4net.config&quot; &quot;$(TargetDir)log4net.config&quot;" Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="if [ ! -f &quot;$(ProjectDir)Config.js&quot; ] &amp;&amp; [ -f &quot;$(ProjectDir)Config.json&quot; ] ; then mv &quot;$(ProjectDir)Config.json&quot; &quot;$(ProjectDir)Config.js&quot; ; fi&#xA;cp &quot;$(ProjectDir)Config.js&quot; &quot;$(TargetDir)Config.js&quot;" Condition="'$(OS)' != 'Windows_NT'" />
<Exec Command="copy &quot;$(ProjectDir)Config.js&quot; &quot;$(TargetDir)Config.js&quot;&#xD;&#xA;if not exist &quot;$(ProjectDir)log4net.config&quot; if exist &quot;$(TargetDir)log4net.config&quot; copy &quot;$(TargetDir)log4net.config&quot; &quot;$(ProjectDir)log4net.config&quot;&#xD;&#xA;if exist &quot;$(ProjectDir)log4net.config&quot; copy &quot;$(ProjectDir)log4net.config&quot; &quot;$(TargetDir)log4net.config&quot;" Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command="cp &quot;$(ProjectDir)Config.js&quot; &quot;$(TargetDir)Config.js&quot;&#xD;&#xA;if [ ! -f &quot;$(ProjectDir)log4net.config&quot; ] &amp;&amp; [ -f &quot;$(TargetDir)log4net.config&quot; ] ; then cp &quot;$(TargetDir)log4net.config&quot; &quot;$(ProjectDir)log4net.config&quot; ; fi&#xD;&#xA;if [ -f &quot;$(ProjectDir)log4net.config&quot; ] ; then cp &quot;$(ProjectDir)log4net.config&quot; &quot;$(TargetDir)log4net.config&quot; ; fi" Condition="'$(OS)' != 'Windows_NT'" />
</Target>

</Project>
7 changes: 7 additions & 0 deletions Source/ACE.Server/Network/Handlers/AuthenticationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ private static void DoLogin(Session session, PacketInboundLoginRequest loginRequ
if (!System.Enum.IsDefined(typeof(AccessLevel), accessLevel))
accessLevel = AccessLevel.Player;

if (DatabaseManager.AutoPromoteNextAccountToAdmin)
{
accessLevel = AccessLevel.Admin;
DatabaseManager.AutoPromoteNextAccountToAdmin = false;
log.Warn($"Automatically setting account AccessLevel to Admin for account \"{loginRequest.Account}\" because there are no admin accounts in the current database.");
}

account = DatabaseManager.Authentication.CreateAccount(loginRequest.Account.ToLower(), loginRequest.Password, accessLevel, session.EndPoint.Address);
}
}
Expand Down
Loading

0 comments on commit 8179766

Please sign in to comment.