summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-06-01 16:37:20 +0200
committerGitHub <noreply@github.com>2019-06-01 16:37:20 +0200
commitf6505f67237e7381eb364212789531421e60bd5a (patch)
tree529bf10ba9f0901691e171dbe3f4b93357308a08
parent69abd68efd576efa86462cbed7c6d1579abd7d76 (diff)
parent9813890b1b0e9dfe1e795c4bcd7fbb0d9cfb7131 (diff)
downloadhercules-f6505f67237e7381eb364212789531421e60bd5a.tar.gz
hercules-f6505f67237e7381eb364212789531421e60bd5a.tar.bz2
hercules-f6505f67237e7381eb364212789531421e60bd5a.tar.xz
hercules-f6505f67237e7381eb364212789531421e60bd5a.zip
Merge pull request #2222 from Helianthella/scoop
Simplify windows installation
-rw-r--r--README.md77
-rw-r--r--mariadb.bat15
-rw-r--r--tools/install_mariadb.bat7
-rw-r--r--tools/setup_mariadb.ps190
4 files changed, 159 insertions, 30 deletions
diff --git a/README.md b/README.md
index b17eedbda..0b4257b3b 100644
--- a/README.md
+++ b/README.md
@@ -52,14 +52,11 @@ Before installing Hercules, you will need to install certain tools and applicati
This differs between the varying Operating Systems available, so the
following list is broken down into Windows and Unix (incl. Linux) prerequisites.
-For a list of supported platforms, please refer to the [Supported
-Platforms](https://github.com/HerculesWS/Hercules/wiki/Supported-Platforms) wiki page.
+For a list of supported platforms, please refer to the [Supported Platforms](https://github.com/HerculesWS/Hercules/wiki/Supported-Platforms) wiki page.
#### Windows
- - Git client
- - MySQL-compatible server ([MySQL Community Edition](https://www.mysql.com/products/community/) or
- [MariaDB](https://mariadb.org/))
- - Microsoft Visual Studio ([Version 2012 through 2015](https://www.visualstudio.com/))
+ - [Git client](https://git-scm.com/)
+ - [Microsoft Visual Studio Community](https://visualstudio.microsoft.com/vs/community/)
#### Unix/Linux/BSD (names of packages may require specific version numbers on certain distributions)
- git
@@ -85,10 +82,20 @@ Platforms](https://github.com/HerculesWS/Hercules/wiki/Supported-Platforms) wiki
- MySQL GUI clients
- [MySQL Workbench](http://www.mysql.com/downloads/workbench/) (cross-platform)
- [HeidiSQL](http://www.heidisql.com/) (Windows)
+ - [DBeaver](http://dbeaver.jkiss.org/) (cross-platform)
- [Sequel Pro](http://www.sequelpro.com/) (Mac OS X)
+ - *More options available at [mariadb.com](https://mariadb.com/kb/en/library/graphical-and-enhanced-clients/)*
- GUI Git clients
+ - [GitHub Desktop](https://desktop.github.com/) (cross-platform)
+ - [GitKraken](https://www.gitkraken.com/git-client) (cross-platform)
+ - [SmartGit](https://www.syntevo.com/smartgit/) (cross-platform)
- [Atlassian SourceTree](https://www.sourcetreeapp.com/) (Windows, Mac OS X)
- - [TortoiseGit](https://tortoisegit.org/) (Windows)
+ - *More options available at [git-scm.com](https://git-scm.com/downloads/guis)*
+ - Text editors with syntax highlighting
+ - [Visual Studio Code](https://code.visualstudio.com) (cross-platform)
+ - [Atom](https://atom.io) (cross-platform)
+ - [Notepad++](https://notepad-plus-plus.org) (Windows)
+ - *More options available at [wikipedia.org](https://en.wikipedia.org/wiki/Comparison_of_text_editors#Overview)*
## Installation
@@ -99,39 +106,49 @@ guides relevant to your Operation System, please refer to the Wiki (links at
the end of this file).
#### Windows
+##### Easy installation
1. Install the prerequisites.
- 2. Clone the Hercules repository (see [GitHub](https://github.com/HerculesWS/Hercules)) using a git client, into a new
+ 2. Clone the [Hercules repository](https://github.com/HerculesWS/Hercules) using a git client, into a new
folder.
- 3. Connect to the MySQL server as root:
- - Create a database (hercules): `CREATE DATABASE hercules;`
- - Create a user (hercules): `CREATE USER 'hercules'@'localhost' IDENTIFIED BY 'password';`.
- - Give permissions (GRANT SELECT,INSERT,UPDATE,DELETE) to the user: `GRANT SELECT,INSERT,UPDATE,DELETE ON hercules.* TO 'hercules'@'localhost';`
- 4. Connect to the MySQL server as the new user:
- - Import the .sql files in /sql-files/ into the new database.
- 5. Start Visual Studio and load the provided solution:
- - Compile and run the three projects, login-server, char-server, map-server.
+ - If you do not want to use the command line, you can instead clone with [GitHub Desktop](https://desktop.github.com/).
+ 3. Run `mariadb.bat` to automatically install and configure MariaDB.
+ 4. Start Visual Studio and load the provided solution:
+ - Compile and run the three projects, login-server, char-server, map-server.
+##### Manual installation
+ 1. Install the prerequisites.
+ 2. Install a MySQL-compatible server, such as [MariaDB](https://mariadb.org/) (recommended) or [MySQL Community Edition](https://www.mysql.com/products/community/)
+ 3. Clone the Hercules repository [Hercules repository](https://github.com/HerculesWS/Hercules) using a git client, into a new
+ folder.
+ 4. Connect to the MySQL server as root:
+ - Create a database (hercules): `CREATE DATABASE hercules;`
+ - Create a user (hercules): `CREATE USER 'hercules'@'localhost' IDENTIFIED BY 'password';`.
+ - Give permissions (GRANT SELECT,INSERT,UPDATE,DELETE) to the user: `GRANT SELECT,INSERT,UPDATE,DELETE ON hercules.* TO 'hercules'@'localhost';`
+ 5. Connect to the MySQL server as the new user:
+ - Import the .sql files in /sql-files/ into the new database.
+ 6. Start Visual Studio and load the provided solution:
+ - Compile and run the three projects, login-server, char-server, map-server.
#### Unix
1. Install the prerequisites through your distribution's package manager
- - (Red Hat compatible / CentOS) `yum install gcc make mysql mysql-devel mysql-server pcre-devel zlib-devel git`
- - (Debian compatible) `apt-get install gcc make libmysqlclient-dev zlib1g-dev libpcre3-dev mysql-server git`
- - (FreeBSD) `pkg install clang35 gmake mysql56-server mysql-connector-c pcre git`
- - (Mac OS X):
- - Install Xcode through the Mac App Store
- - Initialize the build tools through the Terminal `xcode-select --help`
- - Install Homebrew as described on the project page
- - Install the other prerequisites: `brew install mysql pcre`
+ - (Red Hat compatible / CentOS) `yum install gcc make mysql mysql-devel mysql-server pcre-devel zlib-devel git`
+ - (Debian compatible) `apt-get install gcc make libmysqlclient-dev zlib1g-dev libpcre3-dev mysql-server git`
+ - (FreeBSD) `pkg install clang35 gmake mysql56-server mysql-connector-c pcre git`
+ - (Mac OS X):
+ - Install Xcode through the Mac App Store
+ - Initialize the build tools through the Terminal `xcode-select --help`
+ - Install Homebrew as described on the project page
+ - Install the other prerequisites: `brew install mysql pcre`
2. Clone the Hercules repository `git clone https://github.com/HerculesWS/Hercules.git ~/Hercules`
3. Configure the MySQL server and start it.
4. Connect to the MySQL server as root:
- - Create a database (hercules): `CREATE DATABASE hercules;`
- - Create a user (hercules): `CREATE USER 'hercules'@'localhost' IDENTIFIED BY 'password';`.
- - Give permissions (GRANT SELECT,INSERT,UPDATE,DELETE) to the user: `GRANT SELECT,INSERT,UPDATE,DELETE ON hercules.* TO 'hercules'@'localhost';`
+ - Create a database (hercules): `CREATE DATABASE hercules;`
+ - Create a user (hercules): `CREATE USER 'hercules'@'localhost' IDENTIFIED BY 'password';`.
+ - Give permissions (GRANT SELECT,INSERT,UPDATE,DELETE) to the user: `GRANT SELECT,INSERT,UPDATE,DELETE ON hercules.* TO 'hercules'@'localhost';`
5. Connect to the MySQL server as the new user:
- - Import the .sql files in /sql-files/ into the new database.
+ - Import the .sql files in /sql-files/ into the new database.
6. Enter the Hercules directory and configure/build Hercules
- - `./configure`
- - `make clean && make sql` (on FreeBSD, replace `make` with `gmake`)
+ - `./configure`
+ - `make clean && make sql` (on FreeBSD, replace `make` with `gmake`)
7. Start the three servers login-server, char-server, map-server.
## Troubleshooting
diff --git a/mariadb.bat b/mariadb.bat
new file mode 100644
index 000000000..67d7c39a3
--- /dev/null
+++ b/mariadb.bat
@@ -0,0 +1,15 @@
+@echo off
+
+WHERE powershell.exe >nul 2>nul
+IF %ERRORLEVEL% NEQ 0 (
+ ECHO ERROR: PowerShell is not installed on this computer!
+ ECHO Please download it here:
+ ECHO https://github.com/PowerShell/PowerShell#get-powershell
+ ECHO.
+ ECHO Once it is installed, please re-launch mariadb.bat
+ pause >nul
+ exit
+)
+
+powershell -NoLogo -ExecutionPolicy Bypass -File "%~dp0\tools\setup_mariadb.ps1"
+pause >nul
diff --git a/tools/install_mariadb.bat b/tools/install_mariadb.bat
new file mode 100644
index 000000000..cfe2ce3b7
--- /dev/null
+++ b/tools/install_mariadb.bat
@@ -0,0 +1,7 @@
+@echo off
+
+:: this file installs the mariadb service
+
+if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
+mysqld.exe --install "MySQL"
+net start MySQL
diff --git a/tools/setup_mariadb.ps1 b/tools/setup_mariadb.ps1
new file mode 100644
index 000000000..709a5cf93
--- /dev/null
+++ b/tools/setup_mariadb.ps1
@@ -0,0 +1,90 @@
+#Requires -Version 5.1
+
+function Ask-Continue { Write-Output ""; pause; Write-Output "" }
+
+Write-Output "This script will automatically install MariaDB and configure it for you."
+Write-Output "You may interrupt the installation by pressing CTRL+C or closing this window."
+Ask-Continue
+
+if (-Not (Select-String -Quiet -SimpleMatch -Pattern "db_password: ""ragnarok""" -LiteralPath "$PSScriptRoot\..\conf\global\sql_connection.conf")) {
+ Write-Output "WARNING: It seems you already configured the sql connection for your server."
+ Write-Output "If you decide to continue, your settings will be overwritten."
+ Ask-Continue
+}
+
+# step 1: install scoop
+if (-Not (Get-Command scoop -errorAction SilentlyContinue)) {
+ Set-ExecutionPolicy RemoteSigned -scope Process -Force # <= this will trigger a yes/no prompt if not already authorized
+ Invoke-Expression (new-object net.webclient).downloadstring('https://get.scoop.sh')
+ scoop update
+}
+
+# step 2: install mariadb
+if (Test-Path $env:USERPROFILE\scoop\apps\mariadb) {
+ # usually we'd want to capture the output of "scoop list mariadb", but it uses
+ # Write-Host, so we can't, hence why we check manually for the folder
+ Write-Output "WARNING: MariaDB is already installed!"
+ Write-Output "If you decide to continue, your hercules user password will be overwritten."
+ Ask-Continue
+} elseif (Get-Command mysqld -errorAction SilentlyContinue) {
+ Write-Output "ERROR: You already have a MySQL provider installed. To avoid conflict, MariaDB will not be installed."
+ Write-Output "If you wish to continue you will have to uninstall your current MySQL provider."
+ exit 1
+} else {
+ scoop install mariadb
+}
+
+# step 3: add the herc user, set up the new database
+$userpw = -join ((48..57) + (97..122) | Get-Random -Count 32 | % {[char]$_})
+$rootpw = -join ((48..57) + (97..122) | Get-Random -Count 32 | % {[char]$_})
+$maria_job = Start-Process -NoNewWindow -FilePath "mysqld.exe" -ArgumentList "--console" -PassThru -RedirectStandardError "$PSScriptRoot\maria.out"
+
+while (-Not $maria_job.HasExited) {
+ if ($lt -Lt 1 -And (Select-String -Quiet -SimpleMatch -Pattern "ready for connections" -LiteralPath "$PSScriptRoot\maria.out")) {
+@"
+CREATE DATABASE IF NOT EXISTS hercules;
+DROP USER IF EXISTS 'hercules'@'localhost';
+DROP USER IF EXISTS 'hercules'@'127.0.0.1';
+CREATE USER 'hercules'@'localhost' IDENTIFIED BY '$userpw';
+CREATE USER 'hercules'@'127.0.0.1' IDENTIFIED BY '$userpw';
+-- ALTER USER 'root'@'localhost' IDENTIFIED BY '$rootpw';
+GRANT ALTER,CREATE,SELECT,INSERT,UPDATE,DELETE,DROP,INDEX ON `hercules`.* TO 'hercules'@'localhost';
+GRANT ALTER,CREATE,SELECT,INSERT,UPDATE,DELETE,DROP,INDEX ON `hercules`.* TO 'hercules'@'127.0.0.1';
+FLUSH PRIVILEGES;
+USE `hercules`;
+\. $PSScriptRoot\..\sql-files\main.sql
+\. $PSScriptRoot\..\sql-files\logs.sql
+shutdown;
+\q
+"@ | mysql.exe -u root
+ $lt++
+ }
+ Start-Sleep 1
+}
+
+if ($lt -Lt 1) {
+ Write-Output "ERROR: MariaDB could not execute the query."
+ Write-Output "This might happen if your root user already has a password, or if the MySQL service is currently running."
+ $maria_job.close()
+ exit 1
+}
+
+# step 4: finish up
+@"
+sql_connection: {
+ db_username: "hercules"
+ db_password: "$userpw"
+ db_database: "hercules"
+}
+"@ | Out-File -Encoding UTF8 -LiteralPath "$PSScriptRoot\..\conf\global\sql_connection.conf"
+Remove-Item -Force -errorAction SilentlyContinue "$PSScriptRoot\maria.out"
+& "$PSScriptRoot\install_mariadb.bat" # <= we need admin permissions, so we use an external script
+Write-Output "========= ALL DONE ========="
+Write-Output ""
+Write-Output "Your hercules installation is now configured to use MariaDB."
+Write-Output "You can find the password in conf\global\sql_connection.conf."
+Write-Output ""
+Write-Output "If you want to start MariaDB on boot, use services.msc and set ""MySQL"" to Automatic."
+Write-Output ""
+Write-Output "Make sure you set a password for the root user. You can do this from the command line or from HeidiSQL."
+Write-Output "You can obtain HeidiSQL at https://www.microsoft.com/store/productId/9NXPRT2T0ZJF"