initial commit
This commit is contained in:
parent
2fb17756a0
commit
36543e57bb
|
@ -0,0 +1,3 @@
|
|||
work
|
||||
*.zip
|
||||
*.7z
|
14
README.md
14
README.md
|
@ -1,3 +1,15 @@
|
|||
# artemis-portable
|
||||
|
||||
Script to build ARTEMiS with Python and MariaDB bundled
|
||||
Script to build ARTEMiS with Python and MariaDB bundled
|
||||
|
||||
## Build requirements
|
||||
- curl (should be bundled with Windows 10 since forever)
|
||||
- 7zip
|
||||
|
||||
## Run
|
||||
```powershell
|
||||
# maybe needed, maybe not
|
||||
Set-ExecutionPolicy Unrestricted
|
||||
|
||||
.\build.ps1
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
================
|
||||
Portable ARTEMiS
|
||||
================
|
||||
|
||||
This is a portable distribution of ARTEMiS. Python and MariaDB (a variant of MySQL)
|
||||
has been bundled, and the server can simply be started by double-clicking start.bat.
|
||||
|
||||
========================
|
||||
dbutils/importing events
|
||||
========================
|
||||
Follow the official ARTEMiS guides, but replace "python read.py" with "read.bat",
|
||||
and "python dbutils.py" with "dbutils.bat" accordingly.
|
||||
|
||||
========================
|
||||
Credentials
|
||||
========================
|
||||
In case you need it:
|
||||
- database root password: %%MARIADB_ROOT_PASSWORD%%
|
||||
- database aime password: %%MARIADB_AIME_PASSWORD%%
|
||||
- database port: %%MARIADB_PORT%%
|
|
@ -0,0 +1,5 @@
|
|||
@echo off
|
||||
start "artemis-mariadb" /MIN /D mariadb bin\mysqld.exe --console
|
||||
start /B /WAIT /D artemis ..\python\python.exe dbutils.py %*
|
||||
|
||||
taskkill /f /fi "WindowTitle eq artemis-mariadb" /t
|
|
@ -0,0 +1,5 @@
|
|||
@echo off
|
||||
start "artemis-mariadb" /MIN /D mariadb bin\mysqld.exe --console
|
||||
start /B /WAIT /D artemis ..\python\python.exe read.py %*
|
||||
|
||||
taskkill /f /fi "WindowTitle eq artemis-mariadb" /t
|
|
@ -0,0 +1,3 @@
|
|||
@echo off
|
||||
title ARTEMiS
|
||||
type .\scripts\start.ps1 | powershell -noprofile -
|
|
@ -0,0 +1,8 @@
|
|||
$mariadb = Start-Process -NoNewWindow -PassThru -WorkingDirectory mariadb mariadb\bin\mysqld.exe --console
|
||||
Start-Process -Wait -NoNewWindow -WorkingDirectory artemis python\python.exe index.py
|
||||
|
||||
Stop-Process $mariadb.Id
|
||||
|
||||
Write-Output .
|
||||
Write-Output "ARTEMiS has stopped."
|
||||
cmd /c pause
|
|
@ -0,0 +1,3 @@
|
|||
@echo off
|
||||
title Update ARTEMiS
|
||||
type .\scripts\update-artemis.ps1 | powershell -noprofile -
|
|
@ -0,0 +1,26 @@
|
|||
$artemis_branch = "%%ARTEMIS_BRANCH%%"
|
||||
|
||||
$old = Join-Path $(Get-Location) "artemis"
|
||||
$tmpdir = Join-Path $env:TEMP $(New-Guid)
|
||||
New-Item -ItemType Directory -Path $tmpdir
|
||||
|
||||
cd $tmpdir
|
||||
|
||||
Write-Output "[INFO] Downloading ARTEMiS..."
|
||||
Invoke-WebRequest "https://gitea.tendokyu.moe/Hay1tsme/artemis/archive/$artemis_branch.zip" -OutFile "artemis-$artemis_branch.zip"
|
||||
Expand-Archive "artemis-$artemis_branch.zip"
|
||||
Move-Item "artemis-$artemis_branch/artemis" artemis
|
||||
Remove-Item -Recurse "artemis-$artemis_branch"
|
||||
Remove-Item "artemis-$artemis_branch.zip"
|
||||
|
||||
Write-Output "[INFO] Copying files..."
|
||||
(Get-ChildItem "$tmpdir/artemis/*" -Directory).FullName | ForEach-Object { Join-Path $_ '*' } | Copy-Item -Destination "$old" -Recurse
|
||||
|
||||
Set-Location "$old"
|
||||
Write-Output "[INFO] Updating dependencies..."
|
||||
../python/python.exe -m pip install --no-warn-script-location -r requirements.txt
|
||||
|
||||
Remove-Item -Recurse "$tmpdir"
|
||||
|
||||
Write-Output "ARTEMiS update finished."
|
||||
cmd /k pause
|
|
@ -0,0 +1,139 @@
|
|||
$workdir = "work/"
|
||||
$artemis_branch = "develop"
|
||||
$python_version = "3.9.13"
|
||||
$mariadb_version = "10.11.6"
|
||||
|
||||
Remove-Item -Recurse $workdir 2>&1>$null
|
||||
New-Item $workdir -ItemType Directory 2>&1>$null
|
||||
Set-Location $workdir
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Setting up Python
|
||||
# --------------------------------------------------------
|
||||
Write-Output "[INFO] Downloading Python $python_version..."
|
||||
curl.exe -LO "https://www.python.org/ftp/python/$python_version/python-$python_version-embed-amd64.zip"
|
||||
|
||||
Write-Output "[INFO] Extracting Python $python_version..."
|
||||
7z x "python-$python_version-embed-amd64.zip" -opython
|
||||
|
||||
Write-Output "[INFO] Configuring Python $python_version..."
|
||||
7z x python/python39.zip -opython/Lib
|
||||
Remove-Item python/python39.zip
|
||||
Move-Item python/python39._pth python/python39.pth
|
||||
New-Item -ItemType Directory python/DLLs
|
||||
|
||||
curl.exe -L https://bootstrap.pypa.io/get-pip.py | python/python.exe -
|
||||
Remove-Item "python-$python_version-embed-amd64.zip"
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Setting up MariaDB
|
||||
# --------------------------------------------------------
|
||||
$mariadb_root_password = (-join ((65..90) + (97..122) | Get-Random -Count 32 | % {[char]$_}))
|
||||
$mariadb_aime_password = (-join ((65..90) + (97..122) | Get-Random -Count 32 | % {[char]$_}))
|
||||
$mariadb_port = (40000..49151) | Get-Random
|
||||
|
||||
Write-Output "[INFO] Downloading MariaDB $mariadb_version..."
|
||||
curl.exe -LO "https://archive.mariadb.org/mariadb-$mariadb_version/winx64-packages/mariadb-$mariadb_version-winx64.zip"
|
||||
7z.exe x "mariadb-$mariadb_version-winx64.zip"
|
||||
Rename-Item "mariadb-$mariadb_version-winx64" mariadb
|
||||
Remove-Item "mariadb-$mariadb_version-winx64.zip"
|
||||
|
||||
Set-Location mariadb
|
||||
Write-Output "[INFO] Setting up MariaDB on port $mariadb_port..."
|
||||
bin/mysql_install_db.exe --datadir=data --password=$mariadb_root_password "--port=$mariadb_port"
|
||||
../python/python.exe ../../scripts/update_myini.py data/my.ini
|
||||
|
||||
Write-Output "[INFO] Creating user for ARTEMiS..."
|
||||
$process = Start-Process -NoNewWindow -PassThru -RedirectStandardError "NUL" .\bin\mysqld.exe --console
|
||||
bin/mysql.exe --user=root --password=$mariadb_root_password -e "$((Get-Content ../../scripts/artemis.sql) -replace "%%PASSWORD%%", "$mariadb_aime_password")"
|
||||
# don't stop mysqld yet, artemis will need it
|
||||
|
||||
# remove mariadb junk
|
||||
$junk_extensions = ".pdb",".lib"
|
||||
$exclusions = "mysqld","mysql","server"
|
||||
Get-ChildItem bin | ForEach-Object {
|
||||
if ($junk_extensions.Contains($_.Extension)) {
|
||||
Remove-Item $_.FullName
|
||||
return
|
||||
}
|
||||
|
||||
if ($exclusions.Contains($_.BaseName)) { return }
|
||||
|
||||
Remove-Item $_.FullName
|
||||
}
|
||||
Remove-Item -Recurse include
|
||||
Get-ChildItem -Recurse lib | ForEach-Object {
|
||||
if ($junk_extensions.Contains($_.Extension)) {
|
||||
Remove-Item $_.FullName
|
||||
return
|
||||
}
|
||||
|
||||
# other storage engines, we don't care, only innodb for you
|
||||
if ($_.BaseName.StartsWith("ha_")) {
|
||||
Remove-Item $_.FullName
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Item share/*.sql
|
||||
Remove-Item share/*.jar
|
||||
Get-ChildItem -Directory share | ForEach-Object {
|
||||
if ($_.BaseName -ne "english") {
|
||||
Remove-Item -Recurse $_.FullName
|
||||
}
|
||||
}
|
||||
../python/python.exe ../../scripts/remove_mariadb_languages.py share/errmsg-utf8.txt
|
||||
|
||||
Set-Location ..
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Setting up ARTEMiS
|
||||
# ----------------------------------------------------
|
||||
Write-Output "[INFO] Downloading ARTEMiS..."
|
||||
curl.exe -L -o "artemis-$artemis_branch.zip" "https://gitea.tendokyu.moe/Hay1tsme/artemis/archive/$artemis_branch.zip"
|
||||
7z.exe x "artemis-$artemis_branch.zip"
|
||||
Remove-Item "artemis-$artemis_branch.zip"
|
||||
|
||||
Set-Location artemis
|
||||
|
||||
Write-Output "[INFO] Installing dependencies..."
|
||||
../python/python.exe -m pip install --no-warn-script-location -r requirements.txt
|
||||
|
||||
Write-Output "[INFO] Setting up ARTEMiS core configuration..."
|
||||
Copy-Item -Recurse example_config config
|
||||
../python/python.exe ../../scripts/update_artemis_config.py config/core.yaml "$mariadb_aime_password" "$mariadb_port"
|
||||
|
||||
Write-Output "[INFO] Generating ARTEMiS tables..."
|
||||
../python/python.exe dbutils.py create
|
||||
|
||||
Set-Location ..
|
||||
Stop-Process $process.Id
|
||||
Remove-Item "mariadb/data/$env:ComputerName.*"
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Slim down Python install
|
||||
# ----------------------------------------------------
|
||||
python/python.exe -m pip uninstall -y mypy
|
||||
Remove-Item python/pythonw.exe
|
||||
Remove-Item -Recurse python/Include/*
|
||||
Remove-Item -Recurse python/Scripts/*
|
||||
Remove-Item -Recurse python/Lib/pydoc_data
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Pack things up
|
||||
# ----------------------------------------------------
|
||||
Copy-Item ../assets/dbutils.bat .
|
||||
Copy-Item ../assets/read.bat .
|
||||
Copy-Item ../assets/start.bat .
|
||||
Copy-Item ../assets/update-artemis.bat .
|
||||
|
||||
New-Item scripts -ItemType Directory
|
||||
Copy-Item ../assets/start.ps1 scripts/
|
||||
$update_script = (Get-Content ../assets/update-artemis.ps1) -replace "%%ARTEMIS_BRANCH%%", "$artemis_branch"
|
||||
$update_script | Out-File -Force -FilePath scripts/update-artemis.ps1
|
||||
|
||||
$readme = (Get-Content ../assets/README.txt) -replace "%%MARIADB_ROOT_PASSWORD%%", "$mariadb_root_password" -replace "%%MARIADB_AIME_PASSWORD%%", "$mariadb_aime_password" -replace "%%MARIADB_PORT%%", "$mariadb_port"
|
||||
$readme | Out-File -Force -FilePath README.txt
|
||||
|
||||
7z a -t7z ../artemis-portable.7z *
|
||||
|
||||
cd ..
|
|
@ -0,0 +1,4 @@
|
|||
CREATE USER 'aime'@'localhost' IDENTIFIED BY '%%PASSWORD%%';
|
||||
CREATE DATABASE aime;
|
||||
GRANT Alter,Create,Delete,Drop,Index,Insert,References,Select,Update ON aime.* TO 'aime'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
|
@ -0,0 +1,13 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
path = os.path.join(os.getcwd(), sys.argv[1])
|
||||
with open(path, encoding="utf-8") as f:
|
||||
errmsg = f.readlines()
|
||||
|
||||
errmsg[0] = "languages english=eng;\n"
|
||||
errmsg = [line for line in errmsg if not line.startswith(" ") or line.startswith(" eng")]
|
||||
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write("".join(errmsg))
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# This should be run with ARTEMiS's venv instead of the system Python
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
core_config_path = os.path.join(os.getcwd(), sys.argv[1])
|
||||
mariadb_password = sys.argv[2]
|
||||
mariadb_port = int(sys.argv[3])
|
||||
|
||||
with open(core_config_path) as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
config["server"]["listen_address"] = "0.0.0.0"
|
||||
config["server"]["is_develop"] = False
|
||||
config["server"]["threading"] = True
|
||||
|
||||
config["database"]["password"] = mariadb_password
|
||||
config["database"]["port"] = mariadb_port
|
||||
|
||||
config["aimedb"]["key"] = "Copyright(C)SEGA"
|
||||
|
||||
with open(core_config_path, "w") as f:
|
||||
yaml.safe_dump(config, f, sort_keys=False)
|
|
@ -0,0 +1,11 @@
|
|||
import configparser
|
||||
import sys
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(sys.argv[1])
|
||||
config["mysqld"]["datadir"] = "data"
|
||||
config["mysqld"]["bind-address"] = "127.0.0.1"
|
||||
config["client"]["plugin-dir"] = "lib/plugin"
|
||||
|
||||
with open(sys.argv[1], "w") as f:
|
||||
config.write(f)
|
Loading…
Reference in New Issue