This commit is contained in:
commit
35ae6b7f35
5 changed files with 182 additions and 0 deletions
27
.forgejo/workflows/build-simpleserver.yml
Normal file
27
.forgejo/workflows/build-simpleserver.yml
Normal file
|
@ -0,0 +1,27 @@
|
|||
on: [ push ]
|
||||
|
||||
|
||||
jobs:
|
||||
make:
|
||||
name: Build BaseBand SPLServer
|
||||
|
||||
runs-on: 'docker'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Notify Action Start
|
||||
run: bash scripts/webhook.sh "**(SPLServer)** Updating..."
|
||||
- name: Push to Prod Server
|
||||
env:
|
||||
SSH_PRIVATEKEY: ${{ secrets.SSH_PRIVATEKEY }}
|
||||
GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }}
|
||||
BB_HOST: ${{ vars.BB_HOST }}
|
||||
BB_PORT: ${{ vars.BB_PORT }}
|
||||
BB_PATH: ${{ vars.BB_PATH }}
|
||||
run: |
|
||||
bash scripts/push_file.sh index.html
|
||||
bash scripts/push_file.sh server.spl
|
||||
- name: Notify Action Completion
|
||||
if: always()
|
||||
run: bash scripts/webhook.sh "**(SPLServer)** Update complete!"
|
35
index.html
Normal file
35
index.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta name=viewport content="width=device-width height=device-height">
|
||||
<title>BaseBand download server</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>BaseBand downloads</h1>
|
||||
|
||||
This website serves the version information and downloads of BaseBand.
|
||||
|
||||
<h2>1.12.2</h2>
|
||||
|
||||
<h3>Artifacts</h3>
|
||||
<ul>
|
||||
<li><a href="/1.12.2/download/client/release">/1.12.2/download/client/release</a></li>
|
||||
<li><a href="/1.12.2/download/client/main"> /1.12.2/download/client/main</a></li>
|
||||
<li><a href="/1.12.2/download/loader"> /1.12.2/download/loader</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Version information</h3>
|
||||
<a href="/1.12.2/branches">/1.12.2/branches</a>
|
||||
|
||||
<h2>Ednieva</h2>
|
||||
|
||||
<h3>Artifacts</h3>
|
||||
<ul>
|
||||
<li><a href="/ednieva/download/client/release">/ednieva/download/client/release</a></li>
|
||||
<li><a href="/ednieva/download/client/main"> /ednieva/download/client/main</a></li>
|
||||
<li><a href="/ednieva/download/loader"> /ednieva/download/loader</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Version information</h3>
|
||||
<a href="/ednieva/branches">/ednieva/branches</a>
|
||||
|
||||
</body>
|
10
scripts/push_file.sh
Normal file
10
scripts/push_file.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# DO NOT RUN THIS MANUALLY. PUSH TO RELEASE INSTEAD. ( <- unless there is an emergency.)
|
||||
|
||||
|
||||
echo "$SSH_PRIVATEKEY" > ssh_key
|
||||
chmod 700 ssh_key
|
||||
scp -o StrictHostKeyChecking=no -i ssh_key -P "$BB_PORT" "$1" "root@$BB_HOST:$BB_PATH" &&
|
||||
(ssh -o StrictHostKeyChecking=no -i ssh_key -p "$BB_PORT" "root@$BB_HOST" "cd $BB_PATH && bash reload.sh" || true)
|
||||
rm ssh_key
|
1
scripts/webhook.sh
Normal file
1
scripts/webhook.sh
Normal file
|
@ -0,0 +1 @@
|
|||
curl -i -s -o /dev/null -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"$*\n on $(basename "$(git describe --always --all)") with \`$(git log --no-abbrev --oneline | head -n1 | sed -E 's/\w+ (.*)/\1/g')\`\n at $(date)\"}" https://discord.com/api/webhooks/1250323633205940244/yu1v_moeBxWi4YWaRK_s4tNAXUGUJml-E2PbhToccVFo1Ax2_6Iq6R6lEONCKikHBBn4
|
109
server.spl
Normal file
109
server.spl
Normal file
|
@ -0,0 +1,109 @@
|
|||
|
||||
"#httpserver/base.spl" import
|
||||
"#httpserver/static.spl" import
|
||||
|
||||
use net:http:Server
|
||||
1048576 net:http:server:=bufsize
|
||||
|
||||
construct Branch {
|
||||
name
|
||||
commit
|
||||
;
|
||||
construct { this | with name commit this ;
|
||||
name this:=name
|
||||
commit this:=commit
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
construct Branches {
|
||||
main
|
||||
release
|
||||
loader
|
||||
;
|
||||
construct { this | with dir this ;
|
||||
func read-commit { s | with file ;
|
||||
[ "unzip" "-p" file "commit" ] StreamTypes:cmd:create:read-to-end<32>:to-str
|
||||
}
|
||||
"Loader" dir "/BaseBand-Loader.jar" concat read-commit Branch:new this:=loader
|
||||
"Broadway" dir "/BaseBand-release.jar" concat read-commit Branch:new this:=release
|
||||
"Iceland" dir "/BaseBand-main.jar" concat read-commit Branch:new this:=main
|
||||
this properties props-to-json
|
||||
}
|
||||
}
|
||||
|
||||
construct Object404 {
|
||||
error
|
||||
;
|
||||
construct { this | with this ;
|
||||
"Endpoint not found" this:=error
|
||||
this properties props-to-json
|
||||
}
|
||||
}
|
||||
|
||||
construct Refreshed {
|
||||
ok
|
||||
;
|
||||
construct { this | with this ;
|
||||
"true" this:=ok
|
||||
this properties props-to-json
|
||||
}
|
||||
}
|
||||
|
||||
func props-to-json { | with props ;
|
||||
props:last:get<1> dup null eq not if {
|
||||
"\"" swap _str :replace<"\\" "\\\\">:replace<"\"" "\\\""> concat "\"" concat 2 stop
|
||||
} pop
|
||||
"{"
|
||||
props
|
||||
:iter
|
||||
:filter<{ b | :to-stack pop with key ; key ":" eq not key ";" eq not and }>
|
||||
:map<{ s |
|
||||
:to-stack with key value ;
|
||||
"\""
|
||||
key :replace<"\\" "\\\\">:replace<"\"" "\\\""> concat
|
||||
"\": " concat
|
||||
value properties props-to-json concat
|
||||
}>
|
||||
:join<", "> concat
|
||||
"}" concat
|
||||
}
|
||||
|
||||
func main { exitcode | with args ;
|
||||
def server Server:new<"::0" 40002> =server
|
||||
while { 1 } {
|
||||
server:accept &handle-client fork;
|
||||
}
|
||||
}
|
||||
|
||||
func dir { | with client dir location ;
|
||||
dir "/BaseBand-release.jar" concat location "/download/client/release" concat client:serve-file-cached;<"application/octet-stream">
|
||||
dir "/BaseBand-main.jar" concat location "/download/client/main" concat client:serve-file-cached;<"application/octet-stream">
|
||||
dir "/BaseBand-Loader.jar" concat location "/download/loader" concat client:serve-file-cached;<"application/octet-stream">
|
||||
|
||||
location "/branches" concat client:path eq if {
|
||||
dir Branches:new client:write-ok:write-content-type<"application/json">:write-str-body:finish;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func handle-client { | with client ;
|
||||
client:read;
|
||||
"index.html" "/" client:serve-html-cached;
|
||||
|
||||
client "rewrite" "/1.12.2" dir
|
||||
|
||||
client "ednieva" "/ednieva" dir
|
||||
|
||||
"/refresh" client:path eq if {
|
||||
"refresh" println;
|
||||
client:server:cached-files if {
|
||||
client:server:cached-files:clear;
|
||||
}
|
||||
Refreshed:new client:write-ok:write-content-type<"application/json">:write-str-body:finish;
|
||||
}
|
||||
|
||||
client:wrote-body not if {
|
||||
Object404:new client:write-head<404 "Not Found">:write-content-type<"application/json">:write-str-body:finish;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue