Skip to content

Commit

Permalink
update terminal
Browse files Browse the repository at this point in the history
update front-end dependencies
support macOS(darwin)
support shutdown and reboot on macOS
  • Loading branch information
XZB-1248 committed Apr 17, 2022
1 parent 14e0628 commit 6ff0e53
Show file tree
Hide file tree
Showing 28 changed files with 15,205 additions and 7,340 deletions.
202 changes: 142 additions & 60 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,125 @@
name: Build
name: build

on:
push:
tags-ignore:
- '!v*.*.*'

jobs:
build-macOS-clients:
runs-on: macos-latest

build:
strategy:
matrix:
go-version: [ 1.17 ]

steps:
- uses: actions/checkout@v3

- name: Set up golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Build clients
run: |
export COMMIT=`git rev-parse HEAD`
export GOMOD=`pwd`/go.mod
export CGO_ENABLED=1
go mod tidy
go mod download
mkdir ./built
export GOOS=darwin
export GOARCH=arm64
go build -ldflags "-s -w -X 'Spark/client/config.COMMIT=$COMMIT'" -o ./built/darwin_arm64 Spark/client
export GOARCH=amd64
go build -ldflags "-s -w -X 'Spark/client/config.COMMIT=$COMMIT'" -o ./built/darwin_amd64 Spark/client
- name: Upload prebuilt client (darwin_arm64)
uses: actions/upload-artifact@v2
with:
name: darwin_arm64
path: ./built/darwin_arm64

- name: Upload prebuilt client (darwin_amd64)
uses: actions/upload-artifact@v2
with:
name: darwin_amd64
path: ./built/darwin_amd64



