Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f020c1162d | ||
|
|
37130966cf | ||
|
|
a6ceee7bc0 | ||
|
|
a5fee0ee97 | ||
|
|
cad7af13af | ||
|
|
2ed372b3cd | ||
|
|
8bca76b78b | ||
|
|
4939fe10aa | ||
|
|
d7d53d639b | ||
|
|
7191735737 | ||
|
|
ba77e07e36 | ||
|
|
b1d5d9858b | ||
|
|
812ffd56a8 | ||
|
|
5cdd842a3e | ||
|
|
b3aa22605d | ||
|
|
39ccbe251f | ||
|
|
8a28d3c589 | ||
|
|
fb15695dab | ||
|
|
5f5091f1e2 | ||
|
|
df92766c74 | ||
|
|
cc8b3e8f06 | ||
|
|
a116db8dbd | ||
|
|
d697547cb7 | ||
|
|
01960c0391 | ||
|
|
953c393e71 | ||
|
|
0873f7dd46 | ||
|
|
8d93a7f320 | ||
|
|
801eca0a14 | ||
|
|
a3ec7b70c9 | ||
|
|
4a77548b23 | ||
|
|
15ccade3d3 | ||
|
|
587fb6fb8a | ||
|
|
5bcb663ac8 | ||
|
|
cbd945536d | ||
|
|
081e9213c2 | ||
|
|
966fae2d4c | ||
|
|
dc4f9ea990 | ||
|
|
05b9c75714 | ||
|
|
4aeeea2325 | ||
|
|
72531cf6c2 | ||
|
|
9ad9be8c61 | ||
|
|
1aa15932a0 | ||
|
|
dbc6a4265a | ||
|
|
edea1f144a | ||
|
|
85c59c03cf | ||
|
|
a1f57bf1d1 | ||
|
|
e6f2c46c28 | ||
|
|
55c6c21aa3 |
132
.github/workflows/casa.yml
vendored
@@ -3,10 +3,20 @@
|
||||
name: Build CasaOS
|
||||
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
repository_dispatch:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ssh:
|
||||
description: 'SSH connection to Actions'
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
#on:
|
||||
# push:
|
||||
# branches:
|
||||
# - 'main'
|
||||
# tags:
|
||||
# - 'v*'
|
||||
env:
|
||||
REPO_URL: https://github.com/IceWhaleTech/CasaOS.git
|
||||
REPO_BRANCH: main
|
||||
@@ -24,27 +34,44 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Get release
|
||||
id: get_release
|
||||
uses: bruceadams/get-release@v1.2.3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
# - name: Get release
|
||||
# id: get_release
|
||||
# uses: bruceadams/get-release@v1.2.3
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Initialization environment
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
run: |
|
||||
sudo timedatectl set-timezone "$TZ"
|
||||
sudo mkdir -p /workdir
|
||||
sudo chown $USER:$GROUPS /workdir
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
# - name: Initialization environment
|
||||
# env:
|
||||
# DEBIAN_FRONTEND: noninteractive
|
||||
# run: |
|
||||
# sudo timedatectl set-timezone "$TZ"
|
||||
# sudo mkdir -p /workdir
|
||||
# sudo chown $USER:$GROUPS /workdir
|
||||
|
||||
- name: Clone source code
|
||||
working-directory: /workdir
|
||||
|
||||
|
||||
|
||||
|
||||
# - name: Clone source code
|
||||
# working-directory: /workdir
|
||||
# run: |
|
||||
# df -hT $PWD
|
||||
# git clone $REPO_URL -b $REPO_BRANCH --recursive casa
|
||||
# ln -sf /workdir/casa $GITHUB_WORKSPACE/casa
|
||||
# ls
|
||||
|
||||
|
||||
- name: Set enviroment for github-release
|
||||
run: |
|
||||
df -hT $PWD
|
||||
git clone $REPO_URL -b $REPO_BRANCH --recursive casa
|
||||
ln -sf /workdir/casa $GITHUB_WORKSPACE/casa
|
||||
ls
|
||||
echo "VERSION=$(cat types/system.go | grep CURRENTVERSION | awk '$2 == "CURRENTVERSION"{print $4}' | sed 's/"//g')" >>$GITHUB_ENV
|
||||
echo "BODY=$(cat types/system.go | grep BODY | awk -F= '{print $2}' | sed 's/"//g')" >>$GITHUB_ENV
|
||||
|
||||
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
@@ -52,51 +79,70 @@ jobs:
|
||||
|
||||
- name: Build frontend with nodejs and yarn
|
||||
run: |
|
||||
cd casa/UI
|
||||
cd UI
|
||||
ls
|
||||
yarn install
|
||||
yarn build
|
||||
|
||||
- name: list work
|
||||
run: pwd
|
||||
|
||||
- name: Build with xgo
|
||||
uses: crazy-max/ghaction-xgo@v1
|
||||
with:
|
||||
working_dir: /workdir/casa
|
||||
xgo_version: latest
|
||||
go_version: ${{ matrix.go_version }}
|
||||
dest: build
|
||||
prefix: casa
|
||||
targets: linux/amd64,linux/arm64
|
||||
targets: linux/amd64,linux/arm64,linux/arm-7
|
||||
v: true
|
||||
x: false
|
||||
race: false
|
||||
ldflags: -s -w
|
||||
buildmode: default
|
||||
|
||||
- name: List Files
|
||||
run: |
|
||||
ls
|
||||
cd casa/build
|
||||
ls
|
||||
echo "::set-output name=status::success"
|
||||
#
|
||||
# - name: List Files
|
||||
# run: |
|
||||
# ls
|
||||
# mkdir build
|
||||
# ls
|
||||
# echo "::set-output name=status::success"
|
||||
|
||||
- name: Pack builds
|
||||
run: |
|
||||
cd /workdir
|
||||
wget $PACK_SH_URL
|
||||
chmod +x $PACK_SH
|
||||
./$PACK_SH
|
||||
echo "::set-output name=status::success"
|
||||
- name: list work
|
||||
run: ls
|
||||
|
||||
- name: Upload linux-amd64-casaos.tar.gz
|
||||
id: upload_assets_amd64
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ steps.get_release.outputs.upload_url }}
|
||||
asset_path: /workdir/casa/upload/linux-amd64-casaos.tar.gz
|
||||
|
||||
- name: Upload linux-arm64-casaos.tar.gz
|
||||
id: upload_assets_arm64
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
- name: Update release
|
||||
uses: meeDamian/github-release@2.0
|
||||
with:
|
||||
upload_url: ${{ steps.get_release.outputs.upload_url }}
|
||||
asset_path: /workdir/casa/upload/linux-arm64-casaos.tar.gz
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: >
|
||||
linux-amd64-casaos.tar.gz
|
||||
linux-arm64-casaos.tar.gz
|
||||
linux-arm-7-casaos.tar.gz
|
||||
tag: v${{ env.VERSION }}
|
||||
body: >
|
||||
${{ env.BODY }}
|
||||
name: v${{ env.VERSION }}
|
||||
gzip: false
|
||||
allow_override: false
|
||||
prerelease: true
|
||||
# - name: Upload linux-amd64-casaos.tar.gz
|
||||
# id: upload_assets_amd64
|
||||
# uses: shogo82148/actions-upload-release-asset@v1
|
||||
# with:
|
||||
# upload_url: ${{ steps.get_release.outputs.upload_url }}
|
||||
# asset_path: /workdir/casa/upload/linux-amd64-casaos.tar.gz
|
||||
#
|
||||
# - name: Upload linux-arm64-casaos.tar.gz
|
||||
# id: upload_assets_arm64
|
||||
# uses: shogo82148/actions-upload-release-asset@v1
|
||||
# with:
|
||||
# upload_url: ${{ steps.get_release.outputs.upload_url }}
|
||||
# asset_path: /workdir/casa/upload/linux-arm64-casaos.tar.gz
|
||||
|
||||
5
.gitignore
vendored
@@ -20,6 +20,7 @@
|
||||
|
||||
# IntelliJ project files
|
||||
.idea
|
||||
.vscode
|
||||
*.iml
|
||||
out
|
||||
gen
|
||||
@@ -28,3 +29,7 @@ gen
|
||||
/out/
|
||||
/db/
|
||||
/docs/
|
||||
/conf/conf.ini
|
||||
__debug_bin
|
||||
main
|
||||
CasaOS
|
||||
|
||||
2
UI
@@ -4,7 +4,6 @@ RuntimeRootPath = runtime/
|
||||
LogSavePath = /casaOS/logs/server/
|
||||
LogSaveName = log
|
||||
LogFileExt = log
|
||||
; 必须的格式
|
||||
DateStrFormat = 20060102
|
||||
DateTimeFormat = 2006-01-02 15:04:05
|
||||
TimeFormat = 15:04:05
|
||||
@@ -20,27 +19,24 @@ ServerApi = https://api.casaos.zimaboard.com
|
||||
[user]
|
||||
UserName = admin
|
||||
PWD = zimaboard
|
||||
Email = aaa@222.ddd
|
||||
Description = ddddddd
|
||||
Email = user@gmail.com
|
||||
Description = description
|
||||
Initialized = false
|
||||
Token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImVyZXJlIiwicGFzc3dvcmQiOiJhZHNmZGYiLCJleHAiOjE2MjQwMDU0ODEsImlzcyI6Imdpbi1ibG9nIn0.JNsCccZuFCwlSMLJg62iOIB2xymk_k7xGa11xhZ07bc
|
||||
|
||||
[zerotier]
|
||||
UserName = ddddd
|
||||
PWD =
|
||||
UserName = user
|
||||
PWD = pwd
|
||||
Token = yBKYyavr2RdFAIVN7iTpzlsB1o6CqTgm
|
||||
|
||||
[redis]
|
||||
Host = 192.168.2.167:6379
|
||||
Host = 127.0.0.1:6379
|
||||
Password =
|
||||
MaxIdle = 30
|
||||
MaxActive = 30
|
||||
IdleTimeout = 200
|
||||
|
||||
[system]
|
||||
AutoUpdate = true
|
||||
SearchSwitch = true
|
||||
WidgetsSwitch = false
|
||||
ShortcutsSwitch = true
|
||||
SearchEngine = baidu
|
||||
Background = http://google.com
|
||||
BackgroundType = d
|
||||
ConfigStr =
|
||||
WidgetList =
|
||||
|
||||
2901
docs/docs.go
2839
docs/swagger.json
1753
docs/swagger.yaml
20
go.mod
@@ -7,9 +7,8 @@ require (
|
||||
github.com/Microsoft/hcsshim v0.8.22 // indirect
|
||||
github.com/PuerkitoBio/goquery v1.7.0
|
||||
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
|
||||
github.com/bits-and-blooms/bitset v1.2.1 // indirect
|
||||
github.com/containerd/containerd v1.5.5
|
||||
github.com/containerd/containerd v1.5.7
|
||||
github.com/containerd/continuity v0.2.0 // indirect
|
||||
github.com/docker/docker v20.10.7+incompatible
|
||||
github.com/docker/go-connections v0.4.0
|
||||
@@ -18,9 +17,7 @@ require (
|
||||
github.com/gin-gonic/gin v1.7.2
|
||||
github.com/go-ini/ini v1.62.0
|
||||
github.com/go-ole/go-ole v1.2.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.6 // indirect
|
||||
github.com/go-openapi/spec v0.20.3 // indirect
|
||||
github.com/go-openapi/swag v0.19.15 // indirect
|
||||
github.com/go-openapi/spec v0.20.4 // indirect
|
||||
github.com/go-playground/validator/v10 v10.6.1 // indirect
|
||||
github.com/gogo/googleapis v1.4.1 // indirect
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||
@@ -35,11 +32,11 @@ require (
|
||||
github.com/klauspost/compress v1.13.6 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/opencontainers/runc v1.0.2 // indirect
|
||||
github.com/opencontainers/selinux v1.8.5 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prestonTao/upnp v0.0.0-20150206124352-f4370df5e109
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
@@ -50,7 +47,7 @@ require (
|
||||
github.com/smartystreets/assertions v1.2.0 // indirect
|
||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
||||
github.com/swaggo/gin-swagger v1.3.0
|
||||
github.com/swaggo/swag v1.7.0
|
||||
github.com/swaggo/swag v1.7.3
|
||||
github.com/tidwall/gjson v1.8.0
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.6 // indirect
|
||||
@@ -58,13 +55,12 @@ require (
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
|
||||
golang.org/x/mod v0.5.0 // indirect
|
||||
golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167 // indirect
|
||||
golang.org/x/net v0.0.0-20211020060615-d418f374d309 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
|
||||
golang.org/x/sys v0.0.0-20210927052749-1cf2251ac284 // indirect
|
||||
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 // indirect
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
|
||||
golang.org/x/tools v0.1.5 // indirect
|
||||
golang.org/x/tools v0.1.7 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 // indirect
|
||||
google.golang.org/grpc v1.41.0 // indirect
|
||||
|
||||
46
go.sum
@@ -68,7 +68,7 @@ github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg3
|
||||
github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2ow3VK6a9Lg=
|
||||
github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00=
|
||||
github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600=
|
||||
github.com/Microsoft/hcsshim v0.8.18/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
|
||||
github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
|
||||
github.com/Microsoft/hcsshim v0.8.22 h1:CulZ3GW8sNJExknToo+RWD+U+6ZM5kkNfuxywSDPd08=
|
||||
github.com/Microsoft/hcsshim v0.8.22/go.mod h1:91uVCVzvX2QD16sMCenoxxXo6L1wJnLMX2PSufFMtF0=
|
||||
github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU=
|
||||
@@ -168,8 +168,8 @@ github.com/containerd/containerd v1.5.0-beta.3/go.mod h1:/wr9AVtEM7x9c+n0+stptlo
|
||||
github.com/containerd/containerd v1.5.0-beta.4/go.mod h1:GmdgZd2zA2GYIBZ0w09ZvgqEq8EfBp/m3lcVZIvPHhI=
|
||||
github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoTJseu1FGOKuoA4nNb2s=
|
||||
github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g=
|
||||
github.com/containerd/containerd v1.5.5 h1:q1gxsZsGZ8ddVe98yO6pR21b5xQSMiR61lD0W96pgQo=
|
||||
github.com/containerd/containerd v1.5.5/go.mod h1:oSTh0QpT1w6jYcGmbiSbxv9OSQYaa88mPyWIuU79zyo=
|
||||
github.com/containerd/containerd v1.5.7 h1:rQyoYtj4KddB3bxG6SAqd4+08gePNyJjRqvOIfV3rkM=
|
||||
github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c=
|
||||
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
@@ -335,19 +335,17 @@ github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3Hfo
|
||||
github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
||||
github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
|
||||
github.com/go-openapi/jsonreference v0.19.4/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg=
|
||||
github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg=
|
||||
github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs=
|
||||
github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns=
|
||||
github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
|
||||
github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
|
||||
github.com/go-openapi/spec v0.19.14/go.mod h1:gwrgJS15eCUgjLpMjBJmbZezCsw88LmgeEip0M63doA=
|
||||
github.com/go-openapi/spec v0.20.3 h1:uH9RQ6vdyPSs2pSy9fL8QPspDF2AMIMPtmK5coSSjtQ=
|
||||
github.com/go-openapi/spec v0.20.3/go.mod h1:gG4F8wdEDN+YPBMVnzE85Rbhf+Th2DTvA9nFPQ5AYEg=
|
||||
github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M=
|
||||
github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
|
||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.11/go.mod h1:Uc0gKkdR+ojzsEpjh39QChyu92vPgIr72POcgHMAgSY=
|
||||
github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM=
|
||||
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
@@ -367,6 +365,7 @@ github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblf
|
||||
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU=
|
||||
github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
|
||||
github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0=
|
||||
@@ -484,6 +483,7 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
|
||||
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/imdario/mergo v0.3.10/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
|
||||
github.com/jinzhu/copier v0.3.2 h1:QdBOCbaouLDYaIPFfi1bKv5F5tPpeTwXe4sD0jqtz5w=
|
||||
@@ -547,8 +547,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
|
||||
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
|
||||
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
|
||||
@@ -613,7 +613,6 @@ github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59P
|
||||
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||
github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0=
|
||||
github.com/opencontainers/runc v1.0.1/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
|
||||
github.com/opencontainers/runc v1.0.2 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg=
|
||||
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
|
||||
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||
@@ -629,6 +628,8 @@ github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3
|
||||
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
|
||||
github.com/opencontainers/selinux v1.8.5 h1:OkT6bMHOQ1JQQO4ihjQ49sj0+wciDcjziSVTRn8VeTA=
|
||||
github.com/opencontainers/selinux v1.8.5/go.mod h1:HTvjPFoGMbpQsG886e3lQwnsRWtE4TC1OF3OUvG9FAo=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
|
||||
@@ -685,6 +686,7 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh
|
||||
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
|
||||
github.com/shirou/gopsutil/v3 v3.21.5 h1:YUBf0w/KPLk7w1803AYBnH7BmA+1Z/Q5MEZxpREUaB4=
|
||||
github.com/shirou/gopsutil/v3 v3.21.5/go.mod h1:ghfMypLDrFSWN2c9cDYFLHyynQ+QUht0cv/18ZqVczw=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
@@ -733,8 +735,8 @@ github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuI
|
||||
github.com/swaggo/gin-swagger v1.3.0 h1:eOmp7r57oUgZPw2dJOjcGNMse9cvXcI4tTqBcnZtPsI=
|
||||
github.com/swaggo/gin-swagger v1.3.0/go.mod h1:oy1BRA6WvgtCp848lhxce7BnWH4C8Bxa0m5SkWx+cS0=
|
||||
github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y=
|
||||
github.com/swaggo/swag v1.7.0 h1:5bCA/MTLQoIqDXXyHfOpMeDvL9j68OY/udlK4pQoo4E=
|
||||
github.com/swaggo/swag v1.7.0/go.mod h1:BdPIL73gvS9NBsdi7M1JOxLvlbfvNRaBP8m6WT6Aajo=
|
||||
github.com/swaggo/swag v1.7.3 h1:ucB7irEdRrhjmW+Z1Ss4GjO68oPKQFjSgOR8BCAvcbU=
|
||||
github.com/swaggo/swag v1.7.3/go.mod h1:zD8h6h4SPv7t3l+4BKdRquqW1ASWjKZgT6Qv9z3kNqI=
|
||||
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||
@@ -787,7 +789,7 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs=
|
||||
github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA=
|
||||
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg=
|
||||
@@ -903,8 +905,9 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
|
||||
golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167 h1:eDd+TJqbgfXruGQ5sJRU7tEtp/58OAx4+Ayjxg4SM+4=
|
||||
golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211020060615-d418f374d309 h1:A0lJIi+hcTR6aajJH4YqKWwohY4aW9RO7oRMcdv+HKI=
|
||||
golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -991,6 +994,7 @@ golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201202213521-69691e467435/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -1002,8 +1006,10 @@ golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927052749-1cf2251ac284 h1:lBPNCmq8u4zFP3huKCmUQ2Fx8kcY4X+O12UgGnyKsrg=
|
||||
golang.org/x/sys v0.0.0-20210927052749-1cf2251ac284/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 h1:LOlKVhfDyahgmqa97awczplwkjzNaELFg3zRIJ13RYo=
|
||||
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
@@ -1072,10 +1078,10 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20201120155355-20be4ac4bd6e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ=
|
||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
28
main.go
@@ -3,47 +3,59 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/cache"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/sqlite"
|
||||
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||
"github.com/IceWhaleTech/CasaOS/route"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/robfig/cron"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
var sqliteDB *gorm.DB
|
||||
|
||||
var swagHandler gin.HandlerFunc
|
||||
var configFlag = flag.String("c", "", "config address")
|
||||
|
||||
var showUserInfo = flag.Bool("show-user-info", false, "show user info")
|
||||
|
||||
func init() {
|
||||
flag.Parse()
|
||||
config.InitSetup(*configFlag)
|
||||
config.UpdateSetup()
|
||||
loger2.LogSetup()
|
||||
sqliteDB = sqlite.GetDb(config.AppInfo.ProjectPath)
|
||||
//gredis.GetRedisConn(config.RedisInfo),
|
||||
service.MyService = service.NewService(sqliteDB, loger2.NewOLoger())
|
||||
service.Cache = cache.Init()
|
||||
route.InitFunction()
|
||||
}
|
||||
|
||||
// @title Oasis API
|
||||
// @title casaOS API
|
||||
// @version 1.0.0
|
||||
// @contact.name lauren.pan
|
||||
// @contact.url https://www.zimaboard.com
|
||||
// @contact.email lauren.pan@icewhale.org
|
||||
// @description Oasis v1版本api
|
||||
// @host 192.168.2.114:8089
|
||||
// @description casaOS v1版本api
|
||||
// @host 192.168.2.217:8089
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name Authorization
|
||||
// @BasePath /v1
|
||||
func main() {
|
||||
if *showUserInfo {
|
||||
fmt.Println("CasaOS User Info")
|
||||
fmt.Println("UserName:" + config.UserInfo.UserName)
|
||||
fmt.Println("Password:" + config.UserInfo.PWD)
|
||||
return
|
||||
}
|
||||
//model.Setup()
|
||||
//gredis.Setup()
|
||||
r := route.InitRouter(swagHandler)
|
||||
r := route.InitRouter()
|
||||
//service.SyncTask(sqliteDB)
|
||||
cron2 := cron.New() //创建一个cron实例
|
||||
//执行定时任务(每5秒执行一次)
|
||||
|
||||
55
model/app.go
@@ -7,32 +7,35 @@ import (
|
||||
)
|
||||
|
||||
type ServerAppList struct {
|
||||
Id uint `gorm:"column:id;primary_key" json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Tagline string `json:"tagline"`
|
||||
Tags Strings `gorm:"type:json" json:"tags"`
|
||||
Icon string `json:"icon"`
|
||||
ScreenshotLink Strings `gorm:"type:json" json:"screenshot_link"`
|
||||
Category string `json:"category"`
|
||||
TcpPort uint `json:"tcp_port"`
|
||||
PortMap uint `json:"port_map"`
|
||||
ImageVersion string `json:"image_version"`
|
||||
Tip string `json:"tip"`
|
||||
Configures configures `gorm:"type:json" json:"configures"`
|
||||
NetworkModel string `json:"network_mode"`
|
||||
Image string `json:"image"`
|
||||
Index string `json:"index"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
State string `json:"state"`
|
||||
Author string `json:"author"`
|
||||
MinMemory int `json:"min_memory"`
|
||||
MinDisk int `json:"min_disk"`
|
||||
MaxMemory uint64 `json:"max_memory"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
Healthy string `json:"healthy"`
|
||||
Plugins Strings `json:"plugins"`
|
||||
Id uint `gorm:"column:id;primary_key" json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Tagline string `json:"tagline"`
|
||||
Tags Strings `gorm:"type:json" json:"tags"`
|
||||
Icon string `json:"icon"`
|
||||
ScreenshotLink Strings `gorm:"type:json" json:"screenshot_link"`
|
||||
Category string `json:"category"`
|
||||
PortMap string `json:"port_map"`
|
||||
ImageVersion string `json:"image_version"`
|
||||
Tip string `json:"tip"`
|
||||
Envs EnvArray `json:"envs"`
|
||||
Ports PortArray `json:"ports"`
|
||||
Volumes PathArray `json:"volumes"`
|
||||
Devices PathArray `json:"devices"`
|
||||
NetworkModel string `json:"network_model"`
|
||||
Image string `json:"image"`
|
||||
Index string `json:"index"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
State string `json:"state"`
|
||||
Author string `json:"author"`
|
||||
MinMemory int `json:"min_memory"`
|
||||
MinDisk int `json:"min_disk"`
|
||||
MaxMemory uint64 `json:"max_memory"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
Healthy string `json:"healthy"`
|
||||
Plugins Strings `json:"plugins"`
|
||||
Origin string `json:"origin"`
|
||||
}
|
||||
|
||||
type Ports struct {
|
||||
|
||||
@@ -17,20 +17,22 @@ type UdpPorts struct {
|
||||
/*******************使用gorm支持json************************************/
|
||||
|
||||
type PortMap struct {
|
||||
ContainerPort string `json:"container,omitempty"`
|
||||
CommendPort string `json:"host,omitempty"`
|
||||
ContainerPort string `json:"container"`
|
||||
CommendPort string `json:"host"`
|
||||
Protocol string `json:"protocol"`
|
||||
Desc string `json:"desc"`
|
||||
Type int `json:"type"`
|
||||
}
|
||||
|
||||
type PortArrey []PortMap
|
||||
type PortArray []PortMap
|
||||
|
||||
// Value 实现方法
|
||||
func (p PortArrey) Value() (driver.Value, error) {
|
||||
func (p PortArray) Value() (driver.Value, error) {
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
// Scan 实现方法
|
||||
func (p *PortArrey) Scan(input interface{}) error {
|
||||
func (p *PortArray) Scan(input interface{}) error {
|
||||
return json.Unmarshal(input.([]byte), p)
|
||||
}
|
||||
|
||||
@@ -41,20 +43,22 @@ func (p *PortArrey) Scan(input interface{}) error {
|
||||
type Env struct {
|
||||
Name string `json:"container"`
|
||||
Value string `json:"host"`
|
||||
Desc string `json:"desc"`
|
||||
Type int `json:"type"`
|
||||
}
|
||||
|
||||
type JSON json.RawMessage
|
||||
|
||||
type EnvArrey []Env
|
||||
type EnvArray []Env
|
||||
|
||||
// Value 实现方法
|
||||
func (p EnvArrey) Value() (driver.Value, error) {
|
||||
func (p EnvArray) Value() (driver.Value, error) {
|
||||
return json.Marshal(p)
|
||||
//return .MarshalJSON()
|
||||
}
|
||||
|
||||
// Scan 实现方法
|
||||
func (p *EnvArrey) Scan(input interface{}) error {
|
||||
func (p *EnvArray) Scan(input interface{}) error {
|
||||
return json.Unmarshal(input.([]byte), p)
|
||||
}
|
||||
|
||||
@@ -65,17 +69,19 @@ func (p *EnvArrey) Scan(input interface{}) error {
|
||||
type PathMap struct {
|
||||
ContainerPath string `json:"container"`
|
||||
Path string `json:"host"`
|
||||
Type int `json:"type"`
|
||||
Desc string `json:"desc"`
|
||||
}
|
||||
|
||||
type PathArrey []PathMap
|
||||
type PathArray []PathMap
|
||||
|
||||
// Value 实现方法
|
||||
func (p PathArrey) Value() (driver.Value, error) {
|
||||
func (p PathArray) Value() (driver.Value, error) {
|
||||
return json.Marshal(p)
|
||||
}
|
||||
|
||||
// Scan 实现方法
|
||||
func (p *PathArrey) Scan(input interface{}) error {
|
||||
func (p *PathArray) Scan(input interface{}) error {
|
||||
return json.Unmarshal(input.([]byte), p)
|
||||
}
|
||||
|
||||
@@ -103,10 +109,10 @@ type CustomizationPostData struct {
|
||||
Index string `json:"index"`
|
||||
Icon string `json:"icon"`
|
||||
Image string `json:"image"`
|
||||
Envs EnvArrey `json:"envs"`
|
||||
Ports PortArrey `json:"ports"`
|
||||
Volumes PathArrey `json:"volumes"`
|
||||
Devices PathArrey `json:"devices"`
|
||||
Envs EnvArray `json:"envs"`
|
||||
Ports PortArray `json:"ports"`
|
||||
Volumes PathArray `json:"volumes"`
|
||||
Devices PathArray `json:"devices"`
|
||||
//Port string `json:"port,omitempty"`
|
||||
PortMap string `json:"port_map"`
|
||||
CpuShares int64 `json:"cpu_shares"`
|
||||
|
||||
7
model/search.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type SearchFileInfo struct {
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
Type int `json:"type"`
|
||||
}
|
||||
@@ -15,6 +15,7 @@ type UserModel struct {
|
||||
Head string
|
||||
Email string
|
||||
Description string
|
||||
Initialized bool
|
||||
}
|
||||
|
||||
//服务配置
|
||||
@@ -60,11 +61,9 @@ type RedisModel struct {
|
||||
}
|
||||
|
||||
type SystemConfig struct {
|
||||
SearchSwitch bool `json:"search_switch"` //搜索开关
|
||||
SearchEngine string `json:"search_engine"` //搜索引擎
|
||||
ShortcutsSwitch bool `json:"shortcuts_switch"`
|
||||
WidgetsSwitch bool `json:"widgets_switch"`
|
||||
BackgroundType string `json:"background_type"`
|
||||
Background string `json:"background"`
|
||||
AutoUpdate bool `json:"auto_update"`
|
||||
ConfigStr string `json:"config_str"`
|
||||
WidgetList string `json:"widget_list"`
|
||||
ConfigPath string `json:"config_path"`
|
||||
SyncPort string `json:"sync_port"`
|
||||
SyncKey string `json:"sync_key"`
|
||||
}
|
||||
|
||||
8
model/system_app/sync.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package system_app
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
type SyncConfig struct {
|
||||
XMLName xml.Name `xml:"configuration"`
|
||||
Key string `xml:"gui>apikey"`
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package model
|
||||
|
||||
type Path struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
IsDir bool `json:"is_dir"`
|
||||
}
|
||||
|
||||
11
pkg/cache/cache.go
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/patrickmn/go-cache"
|
||||
)
|
||||
|
||||
func Init() *cache.Cache {
|
||||
return cache.New(5*time.Minute, 60*time.Second)
|
||||
}
|
||||
@@ -2,14 +2,15 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/go-ini/ini"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/go-ini/ini"
|
||||
)
|
||||
|
||||
//系统配置
|
||||
@@ -55,6 +56,7 @@ func InitSetup(config string) {
|
||||
mapTo("redis", RedisInfo)
|
||||
mapTo("server", ServerInfo)
|
||||
mapTo("system", SystemConfigInfo)
|
||||
SystemConfigInfo.ConfigPath = configDir
|
||||
// AppInfo.ProjectPath = getCurrentDirectory() //os.Getwd()
|
||||
|
||||
}
|
||||
|
||||
15
pkg/config/update.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package config
|
||||
|
||||
import "github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
|
||||
//检查目录是否存在
|
||||
func mkdirDATAAll() {
|
||||
dirArray := [7]string{"/DATA/AppData", "/DATA/Documents", "/DATA/Downloads", "/DATA/Gallery", "/DATA/Media/Movies", "/DATA/Media/TV Shows", "/DATA/Media/Music"}
|
||||
for _, v := range dirArray {
|
||||
file.IsNotExistMkDir(v)
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateSetup() {
|
||||
mkdirDATAAll()
|
||||
}
|
||||
@@ -4,30 +4,35 @@ import (
|
||||
"bytes"
|
||||
json2 "encoding/json"
|
||||
"fmt"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"io"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
func NewSshClient() (*ssh.Client, error) {
|
||||
func NewSshClient(user, password string) (*ssh.Client, error) {
|
||||
|
||||
// connet to ssh
|
||||
// addr = fmt.Sprintf("%s:%d", host, port)
|
||||
|
||||
config := &ssh.ClientConfig{
|
||||
Timeout: time.Second * 5,
|
||||
User: "root",
|
||||
User: user,
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
//HostKeyCallback: ,
|
||||
//HostKeyCallback: hostKeyCallBackFunc(h.Host),
|
||||
}
|
||||
//if h.Type == "password" {
|
||||
config.Auth = []ssh.AuthMethod{ssh.Password("123456")}
|
||||
config.Auth = []ssh.AuthMethod{ssh.Password(password)}
|
||||
//} else {
|
||||
// config.Auth = []ssh.AuthMethod{publicKeyAuthFunc(h.Key)}
|
||||
//}
|
||||
addr := fmt.Sprintf("%s:%d", "192.168.2.142", 22)
|
||||
addr := fmt.Sprintf("%s:%d", "127.0.0.1", 22)
|
||||
c, err := ssh.Dial("tcp", addr, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -98,6 +103,98 @@ const (
|
||||
wsMsgResize = "resize"
|
||||
)
|
||||
|
||||
//ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin
|
||||
func ReceiveWsMsgUser(wsConn *websocket.Conn, logBuff *bytes.Buffer) string {
|
||||
//tells other go routine quit
|
||||
username := ""
|
||||
for {
|
||||
|
||||
//read websocket msg
|
||||
_, wsData, err := wsConn.ReadMessage()
|
||||
if err != nil {
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
msgObj := wsMsg{}
|
||||
if err := json2.Unmarshal(wsData, &msgObj); err != nil {
|
||||
msgObj.Type = "cmd"
|
||||
msgObj.Cmd = string(wsData)
|
||||
}
|
||||
//if err := json.Unmarshal(wsData, &msgObj); err != nil {
|
||||
// logrus.WithError(err).WithField("wsData", string(wsData)).Error("unmarshal websocket message failed")
|
||||
//}
|
||||
switch msgObj.Type {
|
||||
case wsMsgCmd:
|
||||
//handle xterm.js stdin
|
||||
//decodeBytes, err := base64.StdEncoding.DecodeString(msgObj.Cmd)
|
||||
decodeBytes := []byte(msgObj.Cmd)
|
||||
if msgObj.Cmd == "\u007f" {
|
||||
if len(username) == 0 {
|
||||
continue
|
||||
}
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte("\b\x1b[K"))
|
||||
username = username[:len(username)-1]
|
||||
continue
|
||||
}
|
||||
if msgObj.Cmd == "\r" {
|
||||
return username
|
||||
}
|
||||
username += msgObj.Cmd
|
||||
|
||||
if err := wsConn.WriteMessage(websocket.TextMessage, decodeBytes); err != nil {
|
||||
logrus.WithError(err).Error("ws cmd bytes write to ssh.stdin pipe failed")
|
||||
}
|
||||
//write input cmd to log buffer
|
||||
if _, err := logBuff.Write(decodeBytes); err != nil {
|
||||
logrus.WithError(err).Error("write received cmd into log buffer failed")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func ReceiveWsMsgPassword(wsConn *websocket.Conn, logBuff *bytes.Buffer) string {
|
||||
//tells other go routine quit
|
||||
password := ""
|
||||
for {
|
||||
|
||||
//read websocket msg
|
||||
_, wsData, err := wsConn.ReadMessage()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("reading webSocket message failed")
|
||||
return ""
|
||||
}
|
||||
|
||||
msgObj := wsMsg{}
|
||||
if err := json2.Unmarshal(wsData, &msgObj); err != nil {
|
||||
msgObj.Type = "cmd"
|
||||
msgObj.Cmd = string(wsData)
|
||||
}
|
||||
//if err := json.Unmarshal(wsData, &msgObj); err != nil {
|
||||
// logrus.WithError(err).WithField("wsData", string(wsData)).Error("unmarshal websocket message failed")
|
||||
//}
|
||||
switch msgObj.Type {
|
||||
case wsMsgCmd:
|
||||
//handle xterm.js stdin
|
||||
//decodeBytes, err := base64.StdEncoding.DecodeString(msgObj.Cmd)
|
||||
if msgObj.Cmd == "\r" {
|
||||
return password
|
||||
}
|
||||
|
||||
if msgObj.Cmd == "\u007f" {
|
||||
if len(password) == 0 {
|
||||
continue
|
||||
}
|
||||
password = password[:len(password)-1]
|
||||
continue
|
||||
}
|
||||
password += msgObj.Cmd
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin
|
||||
func (ssConn *SshConn) ReceiveWsMsg(wsConn *websocket.Conn, logBuff *bytes.Buffer, exitCh chan bool) {
|
||||
//tells other go routine quit
|
||||
@@ -187,6 +284,64 @@ func flushComboOutput(w *wsBufferWriter, wsConn *websocket.Conn) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin
|
||||
func (ssConn *SshConn) Login(wsConn *websocket.Conn, logBuff *bytes.Buffer, exitCh chan bool) {
|
||||
//tells other go routine quit
|
||||
defer setQuit(exitCh)
|
||||
for {
|
||||
select {
|
||||
case <-exitCh:
|
||||
return
|
||||
default:
|
||||
//read websocket msg
|
||||
_, wsData, err := wsConn.ReadMessage()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("reading webSocket message failed")
|
||||
return
|
||||
}
|
||||
//unmashal bytes into struct
|
||||
//msgObj := wsMsg{
|
||||
// Type: "cmd",
|
||||
// Cmd: "",
|
||||
// Rows: 50,
|
||||
// Cols: 180,
|
||||
//}
|
||||
msgObj := wsMsg{}
|
||||
if err := json2.Unmarshal(wsData, &msgObj); err != nil {
|
||||
msgObj.Type = "cmd"
|
||||
msgObj.Cmd = string(wsData)
|
||||
}
|
||||
//if err := json.Unmarshal(wsData, &msgObj); err != nil {
|
||||
// logrus.WithError(err).WithField("wsData", string(wsData)).Error("unmarshal websocket message failed")
|
||||
//}
|
||||
switch msgObj.Type {
|
||||
|
||||
case wsMsgResize:
|
||||
//handle xterm.js size change
|
||||
if msgObj.Cols > 0 && msgObj.Rows > 0 {
|
||||
if err := ssConn.Session.WindowChange(msgObj.Rows, msgObj.Cols); err != nil {
|
||||
logrus.WithError(err).Error("ssh pty change windows size failed")
|
||||
}
|
||||
}
|
||||
case wsMsgCmd:
|
||||
//handle xterm.js stdin
|
||||
//decodeBytes, err := base64.StdEncoding.DecodeString(msgObj.Cmd)
|
||||
decodeBytes := []byte(msgObj.Cmd)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("websock cmd string base64 decoding failed")
|
||||
}
|
||||
if _, err := ssConn.StdinPipe.Write(decodeBytes); err != nil {
|
||||
logrus.WithError(err).Error("ws cmd bytes write to ssh.stdin pipe failed")
|
||||
}
|
||||
//write input cmd to log buffer
|
||||
if _, err := logBuff.Write(decodeBytes); err != nil {
|
||||
logrus.WithError(err).Error("write received cmd into log buffer failed")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
func (ssConn *SshConn) SessionWait(quitChan chan bool) {
|
||||
if err := ssConn.Session.Wait(); err != nil {
|
||||
logrus.WithError(err).Error("ssh session wait failed")
|
||||
@@ -241,7 +396,7 @@ func WsReaderCopy(reader *websocket.Conn, writer io.Writer) {
|
||||
if err = json2.Unmarshal(p, &msgObj); err != nil {
|
||||
writer.Write(p)
|
||||
} else if msgObj.Type == wsMsgResize {
|
||||
writer.Write([]byte("stty rows " + strconv.Itoa(msgObj.Rows) + " && stty cols " + strconv.Itoa(msgObj.Cols) + " \r" ))
|
||||
writer.Write([]byte("stty rows " + strconv.Itoa(msgObj.Rows) + " && stty cols " + strconv.Itoa(msgObj.Cols) + " \r"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,29 @@
|
||||
package docker
|
||||
|
||||
import "strings"
|
||||
|
||||
func GetDir(id, envName string) string {
|
||||
var path string
|
||||
switch envName {
|
||||
case "/config":
|
||||
path = "/oasis/app_data/" + id + "/"
|
||||
|
||||
if len(id) == 0 {
|
||||
id = "$AppID"
|
||||
}
|
||||
|
||||
switch {
|
||||
case strings.Contains(strings.ToLower(envName), "config") || strings.Contains(strings.ToLower(envName), "photoprism/storage") || strings.Contains(strings.ToLower(envName), "config"):
|
||||
path = "/DATA/AppData/" + id + "/"
|
||||
case strings.Contains(strings.ToLower(envName), "movie"):
|
||||
path = "/DATA/Media/Movies/"
|
||||
case strings.Contains(strings.ToLower(envName), "music"):
|
||||
path = "/DATA/Media/Music/"
|
||||
case strings.Contains(strings.ToLower(envName), "photoprism/originals"):
|
||||
path = "/DATA/Gallery"
|
||||
case strings.Contains(strings.ToLower(envName), "download"):
|
||||
path = "/DATA/Downloads/"
|
||||
case strings.Contains(strings.ToLower(envName), "photo") || strings.Contains(strings.ToLower(envName), "pictures"):
|
||||
path = "/DATA/Downloads/"
|
||||
case strings.ToLower(envName) == "/srv":
|
||||
path = "/DATA/"
|
||||
default:
|
||||
//path = "/media"
|
||||
}
|
||||
|
||||
10
pkg/docker/volumes_test.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetDir(t *testing.T) {
|
||||
fmt.Println(GetDir("", "config"))
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package github
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetRepos(t *testing.T) {
|
||||
GetRepos()
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
package gredis
|
||||
|
||||
import (
|
||||
"github.com/gomodule/redigo/redis"
|
||||
"oasis/model"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/gomodule/redigo/redis"
|
||||
)
|
||||
|
||||
func GetRedisConn(m *model.RedisModel) *redis.Pool {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package upnp
|
||||
|
||||
import (
|
||||
ip_helper2 "oasis/pkg/utils/ip_helper"
|
||||
"testing"
|
||||
|
||||
ip_helper2 "github.com/IceWhaleTech/CasaOS/pkg/utils/ip_helper"
|
||||
)
|
||||
|
||||
func TestGetCtrlUrl(t *testing.T) {
|
||||
|
||||
19
pkg/utils/env_helper/env.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package env_helper
|
||||
|
||||
import "strings"
|
||||
|
||||
func ReplaceDefaultENV(key string) string {
|
||||
temp := ""
|
||||
switch key {
|
||||
case "$DefaultPassword":
|
||||
temp = "casaos"
|
||||
case "$DefaultUserName":
|
||||
temp = "admin"
|
||||
}
|
||||
return temp
|
||||
}
|
||||
|
||||
//replace env default setting
|
||||
func ReplaceStringDefaultENV(str string) string {
|
||||
return strings.ReplaceAll(strings.ReplaceAll(str, "$DefaultPassword", ReplaceDefaultENV("$DefaultPassword")), "$DefaultUserName", ReplaceDefaultENV("$DefaultUserName"))
|
||||
}
|
||||
@@ -50,6 +50,7 @@ func MkDir(src string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
os.Chmod(src, 0777)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -100,10 +101,9 @@ func MustOpen(fileName, filePath string) (*os.File, error) {
|
||||
return f, nil
|
||||
}
|
||||
|
||||
|
||||
// 判断所给路径文件/文件夹是否存在
|
||||
func Exists(path string) bool {
|
||||
_, err := os.Stat(path) //os.Stat获取文件信息
|
||||
_, err := os.Stat(path) //os.Stat获取文件信息
|
||||
if err != nil {
|
||||
if os.IsExist(err) {
|
||||
return true
|
||||
@@ -126,3 +126,36 @@ func IsDir(path string) bool {
|
||||
func IsFile(path string) bool {
|
||||
return !IsDir(path)
|
||||
}
|
||||
|
||||
func CreateFile(path string) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsNotExistMkDir create a directory if it does not exist
|
||||
func IsNotExistCreateFile(src string) error {
|
||||
if notExist := CheckNotExist(src); notExist == true {
|
||||
if err := CreateFile(src); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReadFullFile(path string) []byte {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return []byte("")
|
||||
}
|
||||
defer file.Close()
|
||||
content, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return []byte("")
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
176
pkg/utils/file/reader.go
Normal file
@@ -0,0 +1,176 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
buffSize = 1 << 20
|
||||
)
|
||||
|
||||
// ReadLineFromEnd --
|
||||
type ReadLineFromEnd struct {
|
||||
f *os.File
|
||||
|
||||
fileSize int
|
||||
bwr *bytes.Buffer
|
||||
lineBuff []byte
|
||||
swapBuff []byte
|
||||
|
||||
isFirst bool
|
||||
}
|
||||
|
||||
// NewReadLineFromEnd --
|
||||
func NewReadLineFromEnd(name string) (rd *ReadLineFromEnd, err error) {
|
||||
f, err := os.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
info, err := f.Stat()
|
||||
if info.IsDir() {
|
||||
return nil, fmt.Errorf("not file")
|
||||
}
|
||||
fileSize := int(info.Size())
|
||||
rd = &ReadLineFromEnd{
|
||||
f: f,
|
||||
fileSize: fileSize,
|
||||
bwr: bytes.NewBuffer([]byte{}),
|
||||
lineBuff: make([]byte, 0),
|
||||
swapBuff: make([]byte, buffSize),
|
||||
isFirst: true,
|
||||
}
|
||||
return rd, nil
|
||||
}
|
||||
|
||||
// ReadLine 结尾包含'\n'
|
||||
func (c *ReadLineFromEnd) ReadLine() (line []byte, err error) {
|
||||
var ok bool
|
||||
for {
|
||||
ok, err = c.buff()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
line, err = c.bwr.ReadBytes('\n')
|
||||
if err == io.EOF && c.fileSize > 0 {
|
||||
err = nil
|
||||
}
|
||||
return line, err
|
||||
}
|
||||
|
||||
// Close --
|
||||
func (c *ReadLineFromEnd) Close() (err error) {
|
||||
return c.f.Close()
|
||||
}
|
||||
|
||||
func (c *ReadLineFromEnd) buff() (ok bool, err error) {
|
||||
if c.fileSize == 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
if c.bwr.Len() >= buffSize {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
offset := 0
|
||||
if c.fileSize > buffSize {
|
||||
offset = c.fileSize - buffSize
|
||||
}
|
||||
_, err = c.f.Seek(int64(offset), 0)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
n, err := c.f.Read(c.swapBuff)
|
||||
if err != nil && err != io.EOF {
|
||||
return false, err
|
||||
}
|
||||
if c.fileSize < n {
|
||||
n = c.fileSize
|
||||
}
|
||||
if n == 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
for {
|
||||
m := bytes.LastIndex(c.swapBuff[:n], []byte{'\n'})
|
||||
if m == -1 {
|
||||
break
|
||||
}
|
||||
if m < n-1 {
|
||||
err = c.writeLine(c.swapBuff[m+1 : n])
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
ok = true
|
||||
} else if m == n-1 && !c.isFirst {
|
||||
err = c.writeLine(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
ok = true
|
||||
}
|
||||
n = m
|
||||
if n == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if n > 0 {
|
||||
reverseBytes(c.swapBuff[:n])
|
||||
c.lineBuff = append(c.lineBuff, c.swapBuff[:n]...)
|
||||
}
|
||||
if offset == 0 {
|
||||
err = c.writeLine(nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
ok = true
|
||||
}
|
||||
c.fileSize = offset
|
||||
if c.isFirst {
|
||||
c.isFirst = false
|
||||
}
|
||||
return ok, nil
|
||||
}
|
||||
|
||||
func (c *ReadLineFromEnd) writeLine(b []byte) (err error) {
|
||||
if len(b) > 0 {
|
||||
_, err = c.bwr.Write(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(c.lineBuff) > 0 {
|
||||
reverseBytes(c.lineBuff)
|
||||
_, err = c.bwr.Write(c.lineBuff)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.lineBuff = c.lineBuff[:0]
|
||||
}
|
||||
_, err = c.bwr.Write([]byte{'\n'})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func reverseBytes(b []byte) {
|
||||
n := len(b)
|
||||
if n <= 1 {
|
||||
return
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
k := n - 1
|
||||
if k != i {
|
||||
b[i], b[k] = b[k], b[i]
|
||||
}
|
||||
n--
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,13 @@ package httper
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/tidwall/gjson"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
//发送GET请求
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package jwt
|
||||
|
||||
import (
|
||||
jwt "github.com/golang-jwt/jwt"
|
||||
"time"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt"
|
||||
)
|
||||
|
||||
type Claims struct {
|
||||
@@ -15,8 +16,7 @@ var jwtSecret []byte
|
||||
|
||||
//创建token
|
||||
func GenerateToken(username, password string) (string, error) {
|
||||
nowTime := time.Now()
|
||||
expireTime := nowTime.Add(3 * time.Hour)
|
||||
expireTime := time.Now().AddDate(999, 0, 0)
|
||||
clims := Claims{
|
||||
username,
|
||||
password,
|
||||
|
||||
@@ -2,11 +2,12 @@ package jwt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func JWT(swagHandler gin.HandlerFunc) gin.HandlerFunc {
|
||||
|
||||
@@ -2,13 +2,13 @@ package loger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
file2 "github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
file2 "github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
)
|
||||
|
||||
//定义一个int的别名
|
||||
@@ -20,6 +20,7 @@ type OLog interface {
|
||||
Warn(v ...interface{})
|
||||
Error(v ...interface{})
|
||||
Fatal(v ...interface{})
|
||||
Path() string
|
||||
}
|
||||
|
||||
type oLog struct {
|
||||
@@ -47,9 +48,8 @@ const (
|
||||
func LogSetup() {
|
||||
var err error
|
||||
filePath := fmt.Sprintf("%s", config.AppInfo.LogSavePath)
|
||||
fileName := fmt.Sprintf("%s%s.%s",
|
||||
fileName := fmt.Sprintf("%s.%s",
|
||||
config.AppInfo.LogSaveName,
|
||||
time.Now().Format(config.AppInfo.DateStrFormat),
|
||||
config.AppInfo.LogFileExt,
|
||||
)
|
||||
F, err = file2.MustOpen(fileName, filePath)
|
||||
@@ -60,7 +60,14 @@ func LogSetup() {
|
||||
logger = log.New(F, DefaultPrefix, log.LstdFlags)
|
||||
|
||||
}
|
||||
|
||||
func (o *oLog) Path() string {
|
||||
filePath := fmt.Sprintf("%s", config.AppInfo.LogSavePath)
|
||||
fileName := fmt.Sprintf("%s.%s",
|
||||
config.AppInfo.LogSaveName,
|
||||
config.AppInfo.LogFileExt,
|
||||
)
|
||||
return filePath + fileName
|
||||
}
|
||||
func (o *oLog) Debug(v ...interface{}) {
|
||||
setPrefix(DEBUG)
|
||||
logger.Println(v)
|
||||
|
||||
@@ -7,10 +7,14 @@ const (
|
||||
ERROR_AUTH_TOKEN = 401
|
||||
|
||||
//user
|
||||
PWD_INVALID = 10001
|
||||
PWD_INVALID = 10001
|
||||
PWD_IS_EMPTY = 10002
|
||||
|
||||
PWD_INVALID_OLD = 10003
|
||||
//system
|
||||
DIR_ALREADY_EXISTS = 20001
|
||||
DIR_ALREADY_EXISTS = 20001
|
||||
FILE_ALREADY_EXISTS = 20002
|
||||
FILE_OR_DIR_EXISTS = 20003
|
||||
|
||||
//zerotier
|
||||
GET_TOKEN_ERROR = 30001
|
||||
@@ -35,11 +39,14 @@ var MsgFlags = map[int]string{
|
||||
ERROR_AUTH_TOKEN: "error auth token",
|
||||
|
||||
//user
|
||||
PWD_INVALID: "Password invalid",
|
||||
PWD_INVALID: "Password invalid",
|
||||
PWD_IS_EMPTY: "Password is empty",
|
||||
PWD_INVALID_OLD: "Old Password invalid",
|
||||
|
||||
//system
|
||||
DIR_ALREADY_EXISTS: "Directory already exists",
|
||||
|
||||
DIR_ALREADY_EXISTS: "Directory already exists",
|
||||
FILE_ALREADY_EXISTS: "File already exists",
|
||||
FILE_OR_DIR_EXISTS: "File or directory already exists",
|
||||
|
||||
//zerotier
|
||||
GET_TOKEN_ERROR: "Get token error,Please log in to zerotier's official website to confirm whether the account is available",
|
||||
|
||||
@@ -47,6 +47,7 @@ func IsPortAvailable(port int, t string) bool {
|
||||
uc, err := net.ListenUDP("udp", sadd)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return false
|
||||
} else {
|
||||
defer uc.Close()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package sort
|
||||
|
||||
import (
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"sort"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
)
|
||||
|
||||
// 数据集类型, 与上一篇排序文章(多字段单独排序)比较, less字段的数据类型不再是 func(p1, p2 *Change) bool
|
||||
|
||||
@@ -2,13 +2,14 @@ package version
|
||||
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/httper"
|
||||
"github.com/IceWhaleTech/CasaOS/types"
|
||||
"github.com/tidwall/gjson"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IsNeedUpdate() (bool, model.Version) {
|
||||
@@ -35,3 +36,23 @@ func IsNeedUpdate() (bool, model.Version) {
|
||||
}
|
||||
return false, version
|
||||
}
|
||||
|
||||
//a版本大于b版本
|
||||
func VersionCompared(a string, b string) bool {
|
||||
v1 := strings.Split(a, ".")
|
||||
v2 := strings.Split(b, ".")
|
||||
for len(v1) < len(v2) {
|
||||
v1 = append(v1, "0")
|
||||
}
|
||||
for len(v2) < len(v1) {
|
||||
v2 = append(v2, "0")
|
||||
}
|
||||
for i := 0; i < len(v1); i++ {
|
||||
a, _ := strconv.Atoi(v1[i])
|
||||
b, _ := strconv.Atoi(v2[i])
|
||||
if a > b {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//go:build doc
|
||||
// +build doc
|
||||
|
||||
package route
|
||||
@@ -5,9 +6,10 @@ package route
|
||||
import (
|
||||
_ "github.com/IceWhaleTech/CasaOS/docs"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"github.com/swaggo/gin-swagger/swaggerFiles"
|
||||
swaggerFiles "github.com/swaggo/gin-swagger/swaggerFiles"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// swagHandler = ginSwagger.WrapHandler(swaggerFiles.Handler)
|
||||
swagHandler = ginSwagger.WrapHandler(swaggerFiles.Handler)
|
||||
}
|
||||
|
||||
188
route/init.go
Normal file
@@ -0,0 +1,188 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/model/system_app"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/docker"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/env_helper"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/port"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
func InitFunction() {
|
||||
go checkSystemApp()
|
||||
}
|
||||
|
||||
var syncIsExistence = false
|
||||
|
||||
func installSyncthing(appId string) {
|
||||
|
||||
var appInfo model.ServerAppList
|
||||
m := model.CustomizationPostData{}
|
||||
var dockerImage string
|
||||
var dockerImageVersion string
|
||||
|
||||
appInfo = service.MyService.OAPI().GetServerAppInfo(appId)
|
||||
|
||||
dockerImage = appInfo.Image
|
||||
|
||||
if len(appInfo.ImageVersion) == 0 {
|
||||
dockerImageVersion = "latest"
|
||||
}
|
||||
|
||||
if appInfo.NetworkModel != "host" {
|
||||
for i := 0; i < len(appInfo.Ports); i++ {
|
||||
if p, _ := strconv.Atoi(appInfo.Ports[i].ContainerPort); port.IsPortAvailable(p, appInfo.Ports[i].Protocol) {
|
||||
appInfo.Ports[i].CommendPort = strconv.Itoa(p)
|
||||
} else {
|
||||
if appInfo.Ports[i].Protocol == "tcp" {
|
||||
if p, err := port.GetAvailablePort("tcp"); err == nil {
|
||||
appInfo.Ports[i].CommendPort = strconv.Itoa(p)
|
||||
}
|
||||
} else if appInfo.Ports[i].Protocol == "upd" {
|
||||
if p, err := port.GetAvailablePort("udp"); err == nil {
|
||||
appInfo.Ports[i].CommendPort = strconv.Itoa(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if appInfo.Ports[i].Type == 0 {
|
||||
appInfo.PortMap = appInfo.Ports[i].CommendPort
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < len(appInfo.Devices); i++ {
|
||||
if !file.CheckNotExist(appInfo.Devices[i].ContainerPath) {
|
||||
appInfo.Devices[i].Path = appInfo.Devices[i].ContainerPath
|
||||
}
|
||||
}
|
||||
if len(appInfo.Tip) > 0 {
|
||||
appInfo.Tip = env_helper.ReplaceStringDefaultENV(appInfo.Tip)
|
||||
}
|
||||
|
||||
for i := 0; i < len(appInfo.Volumes); i++ {
|
||||
appInfo.Volumes[i].Path = docker.GetDir("", appInfo.Volumes[i].ContainerPath)
|
||||
}
|
||||
appInfo.MaxMemory = service.MyService.ZiMa().GetMemInfo().Total >> 20
|
||||
|
||||
id := uuid.NewV4().String()
|
||||
|
||||
installLog := model2.AppNotify{}
|
||||
|
||||
// step:下载镜像
|
||||
err := service.MyService.Docker().DockerPullImage(dockerImage+":"+dockerImageVersion, installLog)
|
||||
if err != nil {
|
||||
//pull image error
|
||||
return
|
||||
}
|
||||
|
||||
for !service.MyService.Docker().IsExistImage(dockerImage + ":" + dockerImageVersion) {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
m.CpuShares = 50
|
||||
m.Envs = appInfo.Envs
|
||||
m.Memory = int64(appInfo.MaxMemory)
|
||||
m.Origin = "system"
|
||||
m.PortMap = appInfo.PortMap
|
||||
m.Ports = appInfo.Ports
|
||||
m.Restart = ""
|
||||
m.Volumes = appInfo.Volumes
|
||||
|
||||
containerId, err := service.MyService.Docker().DockerContainerCreate(dockerImage+":"+dockerImageVersion, id, m, appInfo.NetworkModel)
|
||||
|
||||
if err != nil {
|
||||
// create container error
|
||||
return
|
||||
}
|
||||
|
||||
//step:start container
|
||||
err = service.MyService.Docker().DockerContainerStart(id)
|
||||
if err != nil {
|
||||
//start container error
|
||||
return
|
||||
}
|
||||
|
||||
portsStr, _ := json.Marshal(appInfo.Ports)
|
||||
envsStr, _ := json.Marshal(appInfo.Envs)
|
||||
volumesStr, _ := json.Marshal(appInfo.Volumes)
|
||||
devicesStr, _ := json.Marshal(appInfo.Devices)
|
||||
//step: 保存数据到数据库
|
||||
md := model2.AppListDBModel{
|
||||
CustomId: id,
|
||||
Title: appInfo.Title,
|
||||
//ScreenshotLink: appInfo.ScreenshotLink,
|
||||
Slogan: appInfo.Tagline,
|
||||
Description: appInfo.Description,
|
||||
//Tags: appInfo.Tags,
|
||||
Icon: appInfo.Icon,
|
||||
Version: dockerImageVersion,
|
||||
ContainerId: containerId,
|
||||
Image: dockerImage,
|
||||
Index: appInfo.Index,
|
||||
PortMap: appInfo.PortMap,
|
||||
Label: appInfo.Title,
|
||||
EnableUPNP: false,
|
||||
Ports: string(portsStr),
|
||||
Envs: string(envsStr),
|
||||
Volumes: string(volumesStr),
|
||||
Position: true,
|
||||
NetModel: appInfo.NetworkModel,
|
||||
Restart: m.Restart,
|
||||
CpuShares: 50,
|
||||
Memory: int64(appInfo.MaxMemory),
|
||||
Devices: string(devicesStr),
|
||||
Origin: m.Origin,
|
||||
CreatedAt: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
UpdatedAt: strconv.FormatInt(time.Now().Unix(), 10),
|
||||
}
|
||||
service.MyService.App().SaveContainer(md)
|
||||
|
||||
checkSystemApp()
|
||||
}
|
||||
|
||||
// check if the system application is installed
|
||||
func checkSystemApp() {
|
||||
list := service.MyService.App().GetSystemAppList()
|
||||
for _, v := range *list {
|
||||
if v.Image == "linuxserver/syncthing" {
|
||||
syncIsExistence = true
|
||||
if config.SystemConfigInfo.SyncPort != v.Port {
|
||||
config.SystemConfigInfo.SyncPort = v.Port
|
||||
}
|
||||
var paths []model.PathMap
|
||||
json.Unmarshal([]byte(v.Volumes), &paths)
|
||||
path := ""
|
||||
for _, i := range paths {
|
||||
if i.ContainerPath == "/config" {
|
||||
path = docker.GetDir(v.CustomId, i.ContainerPath) + "config.xml"
|
||||
for i := 0; i < 10; i++ {
|
||||
if file.CheckNotExist(path) {
|
||||
time.Sleep(1 * time.Second)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
content := file.ReadFullFile(path)
|
||||
syncConfig := &system_app.SyncConfig{}
|
||||
xml.Unmarshal(content, &syncConfig)
|
||||
config.SystemConfigInfo.SyncKey = syncConfig.Key
|
||||
}
|
||||
}
|
||||
if !syncIsExistence {
|
||||
installSyncthing("44")
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/middleware"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
jwt2 "github.com/IceWhaleTech/CasaOS/pkg/utils/jwt"
|
||||
v1 "github.com/IceWhaleTech/CasaOS/route/v1"
|
||||
"github.com/IceWhaleTech/CasaOS/web"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var swagHandler gin.HandlerFunc
|
||||
|
||||
func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
|
||||
func InitRouter() *gin.Engine {
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(middleware.Cors())
|
||||
@@ -26,10 +27,16 @@ func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
|
||||
if swagHandler != nil {
|
||||
r.GET("/swagger/*any", swagHandler)
|
||||
}
|
||||
//登录
|
||||
|
||||
r.POST("/v1/user/login", v1.Login)
|
||||
|
||||
r.GET("/v1/guide/check", v1.GetGuideCheck)
|
||||
|
||||
r.GET("/debug", v1.GetSystemConfigDebug)
|
||||
//set user
|
||||
r.POST("/v1/user/setusernamepwd", v1.Set_Name_Pwd)
|
||||
//get user info
|
||||
r.GET("/v1/user/info", v1.UserInfo)
|
||||
|
||||
v1Group := r.Group("/v1")
|
||||
|
||||
@@ -38,8 +45,7 @@ func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
|
||||
v1UserGroup := v1Group.Group("/user")
|
||||
v1UserGroup.Use()
|
||||
{
|
||||
//设置用户
|
||||
v1UserGroup.POST("/setusernamepwd", v1.Set_Name_Pwd)
|
||||
|
||||
//chang head
|
||||
v1UserGroup.POST("/changhead", v1.Up_Load_Head)
|
||||
//chang user name
|
||||
@@ -48,8 +54,7 @@ func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
|
||||
v1UserGroup.PUT("/changuserpwd", v1.Chang_User_Pwd)
|
||||
//edit user info
|
||||
v1UserGroup.POST("/changuserinfo", v1.Chang_User_Info)
|
||||
//get user info
|
||||
v1UserGroup.GET("/info", v1.UserInfo)
|
||||
|
||||
}
|
||||
|
||||
v1ZiMaGroup := v1Group.Group("/zima")
|
||||
@@ -182,7 +187,10 @@ func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
|
||||
v1SysGroup.GET("/sys", v1.Sys)
|
||||
v1SysGroup.GET("/wsssh", v1.WsSsh)
|
||||
v1SysGroup.GET("/config", v1.GetSystemConfig)
|
||||
v1SysGroup.GET("/error/logs", v1.GetCasaOSErrorLogs)
|
||||
v1SysGroup.POST("/config", v1.PostSetSystemConfig)
|
||||
v1SysGroup.GET("/widget/config", v1.GetWidgetConfig)
|
||||
v1SysGroup.POST("/widget/config", v1.PostSetWidgetConfig)
|
||||
}
|
||||
v1FileGroup := v1Group.Group("/file")
|
||||
v1FileGroup.Use()
|
||||
@@ -194,6 +202,7 @@ func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
|
||||
v1FileGroup.GET("/dirpath", v1.DirPath)
|
||||
//创建目录
|
||||
v1FileGroup.POST("/mkdir", v1.MkdirAll)
|
||||
v1FileGroup.POST("/create", v1.PostCreateFile)
|
||||
|
||||
v1FileGroup.GET("/download", v1.GetDownloadFile)
|
||||
//v1FileGroup.GET("/download", v1.UserFileDownloadCommonService)
|
||||
@@ -252,6 +261,12 @@ func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
|
||||
v1NotifyGroup.GET("/ws", v1.NotifyWS)
|
||||
v1NotifyGroup.PUT("/read/:id", v1.PutNotifyRead)
|
||||
}
|
||||
v1SearchGroup := v1Group.Group("/search")
|
||||
v1SearchGroup.Use()
|
||||
{
|
||||
v1SearchGroup.GET("/search", v1.GetSearchList)
|
||||
}
|
||||
v1Group.GET("/sync/*url", v1.SyncToSyncthing)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/docker"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/env_helper"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
port2 "github.com/IceWhaleTech/CasaOS/pkg/utils/port"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/sort"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// @Summary 获取远程列表
|
||||
@@ -110,51 +112,66 @@ func MyAppList(c *gin.Context) {
|
||||
func AppInfo(c *gin.Context) {
|
||||
|
||||
id := c.Param("id")
|
||||
info := service.MyService.App().GetServerAppInfo(id)
|
||||
info := service.MyService.OAPI().GetServerAppInfo(id)
|
||||
if info.NetworkModel != "host" {
|
||||
port, _ := port2.GetAvailablePort("tcp")
|
||||
info.PortMap = uint(port)
|
||||
for i := 0; i < len(info.Configures.TcpPorts); i++ {
|
||||
info.Configures.TcpPorts[i].CommendPort, _ = port2.GetAvailablePort("tcp")
|
||||
}
|
||||
for i := 0; i < len(info.Configures.UdpPorts); i++ {
|
||||
info.Configures.UdpPorts[i].CommendPort, _ = port2.GetAvailablePort("udp")
|
||||
}
|
||||
} else {
|
||||
info.PortMap = info.TcpPort
|
||||
}
|
||||
for i := 0; i < len(info.Ports); i++ {
|
||||
if p, _ := strconv.Atoi(info.Ports[i].ContainerPort); port2.IsPortAvailable(p, info.Ports[i].Protocol) {
|
||||
info.Ports[i].CommendPort = strconv.Itoa(p)
|
||||
} else {
|
||||
if info.Ports[i].Protocol == "tcp" {
|
||||
if p, err := port2.GetAvailablePort("tcp"); err == nil {
|
||||
info.Ports[i].CommendPort = strconv.Itoa(p)
|
||||
}
|
||||
} else if info.Ports[i].Protocol == "upd" {
|
||||
if p, err := port2.GetAvailablePort("udp"); err == nil {
|
||||
info.Ports[i].CommendPort = strconv.Itoa(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < len(info.Configures.Devices); i++ {
|
||||
if !file.CheckNotExist(info.Configures.Devices[i].ContainerPath) {
|
||||
info.Configures.Devices[i].Path = info.Configures.Devices[i].ContainerPath
|
||||
if info.Ports[i].Type == 0 {
|
||||
info.PortMap = info.Ports[i].CommendPort
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
portOrder := func(c1, c2 *model.Ports) bool {
|
||||
return c1.Type < c2.Type
|
||||
for i := 0; i < len(info.Devices); i++ {
|
||||
if !file.CheckNotExist(info.Devices[i].ContainerPath) {
|
||||
info.Devices[i].Path = info.Devices[i].ContainerPath
|
||||
}
|
||||
}
|
||||
if len(info.Tip) > 0 {
|
||||
info.Tip = env_helper.ReplaceStringDefaultENV(info.Tip)
|
||||
}
|
||||
|
||||
envOrder := func(c1, c2 *model.Envs) bool {
|
||||
return c1.Type < c2.Type
|
||||
for i := 0; i < len(info.Volumes); i++ {
|
||||
info.Volumes[i].Path = docker.GetDir("", info.Volumes[i].ContainerPath)
|
||||
}
|
||||
// portOrder := func(c1, c2 *model.Ports) bool {
|
||||
// return c1.Type < c2.Type
|
||||
// }
|
||||
|
||||
volOrder := func(c1, c2 *model.Volume) bool {
|
||||
return c1.Type < c2.Type
|
||||
}
|
||||
// envOrder := func(c1, c2 *model.Envs) bool {
|
||||
// return c1.Type < c2.Type
|
||||
// }
|
||||
|
||||
devOrder := func(c1, c2 *model.Devices) bool {
|
||||
return c1.Type < c2.Type
|
||||
}
|
||||
// volOrder := func(c1, c2 *model.Volume) bool {
|
||||
// return c1.Type < c2.Type
|
||||
// }
|
||||
|
||||
// devOrder := func(c1, c2 *model.Devices) bool {
|
||||
// return c1.Type < c2.Type
|
||||
// }
|
||||
|
||||
//sort
|
||||
if info.NetworkModel != "host" {
|
||||
sort.PortsSort(portOrder).Sort(info.Configures.TcpPorts)
|
||||
sort.PortsSort(portOrder).Sort(info.Configures.UdpPorts)
|
||||
}
|
||||
// if info.NetworkModel != "host" {
|
||||
// sort.PortsSort(portOrder).Sort(info.Configures.TcpPorts)
|
||||
// sort.PortsSort(portOrder).Sort(info.Configures.UdpPorts)
|
||||
// }
|
||||
|
||||
sort.EnvSort(envOrder).Sort(info.Configures.Envs)
|
||||
sort.VolSort(volOrder).Sort(info.Configures.Volumes)
|
||||
sort.DevSort(devOrder).Sort(info.Configures.Devices)
|
||||
// sort.EnvSort(envOrder).Sort(info.Envs)
|
||||
// sort.VolSort(volOrder).Sort(info.Volumes.([]model.PathMap))
|
||||
// sort.DevSort(devOrder).Sort(info.Devices)
|
||||
|
||||
info.MaxMemory = service.MyService.ZiMa().GetMemInfo().Total >> 20
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@ package v1
|
||||
import (
|
||||
"bytes"
|
||||
json2 "encoding/json"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/docker"
|
||||
upnp2 "github.com/IceWhaleTech/CasaOS/pkg/upnp"
|
||||
@@ -19,11 +25,8 @@ import (
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/jinzhu/copier"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"github.com/tidwall/gjson"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
var upgrader = websocket.Upgrader{
|
||||
@@ -64,19 +67,46 @@ func DockerTerminal(c *gin.Context) {
|
||||
//打开本机的ssh接口
|
||||
func WsSsh(c *gin.Context) {
|
||||
wsConn, _ := upgrader.Upgrade(c.Writer, c.Request, nil)
|
||||
defer wsConn.Close()
|
||||
cols, _ := strconv.Atoi(c.DefaultQuery("cols", "200"))
|
||||
rows, _ := strconv.Atoi(c.DefaultQuery("rows", "32"))
|
||||
client, _ := docker.NewSshClient()
|
||||
defer client.Close()
|
||||
ssConn, _ := docker.NewSshConn(cols, rows, client)
|
||||
defer ssConn.Close()
|
||||
quitChan := make(chan bool, 3)
|
||||
|
||||
var logBuff = new(bytes.Buffer)
|
||||
quitChan := make(chan bool, 3)
|
||||
user := ""
|
||||
password := ""
|
||||
var login int = 1
|
||||
cols, _ := strconv.Atoi(c.DefaultQuery("cols", "200"))
|
||||
rows, _ := strconv.Atoi(c.DefaultQuery("rows", "32"))
|
||||
var client *ssh.Client
|
||||
for login != 0 {
|
||||
|
||||
var err error
|
||||
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte("login:"))
|
||||
user = docker.ReceiveWsMsgUser(wsConn, logBuff)
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte("\r\n\x1b[0m"))
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte("password:"))
|
||||
password = docker.ReceiveWsMsgPassword(wsConn, logBuff)
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte("\r\n\x1b[0m"))
|
||||
client, err = docker.NewSshClient(user, password)
|
||||
|
||||
if err != nil && client == nil {
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte(err.Error()))
|
||||
wsConn.WriteMessage(websocket.TextMessage, []byte("\r\n\x1b[0m"))
|
||||
} else {
|
||||
login = 0
|
||||
}
|
||||
|
||||
}
|
||||
if client != nil {
|
||||
defer client.Close()
|
||||
}
|
||||
|
||||
ssConn, _ := docker.NewSshConn(cols, rows, client)
|
||||
defer ssConn.Close()
|
||||
|
||||
go ssConn.ReceiveWsMsg(wsConn, logBuff, quitChan)
|
||||
go ssConn.SendComboOutput(wsConn, quitChan)
|
||||
go ssConn.SessionWait(quitChan)
|
||||
|
||||
<-quitChan
|
||||
|
||||
}
|
||||
@@ -143,7 +173,7 @@ func InstallApp(c *gin.Context) {
|
||||
dockerImageVersion = "latest"
|
||||
}
|
||||
if m.Origin != "custom" {
|
||||
appInfo = service.MyService.App().GetServerAppInfo(appId)
|
||||
appInfo = service.MyService.OAPI().GetServerAppInfo(appId)
|
||||
|
||||
} else {
|
||||
|
||||
@@ -209,10 +239,9 @@ func InstallApp(c *gin.Context) {
|
||||
var relyMap = make(map[string]string)
|
||||
go func() {
|
||||
installLog := model2.AppNotify{}
|
||||
installLog.CustomId = id
|
||||
installLog.State = 0
|
||||
installLog.CustomId = id
|
||||
installLog.Message = "installing rely"
|
||||
installLog.Speed = 10
|
||||
installLog.Type = types.NOTIFY_TYPE_UNIMPORTANT
|
||||
installLog.CreatedAt = strconv.FormatInt(time.Now().Unix(), 10)
|
||||
installLog.UpdatedAt = strconv.FormatInt(time.Now().Unix(), 10)
|
||||
@@ -250,16 +279,13 @@ func InstallApp(c *gin.Context) {
|
||||
} else {
|
||||
docker_base.MysqlDelete(mysqlContainerId)
|
||||
installLog.State = 0
|
||||
installLog.Speed = 30
|
||||
installLog.Message = err.Error()
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
installLog.Speed = 50
|
||||
installLog.Message = "pulling"
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
|
||||
@@ -267,7 +293,6 @@ func InstallApp(c *gin.Context) {
|
||||
err := service.MyService.Docker().DockerPullImage(dockerImage+":"+dockerImageVersion, installLog)
|
||||
if err != nil {
|
||||
installLog.State = 0
|
||||
installLog.Speed = 70
|
||||
installLog.Message = err.Error()
|
||||
installLog.Type = types.NOTIFY_TYPE_ERROR
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
@@ -283,36 +308,45 @@ func InstallApp(c *gin.Context) {
|
||||
//}
|
||||
|
||||
//step:创建容器
|
||||
// networkName, err := service.MyService.Docker().GetNetWorkNameByNetWorkID(appInfo.NetworkModel)
|
||||
// if err != nil {
|
||||
// //service.MyService.Redis().Set(id, "{\"id\"\""+id+"\",\"state\":false,\"message\":\""+err.Error()+"\",\"speed\":80}", 100)
|
||||
// installLog.State = 0
|
||||
// installLog.Speed = 75
|
||||
// installLog.Type = types.NOTIFY_TYPE_ERROR
|
||||
// installLog.Message = err.Error()
|
||||
// service.MyService.Notify().UpdateLog(installLog)
|
||||
// return
|
||||
// }
|
||||
containerId, err := service.MyService.Docker().DockerContainerCreate(dockerImage+":"+dockerImageVersion, id, m, appInfo.NetworkModel)
|
||||
installLog.ContainerId = containerId
|
||||
installLog.Name = appInfo.Title
|
||||
installLog.Icon = appInfo.Icon
|
||||
if err != nil {
|
||||
//service.MyService.Redis().Set(id, "{\"id\"\""+id+"\",\"state\":false,\"message\":\""+err.Error()+"\",\"speed\":80}", 100)
|
||||
installLog.State = 0
|
||||
installLog.Speed = 80
|
||||
installLog.Type = types.NOTIFY_TYPE_ERROR
|
||||
installLog.Message = err.Error()
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
return
|
||||
} else {
|
||||
//service.MyService.Redis().Set(id, "{\"id\":\""+id+"\",\"state\":true,\"message\":\"starting\",\"speed\":80}", 100)
|
||||
installLog.Speed = 80
|
||||
installLog.Message = "starting"
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
}
|
||||
|
||||
// echo -e "hellow\nworld" >>
|
||||
|
||||
//step:启动容器
|
||||
err = service.MyService.Docker().DockerContainerStart(id)
|
||||
if err != nil {
|
||||
//service.MyService.Redis().Set(id, "{\"id\"\""+id+"\",\"state\":false,\"message\":\""+err.Error()+"\",\"speed\":90}", 100)
|
||||
installLog.State = 0
|
||||
installLog.Type = types.NOTIFY_TYPE_ERROR
|
||||
installLog.Speed = 90
|
||||
installLog.Message = err.Error()
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
return
|
||||
} else {
|
||||
//service.MyService.Redis().Set(id, "{\"id\":\""+id+"\",\"state\":true,\"message\":\"setting upnp\",\"speed\":90}", 100)
|
||||
installLog.Speed = 90
|
||||
if m.Origin != CUSTOM {
|
||||
installLog.Message = "setting upnp"
|
||||
} else {
|
||||
@@ -357,13 +391,11 @@ func InstallApp(c *gin.Context) {
|
||||
if err != nil {
|
||||
//service.MyService.Redis().Set(id, "{\"id\"\""+id+"\",\"state\":false,\"message\":\""+err.Error()+"\",\"speed\":95}", 100)
|
||||
installLog.State = 0
|
||||
installLog.Speed = 95
|
||||
installLog.Type = types.NOTIFY_TYPE_ERROR
|
||||
installLog.Message = err.Error()
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
} else {
|
||||
//service.MyService.Redis().Set(id, "{\"id\":\""+id+"\",\"state\":true,\"message\":\"checking\",\"speed\":95}", 100)
|
||||
installLog.Speed = 95
|
||||
installLog.Message = "checking"
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
}
|
||||
@@ -375,14 +407,12 @@ func InstallApp(c *gin.Context) {
|
||||
if err != nil && container.ContainerJSONBase.State.Running {
|
||||
//service.MyService.Redis().Set(id, "{\"id\"\""+id+"\",\"state\":false,\"message\":\""+err.Error()+"\",\"speed\":100}", 100)
|
||||
installLog.State = 0
|
||||
installLog.Speed = 100
|
||||
installLog.Type = types.NOTIFY_TYPE_ERROR
|
||||
installLog.Message = err.Error()
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
return
|
||||
} else {
|
||||
//service.MyService.Redis().Set(id, "{\"id\":\""+id+"\",\"state\":true,\"message\":\"installed\",\"speed\":100}", 100)
|
||||
installLog.Speed = 100
|
||||
installLog.Message = "installed"
|
||||
service.MyService.Notify().UpdateLog(installLog)
|
||||
}
|
||||
@@ -658,7 +688,11 @@ func UnInstallApp(c *gin.Context) {
|
||||
if info.Origin != "custom" {
|
||||
|
||||
//step: 删除文件夹
|
||||
service.MyService.App().DelAppConfigDir(appId)
|
||||
vol := gjson.Get(info.Volumes, "#.host")
|
||||
for _, v := range vol.Array() {
|
||||
|
||||
service.MyService.App().DelAppConfigDir(appId, v.String())
|
||||
}
|
||||
|
||||
//step: 删除install log
|
||||
service.MyService.Notify().DelLog(appId)
|
||||
@@ -763,7 +797,6 @@ func ContainerLog(c *gin.Context) {
|
||||
func GetInstallSpeed(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
b := service.MyService.Notify().GetLog(id)
|
||||
b.Id = b.CustomId
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: b})
|
||||
}
|
||||
|
||||
@@ -873,12 +906,17 @@ func UpdateSetting(c *gin.Context) {
|
||||
envsStr, _ := json2.Marshal(m.Envs)
|
||||
volumesStr, _ := json2.Marshal(m.Volumes)
|
||||
devicesStr, _ := json2.Marshal(m.Devices)
|
||||
if !reflect.DeepEqual(string(portsStr), appInfo.Ports) || !reflect.DeepEqual(string(envsStr), appInfo.Envs) || !reflect.DeepEqual(string(volumesStr), appInfo.Volumes) || m.PortMap != appInfo.PortMap {
|
||||
if !reflect.DeepEqual(string(portsStr), appInfo.Ports) || !reflect.DeepEqual(string(envsStr), appInfo.Envs) || !reflect.DeepEqual(string(volumesStr), appInfo.Volumes) || m.PortMap != appInfo.PortMap || m.NetworkModel != appInfo.NetModel {
|
||||
|
||||
var newUUid = uuid.NewV4().String()
|
||||
var err error
|
||||
|
||||
containerId, err = service.MyService.Docker().DockerContainerCreate(appInfo.Image+":"+appInfo.Version, newUUid, cpd, appInfo.NetModel)
|
||||
// networkName, err := service.MyService.Docker().GetNetWorkNameByNetWorkID(appInfo.NetModel)
|
||||
// if err != nil {
|
||||
// c.JSON(http.StatusOK, model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.ERROR)})
|
||||
// return
|
||||
// }
|
||||
containerId, err = service.MyService.Docker().DockerContainerCreate(appInfo.Image+":"+appInfo.Version, newUUid, cpd, m.NetworkModel)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.ERROR)})
|
||||
@@ -980,6 +1018,7 @@ func UpdateSetting(c *gin.Context) {
|
||||
appInfo.Icon = m.Icon
|
||||
appInfo.Volumes = string(volumesStr)
|
||||
appInfo.Devices = string(devicesStr)
|
||||
appInfo.NetModel = m.NetworkModel
|
||||
appInfo.Position = m.Position
|
||||
appInfo.EnableUPNP = m.EnableUPNP
|
||||
appInfo.Restart = m.Restart
|
||||
@@ -1087,16 +1126,20 @@ func ContainerUpdateInfo(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: err.Error()})
|
||||
return
|
||||
}
|
||||
var port model.PortArrey
|
||||
var port model.PortArray
|
||||
json2.Unmarshal([]byte(appInfo.Ports), &port)
|
||||
|
||||
var envs model.EnvArrey
|
||||
var envs model.EnvArray
|
||||
json2.Unmarshal([]byte(appInfo.Envs), &envs)
|
||||
|
||||
var vol model.PathArrey
|
||||
var vol model.PathArray
|
||||
json2.Unmarshal([]byte(appInfo.Volumes), &vol)
|
||||
|
||||
var dir model.PathArrey
|
||||
for i := 0; i < len(vol); i++ {
|
||||
vol[i].Path = strings.ReplaceAll(vol[i].Path, "$AppID", appId)
|
||||
}
|
||||
|
||||
var dir model.PathArray
|
||||
json2.Unmarshal([]byte(appInfo.Devices), &dir)
|
||||
|
||||
//volumesStr, _ := json2.Marshal(m.Volumes)
|
||||
|
||||
@@ -4,16 +4,17 @@ import (
|
||||
"bufio"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func downloadReadFile(c *gin.Context) {
|
||||
@@ -218,6 +219,25 @@ func MkdirAll(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, model.Result{Success: code, Message: oasis_err2.GetMsg(code)})
|
||||
}
|
||||
|
||||
// @Summary 创建文件
|
||||
// @Produce application/json
|
||||
// @Accept multipart/form-data
|
||||
// @Tags file
|
||||
// @Security ApiKeyAuth
|
||||
// @Param path formData string false "路径"
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Router /file/create [post]
|
||||
func PostCreateFile(c *gin.Context) {
|
||||
path := c.PostForm("path")
|
||||
var code int
|
||||
if len(path) == 0 {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.INVALID_PARAMS, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
|
||||
return
|
||||
}
|
||||
code, _ = service.MyService.ZiMa().CreateFile(path)
|
||||
c.JSON(http.StatusOK, model.Result{Success: code, Message: oasis_err2.GetMsg(code)})
|
||||
}
|
||||
|
||||
// @Summary 上传文件
|
||||
// @Produce application/json
|
||||
// @Accept multipart/form-data
|
||||
|
||||
22
route/v1/search.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetSearchList(c *gin.Context) {
|
||||
key := c.DefaultQuery("key", "")
|
||||
if len(key) == 0 {
|
||||
return
|
||||
}
|
||||
list, err := service.MyService.Search().SearchList(key)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS), Data: list})
|
||||
}
|
||||
22
route/v1/sync.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func SyncToSyncthing(c *gin.Context) {
|
||||
u := c.Param("url")
|
||||
target := "http://127.0.0.1:" + config.SystemConfigInfo.SyncPort
|
||||
remote, err := url.Parse(target)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
proxy := httputil.NewSingleHostReverseProxy(remote)
|
||||
c.Request.Header.Add("X-API-Key", config.SystemConfigInfo.SyncKey)
|
||||
c.Request.URL.Path = u
|
||||
proxy.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
@@ -10,9 +15,6 @@ import (
|
||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||
"github.com/IceWhaleTech/CasaOS/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// @Summary 系统信息
|
||||
@@ -26,13 +28,12 @@ func CheckVersion(c *gin.Context) {
|
||||
need, version := version.IsNeedUpdate()
|
||||
if need {
|
||||
installLog := model2.AppNotify{}
|
||||
installLog.CustomId = ""
|
||||
installLog.State = 0
|
||||
installLog.Message = "New version " + version.Version + " is ready, ready to upgrade"
|
||||
installLog.Speed = 100
|
||||
installLog.Type = types.NOTIFY_TYPE_NEED_CONFIRM
|
||||
installLog.CreatedAt = strconv.FormatInt(time.Now().Unix(), 10)
|
||||
installLog.UpdatedAt = strconv.FormatInt(time.Now().Unix(), 10)
|
||||
installLog.Name = "CasaOS System"
|
||||
service.MyService.Notify().AddLog(installLog)
|
||||
}
|
||||
data := make(map[string]interface{}, 1)
|
||||
@@ -51,10 +52,8 @@ func CheckVersion(c *gin.Context) {
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Router /sys/update [post]
|
||||
func SystemUpdate(c *gin.Context) {
|
||||
fmt.Println("开始更新")
|
||||
need, version := version.IsNeedUpdate()
|
||||
if need {
|
||||
fmt.Println("进入更新")
|
||||
service.MyService.System().UpdateSystemVersion(version.Version)
|
||||
}
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS)})
|
||||
@@ -62,28 +61,40 @@ func SystemUpdate(c *gin.Context) {
|
||||
|
||||
//系统配置
|
||||
func GetSystemConfig(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS), Data: config.SystemConfigInfo})
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS), Data: json.RawMessage(config.SystemConfigInfo.ConfigStr)})
|
||||
}
|
||||
|
||||
// @Summary get logs
|
||||
// @Produce application/json
|
||||
// @Accept application/json
|
||||
// @Tags sys
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Router /sys/error/logs [get]
|
||||
func GetCasaOSErrorLogs(c *gin.Context) {
|
||||
line, _ := strconv.Atoi(c.DefaultQuery("line", "100"))
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS), Data: service.MyService.System().GetCasaOSLogs(line)})
|
||||
}
|
||||
|
||||
// @Summary 修改配置文件
|
||||
// @Produce application/json
|
||||
// @Accept multipart/form-data
|
||||
// @Tags user
|
||||
// @Tags sys
|
||||
// @Param file formData file true "用户头像"
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Router /user/changhead [post]
|
||||
// @Router /sys/changhead [post]
|
||||
func PostSetSystemConfig(c *gin.Context) {
|
||||
var systemConfig model.SystemConfig
|
||||
c.BindJSON(&systemConfig)
|
||||
service.MyService.System().UpSystemConfig(systemConfig)
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := c.Request.Body.Read(buf)
|
||||
|
||||
service.MyService.System().UpSystemConfig(string(buf[0:n]), "")
|
||||
c.JSON(http.StatusOK,
|
||||
model.Result{
|
||||
Success: oasis_err.SUCCESS,
|
||||
Message: oasis_err.GetMsg(oasis_err.SUCCESS),
|
||||
Data: config.SystemConfigInfo,
|
||||
Data: json.RawMessage(config.SystemConfigInfo.ConfigStr),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//系统配置
|
||||
@@ -98,3 +109,50 @@ func GetSystemConfigDebug(c *gin.Context) {
|
||||
func Sys(c *gin.Context) {
|
||||
service.DockerPull()
|
||||
}
|
||||
|
||||
//widget配置
|
||||
func GetWidgetConfig(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS), Data: json.RawMessage(config.SystemConfigInfo.WidgetList)})
|
||||
}
|
||||
|
||||
// @Summary 修改组件配置文件
|
||||
// @Produce application/json
|
||||
// @Accept application/json
|
||||
// @Tags sys
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Router /sys/widget/config [post]
|
||||
func PostSetWidgetConfig(c *gin.Context) {
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := c.Request.Body.Read(buf)
|
||||
|
||||
service.MyService.System().UpSystemConfig("", string(buf[0:n]))
|
||||
c.JSON(http.StatusOK,
|
||||
model.Result{
|
||||
Success: oasis_err.SUCCESS,
|
||||
Message: oasis_err.GetMsg(oasis_err.SUCCESS),
|
||||
Data: json.RawMessage(config.SystemConfigInfo.WidgetList),
|
||||
})
|
||||
}
|
||||
|
||||
// @Summary 检查是否进入引导状态
|
||||
// @Produce application/json
|
||||
// @Accept application/json
|
||||
// @Tags sys
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Router /guide/check [get]
|
||||
func GetGuideCheck(c *gin.Context) {
|
||||
initUser := false
|
||||
if !config.UserInfo.Initialized {
|
||||
initUser = true
|
||||
}
|
||||
data := make(map[string]interface{}, 1)
|
||||
data["need_init_user"] = initUser
|
||||
c.JSON(http.StatusOK,
|
||||
model.Result{
|
||||
Success: oasis_err.SUCCESS,
|
||||
Message: oasis_err.GetMsg(oasis_err.SUCCESS),
|
||||
Data: data,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@ package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
jwt2 "github.com/IceWhaleTech/CasaOS/pkg/utils/jwt"
|
||||
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/IceWhaleTech/CasaOS/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var user_service service.UserService
|
||||
@@ -32,7 +34,7 @@ func Set_Name_Pwd(c *gin.Context) {
|
||||
username := c.PostForm("username")
|
||||
pwd := c.PostForm("pwd")
|
||||
//老用户名是否存在即新用户名和密码的验证
|
||||
if len(config.UserInfo.UserName) > 0 || len(username) == 0 || len(pwd) == 0 {
|
||||
if config.UserInfo.Initialized || len(username) == 0 || len(pwd) == 0 {
|
||||
c.JSON(http.StatusOK,
|
||||
model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.INVALID_PARAMS)})
|
||||
return
|
||||
@@ -69,15 +71,18 @@ func Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
//if config.UserInfo.UserName == username && config.UserInfo.PWD == pwd {
|
||||
if username == "admin" && pwd == "admin" {
|
||||
token := jwt2.GetToken(username, pwd)
|
||||
if config.UserInfo.UserName == username && config.UserInfo.PWD == pwd {
|
||||
//if username == "admin" && pwd == "admin" {
|
||||
|
||||
data := make(map[string]string, 2)
|
||||
data["token"] = jwt2.GetToken(username, pwd)
|
||||
data["version"] = types.CURRENTVERSION
|
||||
//user_service.SetUser("", "", token, "", "")
|
||||
c.JSON(http.StatusOK,
|
||||
model.Result{
|
||||
Success: oasis_err2.SUCCESS,
|
||||
Message: oasis_err2.GetMsg(oasis_err2.SUCCESS),
|
||||
Data: token,
|
||||
Data: data,
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -106,7 +111,6 @@ func Up_Load_Head(c *gin.Context) {
|
||||
Message: oasis_err2.GetMsg(oasis_err2.SUCCESS),
|
||||
Data: config.UserInfo.Head,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// @Summary 修改用户名
|
||||
@@ -127,7 +131,6 @@ func Chang_User_Name(c *gin.Context) {
|
||||
}
|
||||
user_service.SetUser(username, "", "", "", "")
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
|
||||
return
|
||||
}
|
||||
|
||||
// @Summary 修改密码
|
||||
@@ -142,13 +145,16 @@ func Chang_User_Name(c *gin.Context) {
|
||||
func Chang_User_Pwd(c *gin.Context) {
|
||||
oldpwd := c.PostForm("oldpwd")
|
||||
pwd := c.PostForm("pwd")
|
||||
if len(pwd) == 0 || config.UserInfo.PWD != oldpwd {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.ERROR, Message: oasis_err2.GetMsg(oasis_err2.ERROR)})
|
||||
if config.UserInfo.PWD != oldpwd {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.PWD_INVALID_OLD, Message: oasis_err2.GetMsg(oasis_err2.PWD_INVALID_OLD)})
|
||||
return
|
||||
}
|
||||
if len(pwd) == 0 {
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.PWD_IS_EMPTY, Message: oasis_err2.GetMsg(oasis_err2.PWD_IS_EMPTY)})
|
||||
return
|
||||
}
|
||||
user_service.SetUser("", pwd, "", "", "")
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
|
||||
return
|
||||
}
|
||||
|
||||
// @Summary 修改用户信息
|
||||
@@ -174,21 +180,23 @@ func Chang_User_Info(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
user_service.SetUser(username, pwd, "", email, description)
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
|
||||
return
|
||||
data := make(map[string]string, 2)
|
||||
|
||||
data["token"] = jwt2.GetToken(username, pwd)
|
||||
data["user_name"] = username
|
||||
data["head"] = config.UserInfo.Head
|
||||
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: data})
|
||||
}
|
||||
|
||||
// @Summary 获取用户详情
|
||||
// @Produce application/json
|
||||
// @Accept mapplication/json
|
||||
// @Tags user
|
||||
// @Security ApiKeyAuth
|
||||
// @Success 200 {string} string "ok"
|
||||
// @Router /user/info [get]
|
||||
func UserInfo(c *gin.Context) {
|
||||
var u = make(map[string]string, 2)
|
||||
u["user_name"] = config.UserInfo.UserName
|
||||
u["token"] = config.UserInfo.Token
|
||||
u["head"] = config.UserInfo.Head
|
||||
u["email"] = config.UserInfo.Email
|
||||
u["description"] = config.UserInfo.Description
|
||||
@@ -198,5 +206,4 @@ func UserInfo(c *gin.Context) {
|
||||
Message: oasis_err2.GetMsg(oasis_err2.SUCCESS),
|
||||
Data: u,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
109
service/app.go
@@ -2,35 +2,32 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
json2 "encoding/json"
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/docker"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
httper2 "github.com/IceWhaleTech/CasaOS/pkg/utils/httper"
|
||||
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
client2 "github.com/docker/docker/client"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tidwall/gjson"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AppService interface {
|
||||
GetMyList(index, size int, position bool) *[]model2.MyAppList
|
||||
SaveContainer(m model2.AppListDBModel)
|
||||
GetServerAppInfo(id string) model.ServerAppList
|
||||
GetUninstallInfo(id string) model2.AppListDBModel
|
||||
RemoveContainerById(id string)
|
||||
GetContainerInfo(name string) (types.Container, error)
|
||||
GetAppDBInfo(id string) model2.AppListDBModel
|
||||
UpdateApp(m model2.AppListDBModel)
|
||||
GetSimpleContainerInfo(name string) (types.Container, error)
|
||||
DelAppConfigDir(id string)
|
||||
DelAppConfigDir(id, path string)
|
||||
GetSystemAppList() *[]model2.MyAppList
|
||||
}
|
||||
|
||||
type appStruct struct {
|
||||
@@ -56,7 +53,7 @@ func (a *appStruct) GetMyList(index, size int, position bool) *[]model2.MyAppLis
|
||||
//获取本地数据库应用
|
||||
|
||||
var lm []model2.AppListDBModel
|
||||
a.db.Table(model2.CONTAINERTABLENAME).Select("title,icon,port_map,`index`,container_id,position,label,slogan").Find(&lm)
|
||||
a.db.Table(model2.CONTAINERTABLENAME).Select("title,icon,port_map,`index`,container_id,position,label,slogan,image").Find(&lm)
|
||||
|
||||
list := []model2.MyAppList{}
|
||||
lMap := make(map[string]interface{})
|
||||
@@ -69,6 +66,67 @@ func (a *appStruct) GetMyList(index, size int, position bool) *[]model2.MyAppLis
|
||||
lMap[dbModel.ContainerId] = dbModel
|
||||
}
|
||||
}
|
||||
for _, container := range containers {
|
||||
|
||||
if lMap[container.ID] != nil && container.Labels["origin"] != "system" {
|
||||
var m model2.AppListDBModel
|
||||
m = lMap[container.ID].(model2.AppListDBModel)
|
||||
if len(m.Label) == 0 {
|
||||
m.Label = m.Title
|
||||
}
|
||||
|
||||
info, err := cli.ContainerInspect(context.Background(), container.ID)
|
||||
var tm string
|
||||
if err != nil {
|
||||
tm = time.Now().String()
|
||||
} else {
|
||||
tm = info.State.StartedAt
|
||||
}
|
||||
list = append(list, model2.MyAppList{
|
||||
Name: m.Label,
|
||||
Icon: m.Icon,
|
||||
State: container.State,
|
||||
CustomId: strings.ReplaceAll(container.Names[0], "/", ""),
|
||||
Port: m.PortMap,
|
||||
Index: m.Index,
|
||||
UpTime: tm,
|
||||
Image: m.Image,
|
||||
Slogan: m.Slogan,
|
||||
//Rely: m.Rely,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return &list
|
||||
|
||||
}
|
||||
|
||||
//system application list
|
||||
func (a *appStruct) GetSystemAppList() *[]model2.MyAppList {
|
||||
//获取docker应用
|
||||
cli, err := client2.NewClientWithOpts(client2.FromEnv)
|
||||
if err != nil {
|
||||
a.log.Error("初始化client失败", "app.getmylist", "line:36", err)
|
||||
}
|
||||
defer cli.Close()
|
||||
fts := filters.NewArgs()
|
||||
fts.Add("label", "origin=system")
|
||||
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{All: true, Filters: fts})
|
||||
if err != nil {
|
||||
a.log.Error("获取docker容器失败", "app.getmylist", "line:42", err)
|
||||
}
|
||||
|
||||
//获取本地数据库应用
|
||||
|
||||
var lm []model2.AppListDBModel
|
||||
a.db.Table(model2.CONTAINERTABLENAME).Select("title,icon,port_map,`index`,container_id,position,label,slogan,image,volumes").Find(&lm)
|
||||
|
||||
list := []model2.MyAppList{}
|
||||
lMap := make(map[string]interface{})
|
||||
for _, dbModel := range lm {
|
||||
lMap[dbModel.ContainerId] = dbModel
|
||||
}
|
||||
for _, container := range containers {
|
||||
|
||||
if lMap[container.ID] != nil {
|
||||
@@ -93,7 +151,9 @@ func (a *appStruct) GetMyList(index, size int, position bool) *[]model2.MyAppLis
|
||||
Port: m.PortMap,
|
||||
Index: m.Index,
|
||||
UpTime: tm,
|
||||
Image: m.Image,
|
||||
Slogan: m.Slogan,
|
||||
Volumes: m.Volumes,
|
||||
//Rely: m.Rely,
|
||||
})
|
||||
}
|
||||
@@ -155,27 +215,6 @@ func (a *appStruct) GetUninstallInfo(id string) model2.AppListDBModel {
|
||||
return m
|
||||
}
|
||||
|
||||
func (a *appStruct) GetServerAppInfo(id string) model.ServerAppList {
|
||||
|
||||
head := make(map[string]string)
|
||||
|
||||
t := make(chan string)
|
||||
|
||||
go func() {
|
||||
str := httper2.Get(config.ServerInfo.ServerApi+"/token", nil)
|
||||
|
||||
t <- gjson.Get(str, "data").String()
|
||||
}()
|
||||
head["Authorization"] = <-t
|
||||
|
||||
infoS := httper2.Get(config.ServerInfo.ServerApi+"/v1/app/info/"+id, head)
|
||||
|
||||
info := model.ServerAppList{}
|
||||
json2.Unmarshal([]byte(gjson.Get(infoS, "data").String()), &info)
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
//创建容器成功后保存容器
|
||||
func (a *appStruct) SaveContainer(m model2.AppListDBModel) {
|
||||
a.db.Table(model2.CONTAINERTABLENAME).Create(&m)
|
||||
@@ -185,14 +224,20 @@ func (a *appStruct) UpdateApp(m model2.AppListDBModel) {
|
||||
a.db.Table(model2.CONTAINERTABLENAME).Save(&m)
|
||||
}
|
||||
|
||||
func (a *appStruct) DelAppConfigDir(id string) {
|
||||
command.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;DelAppConfigDir " + docker.GetDir(id, "/config"))
|
||||
func (a *appStruct) DelAppConfigDir(id, path string) {
|
||||
command.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;DelAppConfigDir " + docker.GetDir(id, path))
|
||||
}
|
||||
|
||||
func (a *appStruct) RemoveContainerById(id string) {
|
||||
a.db.Table(model2.CONTAINERTABLENAME).Where("custom_id = ?", id).Delete(&model2.AppListDBModel{})
|
||||
}
|
||||
|
||||
// init install
|
||||
func Init() {
|
||||
|
||||
}
|
||||
|
||||
func NewAppService(db *gorm.DB, logger loger2.OLog) AppService {
|
||||
Init()
|
||||
return &appStruct{db: db, log: logger}
|
||||
}
|
||||
|
||||
@@ -2,34 +2,29 @@ package service
|
||||
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
"strconv"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
httper2 "github.com/IceWhaleTech/CasaOS/pkg/utils/httper"
|
||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||
"github.com/tidwall/gjson"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type OasisService interface {
|
||||
type CasaService interface {
|
||||
GetServerList(index, size, tp, categoryId, key string) ([]model.ServerAppList, int64)
|
||||
GetServerCategoryList() []model.ServerCategoryList
|
||||
GetTaskList(size int) []model2.TaskDBModel
|
||||
GetServerAppInfo(id string) model.ServerAppList
|
||||
}
|
||||
|
||||
type oasisService struct {
|
||||
type casaService struct {
|
||||
}
|
||||
|
||||
func (o *oasisService) GetTaskList(size int) []model2.TaskDBModel {
|
||||
func (o *casaService) GetTaskList(size int) []model2.TaskDBModel {
|
||||
head := make(map[string]string)
|
||||
|
||||
t := make(chan string)
|
||||
|
||||
go func() {
|
||||
str := httper2.Get(config.ServerInfo.ServerApi+"/token", nil)
|
||||
|
||||
t <- gjson.Get(str, "data").String()
|
||||
}()
|
||||
head["Authorization"] = <-t
|
||||
head["Authorization"] = GetToken()
|
||||
|
||||
listS := httper2.Get(config.ServerInfo.ServerApi+"/v1/task/list/"+strconv.Itoa(size), head)
|
||||
|
||||
@@ -39,18 +34,11 @@ func (o *oasisService) GetTaskList(size int) []model2.TaskDBModel {
|
||||
return list
|
||||
}
|
||||
|
||||
func (o *oasisService) GetServerList(index, size, tp, categoryId, key string) ([]model.ServerAppList, int64) {
|
||||
func (o *casaService) GetServerList(index, size, tp, categoryId, key string) ([]model.ServerAppList, int64) {
|
||||
|
||||
head := make(map[string]string)
|
||||
|
||||
t := make(chan string)
|
||||
|
||||
go func() {
|
||||
str := httper2.Get(config.ServerInfo.ServerApi+"/token", nil)
|
||||
|
||||
t <- gjson.Get(str, "data").String()
|
||||
}()
|
||||
head["Authorization"] = <-t
|
||||
head["Authorization"] = GetToken()
|
||||
|
||||
listS := httper2.Get(config.ServerInfo.ServerApi+"/v1/app/list?index="+index+"&size="+size+"&type="+tp+"&category_id="+categoryId+"&key="+key, head)
|
||||
|
||||
@@ -62,18 +50,10 @@ func (o *oasisService) GetServerList(index, size, tp, categoryId, key string) ([
|
||||
return list, count
|
||||
}
|
||||
|
||||
func (o *oasisService) GetServerCategoryList() []model.ServerCategoryList {
|
||||
func (o *casaService) GetServerCategoryList() []model.ServerCategoryList {
|
||||
|
||||
head := make(map[string]string)
|
||||
|
||||
t := make(chan string)
|
||||
|
||||
go func() {
|
||||
str := httper2.Get(config.ServerInfo.ServerApi+"/token", nil)
|
||||
|
||||
t <- gjson.Get(str, "data").String()
|
||||
}()
|
||||
head["Authorization"] = <-t
|
||||
head["Authorization"] = GetToken()
|
||||
|
||||
listS := httper2.Get(config.ServerInfo.ServerApi+"/v1/app/category", head)
|
||||
|
||||
@@ -83,7 +63,42 @@ func (o *oasisService) GetServerCategoryList() []model.ServerCategoryList {
|
||||
|
||||
return list
|
||||
}
|
||||
func (o *casaService) GetServerAppInfo(id string) model.ServerAppList {
|
||||
|
||||
func NewOasisService() OasisService {
|
||||
return &oasisService{}
|
||||
head := make(map[string]string)
|
||||
|
||||
head["Authorization"] = GetToken()
|
||||
|
||||
infoS := httper2.Get(config.ServerInfo.ServerApi+"/v1/app/info/"+id, head)
|
||||
|
||||
info := model.ServerAppList{}
|
||||
json2.Unmarshal([]byte(gjson.Get(infoS, "data").String()), &info)
|
||||
|
||||
return info
|
||||
}
|
||||
func GetToken() string {
|
||||
t := make(chan string)
|
||||
keyName := "casa_token"
|
||||
|
||||
var auth string
|
||||
if result, ok := Cache.Get(keyName); ok {
|
||||
auth, ok = result.(string)
|
||||
if ok {
|
||||
|
||||
return auth
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
str := httper2.Get(config.ServerInfo.ServerApi+"/token", nil)
|
||||
|
||||
t <- gjson.Get(str, "data").String()
|
||||
}()
|
||||
auth = <-t
|
||||
|
||||
Cache.SetDefault(keyName, auth)
|
||||
return auth
|
||||
}
|
||||
|
||||
func NewOasisService() CasaService {
|
||||
return &casaService{}
|
||||
}
|
||||
@@ -3,14 +3,15 @@ package service
|
||||
import (
|
||||
json2 "encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
"github.com/tidwall/gjson"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type DiskService interface {
|
||||
|
||||
@@ -7,27 +7,25 @@ import (
|
||||
"encoding/binary"
|
||||
json2 "encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"syscall"
|
||||
|
||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||
types2 "github.com/IceWhaleTech/CasaOS/types"
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/oci"
|
||||
"syscall"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/docker"
|
||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/env_helper"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||
|
||||
//"github.com/containerd/containerd/oci"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
client2 "github.com/docker/docker/client"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@@ -35,6 +33,14 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
client2 "github.com/docker/docker/client"
|
||||
"github.com/docker/go-connections/nat"
|
||||
)
|
||||
|
||||
type DockerService interface {
|
||||
@@ -55,6 +61,8 @@ type DockerService interface {
|
||||
DockerContainerCommit(name string)
|
||||
DockerNetworkModelList() []types.NetworkResource
|
||||
DockerImageInfo(image string)
|
||||
GetNetWorkNameByNetWorkID(id string) (string, error)
|
||||
ContainerExecShell(container_id string) string
|
||||
}
|
||||
|
||||
type dockerService struct {
|
||||
@@ -62,15 +70,20 @@ type dockerService struct {
|
||||
log loger2.OLog
|
||||
}
|
||||
|
||||
func DockerPs() {
|
||||
func (ds *dockerService) ContainerExecShell(container_id string) string {
|
||||
cli, _ := client2.NewClientWithOpts(client2.FromEnv)
|
||||
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
|
||||
exec, err := cli.ContainerExecCreate(context.Background(), container_id, types.ExecConfig{
|
||||
User: "1000:1000",
|
||||
Cmd: []string{"echo -e \"hellow\nworld\" >> /a.txt"},
|
||||
})
|
||||
if err != nil {
|
||||
os.Exit(5)
|
||||
}
|
||||
for _, container := range containers {
|
||||
fmt.Printf("%s %s\n", container.ID[:10], container.Image)
|
||||
err = cli.ContainerExecStart(context.Background(), exec.ID, types.ExecStartCheck{})
|
||||
if err != nil {
|
||||
fmt.Println("exec script error ", err)
|
||||
}
|
||||
return exec.ID
|
||||
}
|
||||
|
||||
//创建默认网络
|
||||
@@ -79,6 +92,7 @@ func DockerNetwork() {
|
||||
cli, _ := client2.NewClientWithOpts(client2.FromEnv)
|
||||
defer cli.Close()
|
||||
d, _ := cli.NetworkList(context.Background(), types.NetworkListOptions{})
|
||||
|
||||
for _, resource := range d {
|
||||
if resource.Name == docker.NETWORKNAME {
|
||||
return
|
||||
@@ -87,6 +101,19 @@ func DockerNetwork() {
|
||||
cli.NetworkCreate(context.Background(), docker.NETWORKNAME, types.NetworkCreate{})
|
||||
}
|
||||
|
||||
//根据网络id获取网络名
|
||||
func (ds *dockerService) GetNetWorkNameByNetWorkID(id string) (string, error) {
|
||||
cli, _ := client2.NewClientWithOpts(client2.FromEnv)
|
||||
defer cli.Close()
|
||||
filter := filters.NewArgs()
|
||||
filter.Add("id", id)
|
||||
d, err := cli.NetworkList(context.Background(), types.NetworkListOptions{filter})
|
||||
if err == nil && len(d) > 0 {
|
||||
return d[0].Name, nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
//拉取镜像
|
||||
func DockerPull() {
|
||||
|
||||
@@ -306,11 +333,13 @@ func (ds *dockerService) DockerPullImage(imageName string, m model2.AppNotify) e
|
||||
}
|
||||
break
|
||||
}
|
||||
m.Type = types2.NOTIFY_TYPE_INSTALL_LOG
|
||||
m.State = 0
|
||||
m.Speed = 70
|
||||
m.Message = string(buf[:n])
|
||||
MyService.Notify().UpdateLog(m)
|
||||
if !reflect.DeepEqual(m, model2.AppNotify{}) {
|
||||
m.Type = types2.NOTIFY_TYPE_INSTALL_LOG
|
||||
m.State = 0
|
||||
m.Message = string(buf[:n])
|
||||
MyService.Notify().UpdateLog(m)
|
||||
}
|
||||
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -337,9 +366,13 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
|
||||
// if net != "host" {
|
||||
// portMaps[nat.Port(fmt.Sprint(m.Port)+"/tcp")] = []nat.PortBinding{{HostIP: "", HostPort: m.PortMap}}
|
||||
// }
|
||||
|
||||
port := ""
|
||||
for _, portMap := range m.Ports {
|
||||
if portMap.CommendPort == m.PortMap && portMap.Protocol == "tcp" || portMap.Protocol == "both" {
|
||||
port = portMap.ContainerPort
|
||||
}
|
||||
if portMap.Protocol == "tcp" {
|
||||
|
||||
tContainer, _ := strconv.Atoi(portMap.ContainerPort)
|
||||
if tContainer > 0 {
|
||||
ports[nat.Port(portMap.ContainerPort+"/tcp")] = struct{}{}
|
||||
@@ -379,6 +412,10 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
|
||||
|
||||
var envArr []string
|
||||
for _, e := range m.Envs {
|
||||
if strings.HasPrefix(e.Value, "$") {
|
||||
envArr = append(envArr, e.Name+"="+env_helper.ReplaceDefaultENV(e.Value))
|
||||
continue
|
||||
}
|
||||
if len(e.Value) > 0 {
|
||||
if e.Value == "port_map" {
|
||||
envArr = append(envArr, e.Name+"="+m.PortMap)
|
||||
@@ -400,6 +437,7 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
|
||||
res.Devices = append(res.Devices, container.DeviceMapping{PathOnHost: p.Path, PathInContainer: p.ContainerPath})
|
||||
}
|
||||
}
|
||||
hostConfingBind := []string{}
|
||||
// volumes bind
|
||||
volumes := []mount.Mount{}
|
||||
for _, v := range m.Volumes {
|
||||
@@ -409,12 +447,22 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
|
||||
if len(path) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
err = file.IsNotExistMkDir(path)
|
||||
if err != nil {
|
||||
ds.log.Error("mkdir error", err)
|
||||
continue
|
||||
path = strings.ReplaceAll(path, "$AppID", containerDbId)
|
||||
reg1 := regexp.MustCompile(`([^<>/\\\|:""\*\?]+\.\w+$)`)
|
||||
result1 := reg1.FindAllStringSubmatch(path, -1)
|
||||
if len(result1) == 0 {
|
||||
err = file.IsNotExistMkDir(path)
|
||||
if err != nil {
|
||||
ds.log.Error("mkdir error", err)
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
err = file.IsNotExistCreateFile(path)
|
||||
if err != nil {
|
||||
ds.log.Error("mkdir error", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
volumes = append(volumes, mount.Mount{
|
||||
@@ -423,6 +471,7 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
|
||||
Target: v.ContainerPath,
|
||||
})
|
||||
|
||||
hostConfingBind = append(hostConfingBind, v.Path+":"+v.ContainerPath)
|
||||
}
|
||||
|
||||
rp := container.RestartPolicy{}
|
||||
@@ -430,11 +479,24 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
|
||||
if len(m.Restart) > 0 {
|
||||
rp.Name = m.Restart
|
||||
}
|
||||
//fmt.Print(port)
|
||||
healthTest := []string{}
|
||||
if len(port) > 0 {
|
||||
healthTest = []string{"CMD-SHELL", "curl -f http://localhost:" + port + m.Index + " || exit 1"}
|
||||
}
|
||||
|
||||
health := &container.HealthConfig{
|
||||
Test: healthTest,
|
||||
//Test: []string{},
|
||||
StartPeriod: 0,
|
||||
Retries: 1000,
|
||||
}
|
||||
fmt.Print(health)
|
||||
config := &container.Config{
|
||||
Image: imageName,
|
||||
Labels: map[string]string{"origin": m.Origin, m.Origin: m.Origin},
|
||||
Env: envArr,
|
||||
// Healthcheck: health,
|
||||
}
|
||||
hostConfig := &container.HostConfig{Resources: res, Mounts: volumes, RestartPolicy: rp, NetworkMode: container.NetworkMode(net)}
|
||||
//if net != "host" {
|
||||
@@ -771,7 +833,6 @@ func Containerd() {
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("333")
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer container.Delete(ctx, containerd.WithSnapshotCleanup)
|
||||
@@ -779,7 +840,6 @@ func Containerd() {
|
||||
// create a task from the container
|
||||
task, err := container.NewTask(ctx, cio.NewCreator(cio.WithStdio))
|
||||
if err != nil {
|
||||
fmt.Println("444")
|
||||
fmt.Println(err)
|
||||
}
|
||||
defer task.Delete(ctx)
|
||||
@@ -792,7 +852,6 @@ func Containerd() {
|
||||
|
||||
// call start on the task to execute the redis server
|
||||
if err = task.Start(ctx); err != nil {
|
||||
fmt.Println("555")
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
@@ -802,7 +861,6 @@ func Containerd() {
|
||||
|
||||
// kill the process and get the exit status
|
||||
if err = task.Kill(ctx, syscall.SIGTERM); err != nil {
|
||||
fmt.Println("666")
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
@@ -811,7 +869,6 @@ func Containerd() {
|
||||
status := <-exitStatusC
|
||||
code, _, err := status.Result()
|
||||
if err != nil {
|
||||
fmt.Println("777")
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("redis-server exited with status: %d\n", code)
|
||||
|
||||
@@ -3,7 +3,7 @@ package docker_base
|
||||
import "github.com/IceWhaleTech/CasaOS/model"
|
||||
|
||||
//过滤mysql关键字
|
||||
func MysqlFilter(c MysqlConfig, envs model.EnvArrey) model.EnvArrey {
|
||||
func MysqlFilter(c MysqlConfig, envs model.EnvArray) model.EnvArray {
|
||||
for i := 0; i < len(envs); i++ {
|
||||
switch envs[i].Value {
|
||||
case "$MYSQL_HOST":
|
||||
|
||||
@@ -61,4 +61,6 @@ type MyAppList struct {
|
||||
UpTime string `json:"up_time"`
|
||||
Slogan string `json:"slogan"`
|
||||
Rely model.MapStrings `json:"rely"` //[{"mysql":"id"},{"mysql":"id"}]
|
||||
Image string `json:"image"`
|
||||
Volumes string `json:"volumes"`
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package model
|
||||
|
||||
type AppNotify struct {
|
||||
CustomId string `gorm:"column:custom_id;primary_key" json:"custom_id"`
|
||||
ContainerId string `json:"container_id,omitempty"`
|
||||
State int `json:"state"` //0:一直在变动的未读消息 1:未读 2:已读
|
||||
Message string `json:"message"`
|
||||
CreatedAt string `gorm:"<-:create;autoCreateTime" json:"created_at"`
|
||||
UpdatedAt string `gorm:"<-:create;<-:update;autoUpdateTime" json:"updated_at"`
|
||||
Speed int `json:"speed"`
|
||||
Id string `gorm:"-" json:"id"`
|
||||
Type int `json:"type"` // 1:显示即为已读 2:必须手动点掉 3:error
|
||||
State int `json:"state"` //0:一直在变动的未读消息 1:未读 2:已读
|
||||
Message string `json:"message"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
Id string `json:"id"`
|
||||
Type int `json:"type"` // 1:显示即为已读 2:info 3:warning 4:error 5:success
|
||||
Icon string `json:"icon"`
|
||||
Name string `json:"name"`
|
||||
CustomId string `gorm:"column:custom_id;primary_key" json:"custom_id"`
|
||||
}
|
||||
|
||||
func (p *AppNotify) TableName() string {
|
||||
|
||||
57
service/search.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/types"
|
||||
)
|
||||
|
||||
type SearchService interface {
|
||||
SearchList(key string) ([]model.SearchFileInfo, error)
|
||||
}
|
||||
|
||||
type searchService struct {
|
||||
}
|
||||
|
||||
func (s *searchService) SearchList(key string) ([]model.SearchFileInfo, error) {
|
||||
pathName := "/Users/liangjianli/go/CasaOSNew/searchTest"
|
||||
resArr := []model.SearchFileInfo{}
|
||||
files, _ := ioutil.ReadDir(pathName)
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
tempArr, err := s.SearchList(pathName + "/" + file.Name())
|
||||
if err != nil {
|
||||
resArr = append(resArr, tempArr...)
|
||||
}
|
||||
} else {
|
||||
if strings.Contains(file.Name(), key) {
|
||||
resArr = append(resArr, model.SearchFileInfo{Path: pathName, Name: file.Name(), Type: GetSearchType(path.Ext(file.Name()))})
|
||||
}
|
||||
fmt.Println(pathName + "/" + file.Name())
|
||||
}
|
||||
}
|
||||
return resArr, nil
|
||||
}
|
||||
|
||||
func GetSearchType(ext string) int {
|
||||
var reType int = types.UNKNOWN
|
||||
switch ext {
|
||||
case ".png":
|
||||
reType = types.PICTURE
|
||||
case ".mp4":
|
||||
reType = types.MEDIA
|
||||
case ".mp3":
|
||||
reType = types.MUSIC
|
||||
default:
|
||||
reType = types.UNKNOWN
|
||||
}
|
||||
return reType
|
||||
}
|
||||
|
||||
func NewSearchService() SearchService {
|
||||
return &searchService{}
|
||||
}
|
||||
@@ -2,9 +2,12 @@ package service
|
||||
|
||||
import (
|
||||
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||
"github.com/patrickmn/go-cache"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Cache *cache.Cache
|
||||
|
||||
var MyService Repository
|
||||
|
||||
type Repository interface {
|
||||
@@ -15,7 +18,7 @@ type Repository interface {
|
||||
//Redis() RedisService
|
||||
ZeroTier() ZeroTierService
|
||||
ZiMa() ZiMaService
|
||||
OAPI() OasisService
|
||||
OAPI() CasaService
|
||||
Disk() DiskService
|
||||
Notify() NotifyServer
|
||||
ShareDirectory() ShareDirService
|
||||
@@ -23,9 +26,11 @@ type Repository interface {
|
||||
Rely() RelyService
|
||||
System() SystemService
|
||||
Shortcuts() ShortcutsService
|
||||
Search() SearchService
|
||||
}
|
||||
|
||||
func NewService(db *gorm.DB, log loger2.OLog) Repository {
|
||||
|
||||
return &store{
|
||||
app: NewAppService(db, log),
|
||||
ddns: NewDDNSService(db, log),
|
||||
@@ -42,6 +47,7 @@ func NewService(db *gorm.DB, log loger2.OLog) Repository {
|
||||
rely: NewRelyService(db, log),
|
||||
system: NewSystemService(log),
|
||||
shortcuts: NewShortcutsService(db),
|
||||
search: NewSearchService(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +59,7 @@ type store struct {
|
||||
docker DockerService
|
||||
zerotier ZeroTierService
|
||||
zima ZiMaService
|
||||
oapi OasisService
|
||||
oapi CasaService
|
||||
disk DiskService
|
||||
notify NotifyServer
|
||||
shareDirectory ShareDirService
|
||||
@@ -61,6 +67,7 @@ type store struct {
|
||||
rely RelyService
|
||||
system SystemService
|
||||
shortcuts ShortcutsService
|
||||
search SearchService
|
||||
}
|
||||
|
||||
func (c *store) Rely() RelyService {
|
||||
@@ -99,7 +106,7 @@ func (c *store) ZeroTier() ZeroTierService {
|
||||
func (c *store) ZiMa() ZiMaService {
|
||||
return c.zima
|
||||
}
|
||||
func (c *store) OAPI() OasisService {
|
||||
func (c *store) OAPI() CasaService {
|
||||
return c.oapi
|
||||
}
|
||||
|
||||
@@ -112,3 +119,6 @@ func (c *store) ShareDirectory() ShareDirService {
|
||||
func (c *store) Task() TaskService {
|
||||
return c.task
|
||||
}
|
||||
func (c *store) Search() SearchService {
|
||||
return c.search
|
||||
}
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type SystemService interface {
|
||||
UpSystemConfig(systemConfig model.SystemConfig)
|
||||
UpSystemConfig(str string, widget string)
|
||||
UpdateSystemVersion(version string)
|
||||
GetSystemConfigDebug() []string
|
||||
GetCasaOSLogs(lineNumber int) string
|
||||
}
|
||||
type systemService struct {
|
||||
log loger.OLog
|
||||
}
|
||||
|
||||
func (s *systemService) UpdateSystemVersion(version string) {
|
||||
s.log.Error(version)
|
||||
//command2.OnlyExec(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
||||
//s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
||||
s.log.Error(command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/tools.sh ;update " + version))
|
||||
@@ -27,41 +28,31 @@ func (s *systemService) UpdateSystemVersion(version string) {
|
||||
func (s *systemService) GetSystemConfigDebug() []string {
|
||||
return command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetSysInfo")
|
||||
}
|
||||
func (s *systemService) UpSystemConfig(systemConfig model.SystemConfig) {
|
||||
if systemConfig.AutoUpdate != config.SystemConfigInfo.AutoUpdate {
|
||||
config.Cfg.Section("system").Key("AutoUpdate").SetValue(strconv.FormatBool(systemConfig.AutoUpdate))
|
||||
config.SystemConfigInfo.AutoUpdate = systemConfig.AutoUpdate
|
||||
func (s *systemService) UpSystemConfig(str string, widget string) {
|
||||
if len(str) > 0 && str != config.SystemConfigInfo.ConfigStr {
|
||||
config.Cfg.Section("system").Key("ConfigStr").SetValue(str)
|
||||
config.SystemConfigInfo.ConfigStr = str
|
||||
}
|
||||
if systemConfig.SearchSwitch != config.SystemConfigInfo.SearchSwitch {
|
||||
config.Cfg.Section("system").Key("SearchSwitch").SetValue(strconv.FormatBool(systemConfig.SearchSwitch))
|
||||
config.SystemConfigInfo.SearchSwitch = systemConfig.SearchSwitch
|
||||
if len(widget) > 0 && widget != config.SystemConfigInfo.WidgetList {
|
||||
config.Cfg.Section("system").Key("WidgetList").SetValue(widget)
|
||||
config.SystemConfigInfo.WidgetList = widget
|
||||
}
|
||||
if systemConfig.WidgetsSwitch != config.SystemConfigInfo.WidgetsSwitch {
|
||||
config.Cfg.Section("system").Key("WidgetsSwitch").SetValue(strconv.FormatBool(systemConfig.WidgetsSwitch))
|
||||
config.SystemConfigInfo.WidgetsSwitch = systemConfig.WidgetsSwitch
|
||||
}
|
||||
if systemConfig.ShortcutsSwitch != config.SystemConfigInfo.ShortcutsSwitch {
|
||||
config.Cfg.Section("system").Key("ShortcutsSwitch").SetValue(strconv.FormatBool(systemConfig.ShortcutsSwitch))
|
||||
config.SystemConfigInfo.ShortcutsSwitch = systemConfig.ShortcutsSwitch
|
||||
}
|
||||
if len(systemConfig.SearchEngine) > 0 && systemConfig.SearchEngine != config.SystemConfigInfo.SearchEngine {
|
||||
config.Cfg.Section("system").Key("SearchEngine").SetValue(systemConfig.SearchEngine)
|
||||
config.SystemConfigInfo.SearchEngine = systemConfig.SearchEngine
|
||||
}
|
||||
// if len(systemConfig.Version) > 0 && systemConfig.Version != config.SystemConfigInfo.Version {
|
||||
// config.Cfg.Section("system").Key("Version").SetValue(systemConfig.Version)
|
||||
// config.SystemConfigInfo.Version = systemConfig.Version
|
||||
//}
|
||||
if len(systemConfig.Background) > 0 && systemConfig.Background != config.SystemConfigInfo.Background {
|
||||
config.Cfg.Section("system").Key("Background").SetValue(systemConfig.Background)
|
||||
config.SystemConfigInfo.Background = systemConfig.Background
|
||||
}
|
||||
if len(systemConfig.BackgroundType) > 0 && systemConfig.BackgroundType != config.SystemConfigInfo.BackgroundType {
|
||||
config.Cfg.Section("system").Key("BackgroundType").SetValue(systemConfig.BackgroundType)
|
||||
config.SystemConfigInfo.BackgroundType = systemConfig.BackgroundType
|
||||
}
|
||||
config.Cfg.SaveTo("conf/conf.ini")
|
||||
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
||||
}
|
||||
func (s *systemService) GetCasaOSLogs(lineNumber int) string {
|
||||
file, err := os.Open(s.log.Path())
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
defer file.Close()
|
||||
content, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
return string(content)
|
||||
}
|
||||
|
||||
func NewSystemService(log loger.OLog) SystemService {
|
||||
return &systemService{log: log}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"os"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
)
|
||||
|
||||
type UserService interface {
|
||||
@@ -20,6 +21,8 @@ func (c *user) SetUser(username, pwd, token, email, desc string) error {
|
||||
if len(username) > 0 {
|
||||
config.Cfg.Section("user").Key("UserName").SetValue(username)
|
||||
config.UserInfo.UserName = username
|
||||
config.Cfg.Section("user").Key("Initialized").SetValue("true")
|
||||
config.UserInfo.Initialized = true
|
||||
}
|
||||
if len(pwd) > 0 {
|
||||
config.Cfg.Section("user").Key("PWD").SetValue(pwd)
|
||||
@@ -37,7 +40,7 @@ func (c *user) SetUser(username, pwd, token, email, desc string) error {
|
||||
config.Cfg.Section("user").Key("Description").SetValue(desc)
|
||||
config.UserInfo.Description = desc
|
||||
}
|
||||
config.Cfg.SaveTo("conf/conf.ini")
|
||||
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -2,20 +2,22 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/model"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
|
||||
"github.com/shirou/gopsutil/v3/cpu"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
"github.com/shirou/gopsutil/v3/mem"
|
||||
"github.com/shirou/gopsutil/v3/net"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
//系统信息
|
||||
@@ -30,6 +32,7 @@ type ZiMaService interface {
|
||||
GetSysInfo() host.InfoStat
|
||||
GetDirPath(path string) []model.Path
|
||||
MkdirAll(path string) (int, error)
|
||||
CreateFile(path string) (int, error)
|
||||
RenameFile(oldF, newF string) (int, error)
|
||||
GetCpuInfo() []cpu.InfoStat
|
||||
}
|
||||
@@ -81,17 +84,12 @@ func (c *zima) GetDirPath(path string) []model.Path {
|
||||
ls, _ := ioutil.ReadDir(path)
|
||||
dirs := []model.Path{}
|
||||
|
||||
if strings.Count(path, "/") > 1 {
|
||||
|
||||
if strings.Count(path, "/") > 0 {
|
||||
for _, l := range ls {
|
||||
if !strings.HasPrefix(l.Name(), ".") && l.IsDir() {
|
||||
dirs = append(dirs, model.Path{Name: l.Name(), Path: path + l.Name() + "/"})
|
||||
}
|
||||
dirs = append(dirs, model.Path{Name: l.Name(), Path: path + "/" + l.Name(), IsDir: l.IsDir()})
|
||||
}
|
||||
} else {
|
||||
dirs = append(dirs, model.Path{Name: "mnt", Path: "/mnt/"})
|
||||
dirs = append(dirs, model.Path{Name: "media", Path: "/media/"})
|
||||
dirs = append(dirs, model.Path{Name: "home", Path: "/home/"})
|
||||
dirs = append(dirs, model.Path{Name: "DATA", Path: "/DATA/", IsDir: true})
|
||||
}
|
||||
return dirs
|
||||
}
|
||||
@@ -133,6 +131,22 @@ func (c *zima) MkdirAll(path string) (int, error) {
|
||||
if os.IsNotExist(err) {
|
||||
os.MkdirAll(path, os.ModePerm)
|
||||
return oasis_err.SUCCESS, nil
|
||||
} else if strings.Contains(err.Error(), ": not a directory") {
|
||||
return oasis_err.FILE_OR_DIR_EXISTS, err
|
||||
}
|
||||
}
|
||||
return oasis_err.ERROR, err
|
||||
}
|
||||
|
||||
//create
|
||||
func (c *zima) CreateFile(path string) (int, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return oasis_err.FILE_OR_DIR_EXISTS, nil
|
||||
} else {
|
||||
if os.IsNotExist(err) {
|
||||
file.CreateFile(path)
|
||||
return oasis_err.SUCCESS, nil
|
||||
}
|
||||
}
|
||||
return oasis_err.ERROR, err
|
||||
|
||||
10
types/search.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
APPLICATION = iota
|
||||
MEDIA
|
||||
PICTURE
|
||||
MUSIC
|
||||
SEARCH
|
||||
UNKNOWN
|
||||
)
|
||||
@@ -1,3 +1,4 @@
|
||||
package types
|
||||
|
||||
const CURRENTVERSION = "0.1.2"
|
||||
const CURRENTVERSION = "0.1.10"
|
||||
const BODY = "<li>Add App Store for installation</li><li>add casaOS logs</li><li>add application terminal</li><li>add application logs</li>"
|
||||
|
||||
9
web/browserconfig.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square150x150logo src="/ui/img/icon/mstile-150x150.png"/>
|
||||
<TileColor>#da532c</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
</browserconfig>
|
||||
14
web/favicon.svg
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:none;stroke:#363636;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:2;}
|
||||
@media ( prefers-color-scheme: dark ) {
|
||||
.st0{fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:2;}
|
||||
}
|
||||
</style>
|
||||
<path class="st0" d="M12,22c5.5,0,10-4.5,10-10S17.5,2,12,2S2,6.5,2,12S6.5,22,12,22z"/>
|
||||
<path class="st0" d="M12,22c3.9,0,7-3.1,7-7s-3.1-7-7-7s-7,3.1-7,7S8.1,22,12,22z"/>
|
||||
<path class="st0" d="M12,22c2.2,0,4-1.8,4-4s-1.8-4-4-4s-4,1.8-4,4S9.8,22,12,22z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 863 B |
BIN
web/img/bg.afedbc0b.jpeg
Normal file
|
After Width: | Height: | Size: 301 KiB |
11
web/img/casa.2579f069.svg
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 24 24" style="enable-background:new 0 0 24 24;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:none;stroke:#FFFFFF;stroke-width:2;stroke-linejoin:round;stroke-miterlimit:2;}
|
||||
</style>
|
||||
<path class="st0" d="M12,22c5.5,0,10-4.5,10-10S17.5,2,12,2S2,6.5,2,12S6.5,22,12,22z"/>
|
||||
<path class="st0" d="M12,22c3.9,0,7-3.1,7-7s-3.1-7-7-7s-7,3.1-7,7S8.1,22,12,22z"/>
|
||||
<path class="st0" d="M12,22c2.2,0,4-1.8,4-4s-1.8-4-4-4s-4,1.8-4,4S9.8,22,12,22z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 729 B |
BIN
web/img/default.be7833db.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
web/img/disk.573d4b55.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
web/img/folder.c8ff81f3.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
web/img/icon/android-chrome-192x192.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
web/img/icon/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
web/img/icon/favicon-16x16.png
Normal file
|
After Width: | Height: | Size: 693 B |
BIN
web/img/icon/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
web/img/icon/mstile-150x150.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
25
web/img/icon/safari-pinned-tab.svg
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="200.000000pt" height="200.000000pt" viewBox="0 0 200.000000 200.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<metadata>
|
||||
Created by potrace 1.14, written by Peter Selinger 2001-2017
|
||||
</metadata>
|
||||
<g transform="translate(0.000000,200.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path d="M875 1894 c-11 -2 -51 -11 -88 -20 -341 -78 -610 -364 -673 -714 -82
|
||||
-459 197 -902 647 -1030 94 -27 277 -37 378 -21 303 47 575 261 690 540 55
|
||||
133 66 192 65 361 -1 136 -4 165 -27 235 -36 116 -62 170 -123 261 -123 186
|
||||
-347 336 -566 379 -42 8 -276 15 -303 9z m250 -168 c11 -2 42 -9 70 -16 131
|
||||
-30 288 -135 387 -260 160 -201 198 -506 93 -745 l-22 -50 2 80 c3 180 -64
|
||||
351 -184 476 -209 216 -544 260 -807 105 -201 -117 -326 -347 -319 -587 l2
|
||||
-74 -19 44 c-63 140 -80 332 -44 476 24 94 87 219 147 292 109 133 290 238
|
||||
448 259 25 3 47 7 49 9 5 4 173 -3 197 -9z m8 -501 c33 -8 85 -31 116 -50 227
|
||||
-137 305 -418 183 -651 l-21 -39 -1 35 c-9 251 -245 439 -490 389 -186 -38
|
||||
-323 -200 -330 -389 l-1 -35 -23 45 c-101 194 -61 429 99 578 130 122 292 162
|
||||
468 117z m-27 -499 c182 -85 183 -345 1 -438 -53 -27 -161 -26 -215 1 -146 75
|
||||
-180 267 -69 390 63 69 190 90 283 47z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
15
web/img/user.89095c02.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_420:1626)">
|
||||
<path d="M105.303 90.2303C101.758 84.7641 96.8971 80.2755 91.1663 77.1761C85.4355 74.0767 79.0183 72.4657 72.5032 72.4909H47.5032C40.9874 72.4663 34.5698 74.0782 28.839 77.1787C23.1082 80.2792 18.2477 84.769 14.7032 90.2363C13.5758 91.9796 12.5966 93.8143 11.7759 95.7212C13.5427 98.0944 15.4812 100.335 17.5759 102.424C28.8279 113.675 44.0882 119.996 60.0001 119.996C75.9121 119.996 91.1724 113.675 102.424 102.424C104.515 100.333 106.452 98.0929 108.218 95.7212C107.398 93.8145 106.423 91.978 105.303 90.2303Z" fill="#585858"/>
|
||||
<path d="M102.424 17.5757C94.0333 9.18545 83.3428 3.4717 71.7045 1.15695C60.0662 -1.15781 48.0028 0.0303833 37.0398 4.57128C26.0768 9.11219 16.7064 16.8019 10.1134 26.668C3.5205 36.5342 0.0010934 48.1337 0.000237319 60C-0.0360734 72.8664 4.09527 85.3987 11.776 95.7212C13.5428 98.0944 15.4813 100.335 17.576 102.424C28.828 113.675 44.0883 119.996 60.0002 119.996C75.9122 119.996 91.1725 113.675 102.424 102.424C104.516 100.333 106.452 98.0929 108.218 95.7212C116.773 84.1613 120.894 69.9144 119.83 55.5727C118.767 41.231 112.591 27.7476 102.424 17.5757ZM105.297 90.2303C103.301 93.1993 101.022 95.9678 98.4911 98.4969C88.2822 108.7 74.4396 114.431 60.0063 114.431C45.573 114.431 31.7304 108.7 21.5215 98.4969C18.9927 95.97 16.7154 93.2035 14.7214 90.2363C7.24501 78.996 4.21031 65.3792 6.20611 52.0277C8.20191 38.6763 15.0859 26.5422 25.5226 17.9795C35.9592 9.41683 49.2044 5.03605 62.6885 5.68711C76.1725 6.33817 88.9341 11.9746 98.4972 21.503C107.396 30.4094 112.936 42.1221 114.177 54.6509C115.418 67.1796 112.282 79.7515 105.303 90.2303H105.297Z" fill="#585858"/>
|
||||
<path d="M39.0305 44.8545C39.0305 47.6083 39.5729 50.3351 40.6267 52.8793C41.6806 55.4234 43.2252 57.7351 45.1724 59.6823C47.1196 61.6296 49.4313 63.1742 51.9755 64.228C54.5196 65.2818 57.2464 65.8242 60.0002 65.8242C62.754 65.8242 65.4808 65.2818 68.025 64.228C70.5691 63.1742 72.8808 61.6296 74.828 59.6823C76.7752 57.7351 78.3199 55.4234 79.3737 52.8793C80.4275 50.3351 80.9699 47.6083 80.9699 44.8545C80.9699 42.1007 80.4275 39.3739 79.3737 36.8298C78.3199 34.2856 76.7752 31.9739 74.828 30.0267C72.8808 28.0795 70.5691 26.5349 68.025 25.4811C65.4808 24.4272 62.754 23.8848 60.0002 23.8848C57.2464 23.8848 54.5196 24.4272 51.9755 25.4811C49.4313 26.5349 47.1196 28.0795 45.1724 30.0267C43.2252 31.9739 41.6806 34.2856 40.6267 36.8298C39.5729 39.3739 39.0305 42.1007 39.0305 44.8545Z" fill="#585858"/>
|
||||
<circle cx="60" cy="60" r="60" fill="#2276F3"/>
|
||||
<circle cx="59.9998" cy="45.0001" r="20" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.2061 99.9198C21.2482 82.8587 39.0184 70.5001 59.9998 70.5001C80.9812 70.5001 98.7515 82.8589 104.794 99.9201C93.805 112.242 77.8085 120 60 120C42.1912 120 26.1946 112.241 15.2061 99.9198Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_420:1626">
|
||||
<rect width="120" height="120" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
BIN
web/img/xfile.402f9e59.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
33
web/index.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<script>
|
||||
if (document.URL.indexOf("ui") === -1) {
|
||||
window.location.replace("ui")
|
||||
}
|
||||
</script>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/ui/img/icon/apple-touch-icon.png">
|
||||
<link rel="manifest" href="/ui/site.webmanifest">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
<link rel="icon" href="/ui/favicon.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/@mdi/font@6.2.95/css/materialdesignicons.min.css">
|
||||
<title>
|
||||
CasaOS
|
||||
</title>
|
||||
<link href="/ui/js/0.js" rel="prefetch"><link href="/ui/js/1.js" rel="prefetch"><link href="/ui/js/2.js" rel="prefetch"><link href="/ui/js/3.js" rel="prefetch"><link href="/ui/js/4.js" rel="prefetch"><link href="/ui/js/app.js" rel="preload" as="script"><link href="/ui/js/chunk-vendors.js" rel="preload" as="script"></head>
|
||||
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but CasaOS doesn't work properly without JavaScript enabled.
|
||||
Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
<script type="text/javascript" src="/ui/js/chunk-vendors.js"></script><script type="text/javascript" src="/ui/js/app.js"></script></body>
|
||||
|
||||
</html>
|
||||
221
web/js/0.js
Normal file
26
web/js/1.js
Normal file
4296
web/js/2.js
Normal file
108
web/js/3.js
Normal file
63
web/js/4.js
Normal file
627
web/js/app.js
Normal file
2859
web/js/chunk-vendors.js
Normal file
14
web/site.webmanifest
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "",
|
||||
"short_name": "",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/ui/img/icon/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"theme_color": "#ffffff",
|
||||
"background_color": "#ffffff",
|
||||
"display": "standalone"
|
||||
}
|
||||
@@ -2,5 +2,5 @@ package web
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed index.html favicon.ico img js browserconfig.xml site.webmanifest
|
||||
//go:embed index.html favicon.svg img js browserconfig.xml site.webmanifest
|
||||
var Static embed.FS
|
||||
|
||||