build-others:
needs: [ build-macOS-clients ]
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 14.x ]
node-version: [ 16.x ]
go-version: [ 1.17 ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Set up Go
uses: actions/setup-go@v2
- name: Set up golang
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: ${{ matrix.go-version }}

- name: Install statik
run: |
export PATH=$PATH:~/go/bin/
go install github.com/rakyll/statik
- name: Get artifacts from previous job (arm64)
uses: actions/download-artifact@v3
with:
name: darwin_arm64
path: ./built

- name: Get artifacts from previous job (amd64)
uses: actions/download-artifact@v3
with:
name: darwin_amd64
path: ./built

- name: Build and embed clients
run: |
chmod +x ./build.client.sh
export GOMOD=`pwd`/go.mod
export CGO_ENABLED=0
go mod tidy
go mod download
./build.client.sh
statik -m -src="./built" -f -dest="./server/embed" -include=* -p built -ns built
- name: Build and embed static resources
- name: Build and pack static resources
run: |
cd ./web
npm install
npm run build-prod
statik -m -src="./dist" -f -dest="../server/embed" -p web -ns web
cd ..
zip -q -r ./embed.zip ./server/embed
- name: Build server
run: |
chmod +x ./build.server.sh
export GOMOD=`pwd`/go.mod
export CGO_ENABLED=0
go mod tidy
go mod download
mkdir ./releases
./build.server.sh
- name: Install zip and tar
- name: Pack releases
run: |
cd ./releases
sudo apt install zip tar -y
Expand All @@ -71,54 +131,12 @@ jobs:
zip -r server_windows_arm64.zip server_windows_arm64.exe
zip -r server_windows_i386.zip server_windows_i386.exe
zip -r server_windows_amd64.zip server_windows_amd64.exe
- name: Upload binary files (server_linux_arm)
uses: actions/upload-artifact@v2
with:
name: server_linux_arm.tar.gz
path: releases/server_linux_arm.tar.gz
- name: Upload binary files (server_linux_arm64)
- name: Upload embedding resources (embed.zip)
uses: actions/upload-artifact@v2
with:
name: server_linux_arm64.tar.gz
path: releases/server_linux_arm64.tar.gz

- name: Upload binary files (server_linux_i386)
uses: actions/upload-artifact@v2
with:
name: server_linux_i386.tar.gz
path: releases/server_linux_i386.tar.gz

- name: Upload binary files (server_linux_amd64)
uses: actions/upload-artifact@v2
with:
name: server_linux_amd64.tar.gz
path: releases/server_linux_amd64.tar.gz

- name: Upload binary files (server_windows_arm)
uses: actions/upload-artifact@v2
with:
name: server_windows_arm.zip
path: releases/server_windows_arm.zip

- name: Upload binary files (server_windows_arm64)
uses: actions/upload-artifact@v2
with:
name: server_windows_arm64.zip
path: releases/server_windows_arm64.zip

- name: Upload binary files (server_windows_i386)
uses: actions/upload-artifact@v2
with:
name: server_windows_i386.zip
path: releases/server_windows_i386.zip

- name: Upload binary files (server_windows_amd64)
uses: actions/upload-artifact@v2
with:
name: server_windows_amd64.zip
path: releases/server_windows_amd64.zip
name: embed.zip
path: embed.zip

- name: Release
uses: softprops/action-gh-release@v1
Expand All @@ -133,4 +151,68 @@ jobs:
releases/server_windows_arm.zip
releases/server_windows_arm64.zip
releases/server_windows_i386.zip
releases/server_windows_amd64.zip
releases/server_windows_amd64.zip
build-macOS-servers:
needs: [ build-others ]
runs-on: macos-latest

strategy:
matrix:
go-version: [ 1.17 ]

steps:
- uses: actions/checkout@v3

- name: Set up golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Get artifacts from previous job (embed.zip)
uses: actions/download-artifact@v3
with:
name: embed.zip
path: .

- name: Build and compress servers
run: |
rm -rf ./server/embed
unzip -q embed.zip
export COMMIT=`git rev-parse HEAD`
export GOMOD=`pwd`/go.mod
export CGO_ENABLED=0
go mod tidy
go mod download
mkdir ./releases
export GOOS=darwin
export GOARCH=arm64
go build -ldflags "-s -w -X 'Spark/server/config.COMMIT=$COMMIT'" -tags=jsoniter -o ./releases/server_darwin_arm64 Spark/server
export GOARCH=amd64
go build -ldflags "-s -w -X 'Spark/server/config.COMMIT=$COMMIT'" -tags=jsoniter -o ./releases/server_darwin_amd64 Spark/server
cd ./releases
tar -zcvf server_darwin_arm64.tar.gz server_darwin_arm64
tar -zcvf server_darwin_amd64.tar.gz server_darwin_amd64
cd ..
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
releases/server_darwin_arm64.tar.gz
releases/server_darwin_amd64.tar.gz
- name: Clean up
uses: geekyeggo/delete-artifact@v1
with:
name: |
embed.zip
darwin_arm64
darwin_amd64
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
## v0.0.5

* Add: server and client now support macOS.
* Add: shutdown and reboot on macOS (root permission required).
* Update: pty are used on Unix-like OS to provide a full-functional terminal.
* Update: improved the support of terminal on Windows and fixed some bugs.

* 新增:服务端和客户端已支持macOS系统。
* 新增:macOS现在将支持关机和重启功能(需要root权限)。
* 更新:类unix系统的终端现已改用pty实现,以提供完整的终端功能。
* 更新:改进了windows下的终端表现,修复了一些bug。



## v0.0.4

* Add: i18n support
* Add: i18n support.
* Note: from this version, you just need to upgrade server manually and client will automatically self upgrade.

* 新增:支持中英文国际化
* 注意:从本版本开始,只需要更新服务端即可,客户端会自动完成更新
* 新增:支持中英文国际化
* 注意:从本版本开始,只需要更新服务端即可,客户端会自动完成更新



Expand Down
17 changes: 9 additions & 8 deletions README.ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@
|-------|---------|-------|-------|
| 进程管理 ||||
| 结束进程 ||||
| 文件浏览器 ||||
| 文件浏览Ï ||||
| 文件传输 ||||
| 删除文件 ||||
| 系统信息 ||||
| Shell ||||
| 远程终端 ||||
| 屏幕快照 ||||
| 关机 ||| |
| 重启 ||| |
| 休眠 ||||
| 睡眠 ||||
| 注销 ||||
| 锁屏 ||||
| * 关机 ||| |
| * 重启 ||| |
| * 休眠 ||||
| * 睡眠 ||||
| * 注销 ||||
| * 锁屏 ||||

* 空单元格代表目前暂未测试。
* 星号代表该功能可能需要管理员或root权限才能使用。

---

Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ Only local installation are available yet.
| File transfer ||||
| Delete file ||||
| OS info ||||
| Shell ||||
| Terminal ||||
| Screenshot ||||
| Shutdown ||| |
| Reboot ||| |
| Hibernate ||||
| Sleep ||||
| Log off ||||
| Lock screen ||||
| * Shutdown ||| |
| * Reboot ||| |
| * Hibernate ||||
| * Sleep ||||
| * Log off ||||
| * Lock screen ||||

* Blank cell means the situation is not tested yet.
* The Star symbol means the function may need administration or root privilege.

---

Expand Down
1 change: 0 additions & 1 deletion build.client.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set GO111MODULE=auto
mkdir .\built
for /F %%i in ('git rev-parse HEAD') do ( set COMMIT=%%i)


Expand Down
1 change: 0 additions & 1 deletion build.client.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export GO111MODULE=auto
mkdir ./built
export COMMIT=`git rev-parse HEAD`


Expand Down
1 change: 0 additions & 1 deletion build.server.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export GO111MODULE=auto
mkdir ./releases
export COMMIT=`git rev-parse HEAD`


Expand Down
2 changes: 2 additions & 0 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ func handleAct(pack modules.Packet, wsConn *common.Conn) {
}
case `inputTerminal`:
terminal.InputTerminal(pack)
case `resizeTerminal`:
terminal.ResizeTerminal(pack)
case `killTerminal`:
terminal.KillTerminal(pack)
case `listFiles`:
Expand Down
8 changes: 6 additions & 2 deletions client/service/basic/basic_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ func Logoff() error {
}

func Hibernate() error {
return syscall.Reboot(syscall.LINUX_REBOOT_CMD_HALT)
// Prevent constant overflow when GOARCH is arm or i386.
_, _, err := syscall.Syscall(syscall.SYS_REBOOT, syscall.LINUX_REBOOT_CMD_HALT, 0, 0)
return err
}

func Suspend() error {
return syscall.Reboot(syscall.LINUX_REBOOT_CMD_SW_SUSPEND)
// Prevent constant overflow when GOARCH is arm or i386.
_, _, err := syscall.Syscall(syscall.SYS_REBOOT, syscall.LINUX_REBOOT_CMD_SW_SUSPEND, 0, 0)
return err
}

func Restart() error {
Expand Down
Loading

0 comments on commit 6ff0e53

Please sign in to comment.