Compare commits

...

85 Commits

Author SHA1 Message Date
link
cc46a96a75 Merge pull request #27 from IceWhaleTech/v0.2.1
fixed path error
2021-11-25 05:44:33 -06:00
link
049090444e fixed path error 2021-11-25 19:41:25 +08:00
link
796c25b7a5 Merge pull request #26 from IceWhaleTech/v0.2.1
add sync function
2021-11-25 03:35:47 -06:00
link
9057290188 add sync function 2021-11-25 17:35:01 +08:00
John Guan
fcc57bb734 Update README.md 2021-11-24 18:35:14 +08:00
link
a98f5e087c Merge pull request #24 from IceWhaleTech/add-license-1
Create LICENSE
2021-11-19 03:34:09 -06:00
link
403d563869 Create LICENSE 2021-11-19 17:33:57 +08:00
John Guan
88c15104b4 update README.md 2021-11-12 17:52:16 +08:00
link
6176289b88 Merge pull request #23 from IceWhaleTech/v0.2.1
update volumes
2021-11-10 03:51:14 -06:00
link
5cfd44da79 update volumes 2021-11-10 17:50:46 +08:00
link
2437da33a6 Merge pull request #21 from IceWhaleTech/v0.2.1
Update system.go
2021-11-09 05:11:58 -06:00
link
49ca0af746 Update system.go 2021-11-09 19:10:18 +08:00
link
9440b89fab Merge pull request #20 from IceWhaleTech/v0.2.1
Fixing bugs
2021-11-09 04:58:59 -06:00
link
f020c1162d Fixing bugs
Resolve application installation path errors
2021-11-09 18:57:50 +08:00
link
120fb2cea2 Merge pull request #19 from IceWhaleTech/v0.2.1
update ui
2021-11-04 03:04:37 -05:00
link
37130966cf update ui 2021-11-04 16:03:33 +08:00
link
795b82c42c Update issue templates 2021-11-04 15:26:36 +08:00
link
57ad33d53a Merge pull request #17 from IceWhaleTech/v0.2.1
update ui
2021-11-03 06:06:21 -05:00
link
a6ceee7bc0 update ui 2021-11-03 19:05:41 +08:00
link
44bb05fad0 Merge pull request #16 from IceWhaleTech/v0.2.1
New App Store
2021-11-03 04:08:45 -05:00
link
a5fee0ee97 New App Store
Add App Store for installation
Fix favicon display in dark mode
2021-11-03 17:07:46 +08:00
John Guan
da99b2d01a Update README.md 2021-11-03 10:51:32 +08:00
link
1433e3297b Merge pull request #15 from IceWhaleTech/v0.2.1
Update UI
2021-10-29 06:36:37 -05:00
link
cad7af13af Update UI 2021-10-29 19:35:51 +08:00
link
39cb8904a3 Merge pull request #14 from IceWhaleTech/v0.2.1
V0.2.1
2021-10-29 05:39:54 -05:00
link
2ed372b3cd Update system.go 2021-10-29 18:39:07 +08:00
link
8bca76b78b Add new features
add casaOS logs
add application  terminal
add application  logs
2021-10-29 18:37:27 +08:00
link
595e0f28af Merge pull request #13 from IceWhaleTech/v0.2.1
update disk display
2021-10-27 06:04:34 -05:00
link
4939fe10aa update disk display
add casaos logs api
update ui
2021-10-27 19:03:59 +08:00
link
d2962a8e70 Merge pull request #12 from IceWhaleTech/v0.2.1
Add some features
2021-10-27 04:29:44 -05:00
link
d7d53d639b Add some features
Add terminal
Improve single user management function
2021-10-27 17:27:46 +08:00
link
d2ff1b0506 Merge pull request #10 from IceWhaleTech/v0.2.1
update UI
2021-10-22 05:28:34 -05:00
link
7191735737 update UI 2021-10-22 18:28:00 +08:00
link
21f3fd85d9 Merge pull request #9 from IceWhaleTech/v0.2.1
update initialization config
2021-10-22 04:59:00 -05:00
link
ba77e07e36 update initialization config
initialization user config
2021-10-22 17:57:22 +08:00
link
0d6e7ca339 Merge pull request #8 from IceWhaleTech/v0.2.1
update route.go
2021-10-22 04:19:53 -05:00
link
b1d5d9858b update route.go 2021-10-22 17:19:07 +08:00
link
4f06be0e45 Merge pull request #7 from IceWhaleTech/v0.2.1
update webui
2021-10-22 04:10:24 -05:00
link
812ffd56a8 update webui 2021-10-22 17:09:43 +08:00
老竭力
6ba845eec5 Update issue templates 2021-10-22 16:58:29 +08:00
link
4fa72289ed Merge pull request #6 from IceWhaleTech/v0.2.1
remove build file
2021-10-22 03:55:06 -05:00
link
5cdd842a3e remove build file
remove main
remove CasaOS
2021-10-22 16:54:17 +08:00
link
cc5504c0a9 Merge pull request #5 from IceWhaleTech/v0.2.1
Add authentication
2021-10-22 03:52:39 -05:00
link
b3aa22605d Add authentication
Add user authentication module, Login page and initialization page.
Fixed the problem that the application could not start after the system restarted.
2021-10-22 16:49:09 +08:00
John Guan
32e00b17b1 update README.md 2021-10-20 11:23:25 +08:00
John Guan
16108f03ac Merge branch 'main' of https://github.com/IceWhaleTech/CasaOS 2021-10-20 11:10:53 +08:00
John Guan
e7f990b224 Update README.md 2021-10-20 11:10:51 +08:00
link
c5d824c4ba Merge pull request #3 from IceWhaleTech/v0.2.1
Optimize installation process
2021-10-19 06:12:40 -05:00
link
39ccbe251f Optimize installation process
auto create file or dir
2021-10-19 19:07:16 +08:00
link
e69d2e587b Merge pull request #2 from IceWhaleTech/v0.2.1
update create file and dir api
2021-10-18 05:25:26 -05:00
link
8a28d3c589 update create file and dir api 2021-10-18 18:24:18 +08:00
link
8fe0e4aa73 Update casa.yml 2021-10-15 19:48:38 +08:00
link
30a23a93a2 Update casa.yml 2021-10-15 19:38:50 +08:00
link
53157fbb1f Merge pull request #1 from IceWhaleTech/v0.2.1
add widget
2021-10-14 22:45:31 -05:00
link
fb15695dab add widget
Add CPU RAM Status
Add Disk Info
2021-10-15 11:43:41 +08:00
老竭力
5f5091f1e2 🦄 refactor: Change build method
Change build method
add static.go to public folder
2021-09-30 18:52:03 +08:00
a624669980
df92766c74 Catalog Adjustment 2021-09-30 18:45:01 +08:00
a624669980
cc8b3e8f06 Modify gitgnore 2021-09-30 18:42:29 +08:00
John Guan
a116db8dbd Update .gitignore 2021-09-30 18:40:16 +08:00
a624669980
d697547cb7 Modify default config 2021-09-30 17:55:59 +08:00
a624669980
01960c0391 Modify default config 2021-09-30 17:54:29 +08:00
a624669980
953c393e71 Modify default config 2021-09-30 17:53:26 +08:00
a624669980
0873f7dd46 Modify the publishing process 2021-09-30 17:00:55 +08:00
a624669980
8d93a7f320 Modify the publishing process 2021-09-30 16:57:10 +08:00
a624669980
801eca0a14 Modify the publishing process 2021-09-30 16:56:03 +08:00
a624669980
a3ec7b70c9 Modify the publishing process 2021-09-30 16:55:00 +08:00
a624669980
4a77548b23 Modify the publishing process 2021-09-30 16:51:20 +08:00
a624669980
15ccade3d3 Modify the publishing process 2021-09-30 16:42:00 +08:00
a624669980
587fb6fb8a Modify the publishing process 2021-09-30 16:29:32 +08:00
a624669980
5bcb663ac8 Modify the publishing process 2021-09-30 16:26:36 +08:00
a624669980
cbd945536d Modify the publishing process 2021-09-30 16:14:09 +08:00
a624669980
081e9213c2 Modify the publishing process 2021-09-30 16:13:14 +08:00
a624669980
966fae2d4c Modify the publishing process 2021-09-30 16:12:45 +08:00
a624669980
dc4f9ea990 Modify the publishing process 2021-09-30 16:06:56 +08:00
a624669980
05b9c75714 Modify the publishing process 2021-09-30 15:55:02 +08:00
a624669980
4aeeea2325 Modify the publishing process 2021-09-30 15:52:56 +08:00
a624669980
72531cf6c2 Modify the publishing process 2021-09-30 15:45:09 +08:00
a624669980
9ad9be8c61 Modify the publishing process 2021-09-30 15:34:02 +08:00
a624669980
1aa15932a0 Modify the publishing process 2021-09-30 15:24:18 +08:00
a624669980
dbc6a4265a Modify the publishing process 2021-09-30 15:22:05 +08:00
a624669980
edea1f144a Modify the publishing process 2021-09-30 15:10:41 +08:00
a624669980
85c59c03cf Modify the publishing process 2021-09-30 14:52:32 +08:00
a624669980
a1f57bf1d1 Modify the publishing version 2021-09-30 14:45:33 +08:00
a624669980
e6f2c46c28 Modify the publishing process 2021-09-30 14:43:45 +08:00
a624669980
55c6c21aa3 Ignore profile 2021-09-29 19:51:40 +08:00
121 changed files with 11442 additions and 8014 deletions

32
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View File

@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -0,0 +1,15 @@
---
name: Submit application
about: Add an app to this project
title: ''
labels: ''
assignees: LinkLeong
---
Tested platform
e.g. linux/amd64,linux/arm-v7,linux-arm64
Please export and upload the configuration file of this application

View File

@@ -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
View File

@@ -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

201
LICENSE Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -1,4 +1,4 @@
# CasaOS - A simple, easy-to-use, elegant open-source home server system.
# CasaOS - A simple, easy-to-use, elegant open-source Home Cloud system.
![CasaOS](https://raw.githubusercontent.com/IceWhaleTech/logo/main/casaos/casaos_banner_aldeyjarfoss.png)
@@ -8,16 +8,47 @@
[![GitHub Stars](https://img.shields.io/github/stars/IceWhaleTech/CasaOS?color=162453&logo=github&style=flat-square)](https://github.com/IceWhaleTech/CasaOS/stargazers)
[![Discord](https://img.shields.io/discord/884667213326463016?color=162453&label=Chat&logo=discord&logoColor=fff&style=flat-square)](https://discord.gg/Gx4BCEtHjx)
CasaOS is an open-source home server system based on the Docker ecosystem and designed for home scenarios. It is committed to building the world's most simple, easy-to-use, and elegant home server system.
CasaOS is an open-source Home Cloud system based on the Docker ecosystem and designed for home scenarios. It is committed to building the world's most simple, easy-to-use, and elegant Home Cloud system.
IceWhale team believes that through community-driven collaborative innovation and open communication with global developers, we can reshape the digital home experience like never before.
![CasaOS Snapshot](snapshot.png)
![CasaOS Snapshot Mobile](snapshot-mobile.png)
## Getting Started
> ⚠️ Note:
>
> CasaOS is still in the early development stage and may vary significantly with the final release. Feel free to test run and share your feedback in the [Discord server](https://discord.gg/Gx4BCEtHjx)!
### Quick Setup CasaOS
Fresh install a system from the list below and run the this command:
```sh
wget -qO- https://get.icewhale.io/casaos.sh | bash
```
or
```sh
curl -fsSL https://get.icewhale.io/casaos.sh | bash
```
### System Compatibility
- Ubuntu Server 20.04 amd64 (✅ Recommend, Tested)
- Raspberry Pi Lite OS aarch64/arm64 (⚠️ Not Fully Tested Yet)
- Debian 11 amd64 (⚠️ Not Fully Tested Yet)
- OpenWrt 21.02 amd64 (⚠️ Not Fully Tested Yet)
- OpenWrt 21.02 aarch64/arm64 (⚠️ Not Fully Tested Yet)
## Key Features
- UI designed for home scenarios - simple, elegant, and easy-to-use
- Quick Docker app installation with only three steps, plus automatic management
- App Store for private cloud 🚧
- App Store for Home Cloud 🚧
- Home data/digital asset management 🚧
- Smart home manager 🚧
@@ -39,43 +70,6 @@ So, we set out to build this open source project to develop CasaOS with our own
[![Discord Card](https://discordapp.com/api/guilds/884667213326463016/widget.png?style=banner2)](https://discord.gg/Gx4BCEtHjx)
## Getting Started
> ⚠️ Note:
>
> CasaOS is still in the early development stage and may vary significantly with the final release. Feel free to test run and share your feedback in the [Discord server](https://discord.gg/Gx4BCEtHjx)!
### System Compatibility
- Ubuntu Server 20.04 amd64 (✅ Recommend, Tested)
- Debian 11 amd64 (⚠️ Not Fully Tested Yet)
- OpenWrt 21.02 amd64 (⚠️ Not Fully Tested Yet)
- Raspberry Pi OS aarch64/arm64 (🚧 Under Planning)
- OpenWrt 21.02 aarch64/arm64 (🚧 Under Planning)
### Quick Setup CasaOS
Fresh install a system from the above list and run the below command:
```sh
curl -fsSL https://get.icewhale.io/casaos.sh | bash
```
## To Do
**v 0.1.x**
- [x] An elegant UI for home scenarios
- [x] Custom installation of Docker Apps
- [x] Update, stop, uninstall, restart, etc. of Docker apps
- [x] Docker CLI parser
- [x] System Update
- [ ] Getting Started tutorial
- [ ] Docker Compose parser
- [ ] App config file import and export
- [ ] macvlan network mode
## Maintainers
- Jerry Liu

2
UI

Submodule UI updated: 1f2ebd05fa...a74be104eb

View File

@@ -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 =

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

20
go.mod
View File

@@ -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
View File

@@ -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
View File

@@ -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秒执行一次

View File

@@ -15,12 +15,14 @@ type ServerAppList struct {
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"`
PortMap string `json:"port_map"`
ImageVersion string `json:"image_version"`
Tip string `json:"tip"`
Configures configures `gorm:"type:json" json:"configures"`
NetworkModel string `json:"network_mode"`
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"`
@@ -33,6 +35,7 @@ type ServerAppList struct {
Thumbnail string `json:"thumbnail"`
Healthy string `json:"healthy"`
Plugins Strings `json:"plugins"`
Origin string `json:"origin"`
}
type Ports struct {

View File

@@ -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
View File

@@ -0,0 +1,7 @@
package model
type SearchFileInfo struct {
Path string `json:"path"`
Name string `json:"name"`
Type int `json:"type"`
}

View File

@@ -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
View File

@@ -0,0 +1,8 @@
package system_app
import "encoding/xml"
type SyncConfig struct {
XMLName xml.Name `xml:"configuration"`
Key string `xml:"gui>apikey"`
}

View File

@@ -3,4 +3,5 @@ package model
type Path struct {
Name string `json:"name"`
Path string `json:"path"`
IsDir bool `json:"is_dir"`
}

11
pkg/cache/cache.go vendored Normal file
View 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)
}

View File

@@ -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
View 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()
}

View File

@@ -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")

View File

@@ -1,10 +1,31 @@
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), "media"):
path = "/DATA/Media/"
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"
}

View File

@@ -0,0 +1,10 @@
package docker
import (
"fmt"
"testing"
)
func TestGetDir(t *testing.T) {
fmt.Println(GetDir("", "config"))
}

View File

@@ -1,7 +0,0 @@
package github
import "testing"
func TestGetRepos(t *testing.T) {
GetRepos()
}

View File

@@ -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 {

View File

@@ -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) {

View 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"))
}

View File

@@ -50,6 +50,7 @@ func MkDir(src string) error {
if err != nil {
return err
}
os.Chmod(src, 0777)
return nil
}
@@ -100,7 +101,6 @@ func MustOpen(fileName, filePath string) (*os.File, error) {
return f, nil
}
// 判断所给路径文件/文件夹是否存在
func Exists(path string) bool {
_, err := os.Stat(path) //os.Stat获取文件信息
@@ -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
View 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--
}
}

View File

@@ -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请求
@@ -52,10 +53,13 @@ func Get(url string, head map[string]string) (response string) {
//发送POST请求
//url:请求地址data:POST请求提交的数据,contentType:请求体格式application/json
//content:请求放回的内容
func Post(url string, data interface{}, contentType string) (content string) {
jsonStr, _ := json.Marshal(data)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
func Post(url string, data []byte, contentType string, head map[string]string) (content string) {
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
req.Header.Add("content-type", contentType)
for k, v := range head {
req.Header.Add(k, v)
}
if err != nil {
panic(err)
}

View File

@@ -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,

View File

@@ -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 {

View File

@@ -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)

View File

@@ -8,9 +8,13 @@ const (
//user
PWD_INVALID = 10001
PWD_IS_EMPTY = 10002
PWD_INVALID_OLD = 10003
//system
DIR_ALREADY_EXISTS = 20001
FILE_ALREADY_EXISTS = 20002
FILE_OR_DIR_EXISTS = 20003
//zerotier
GET_TOKEN_ERROR = 30001
@@ -36,10 +40,13 @@ var MsgFlags = map[int]string{
//user
PWD_INVALID: "Password invalid",
PWD_IS_EMPTY: "Password is empty",
PWD_INVALID_OLD: "Old Password invalid",
//system
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",

View File

@@ -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()

View File

@@ -1,8 +1,9 @@
package sort
import (
"github.com/IceWhaleTech/CasaOS/model"
"sort"
"github.com/IceWhaleTech/CasaOS/model"
)
// 数据集类型, 与上一篇排序文章(多字段单独排序)比较, less字段的数据类型不再是 func(p1, p2 *Change) bool

View File

@@ -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
}

View File

@@ -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
View 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
}
//stepstart 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")
}
}

View File

@@ -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")
@@ -170,7 +175,7 @@ func InitRouter(swagHandler gin.HandlerFunc) *gin.Engine {
v1AppGroup.GET("/rely/:id/info", v1.ContainerRelyInfo)
v1AppGroup.GET("/install/config", v1.GetDockerInstallConfig)
//v1AppGroup.POST("/custom/install", v1.CustomInstallApp)
v1AppGroup.POST("/share", v1.ShareAppFile)
}
v1SysGroup := v1Group.Group("/sys")
@@ -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,14 @@ 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/config", v1.GetSyncConfig)
v1Group.Any("/syncthing/*url", v1.SyncToSyncthing)
}
return r
}

View File

@@ -1,15 +1,19 @@
package v1
import (
"encoding/json"
"io/ioutil"
"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 +114,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")
}
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 {
info.PortMap = info.TcpPort
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
}
}
portOrder := func(c1, c2 *model.Ports) bool {
return c1.Type < c2.Type
if info.Ports[i].Type == 0 {
info.PortMap = info.Ports[i].CommendPort
}
}
}
envOrder := func(c1, c2 *model.Envs) 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)
}
volOrder := func(c1, c2 *model.Volume) 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
// }
devOrder := func(c1, c2 *model.Devices) bool {
return c1.Type < c2.Type
}
// envOrder := func(c1, c2 *model.Envs) 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
@@ -180,3 +199,16 @@ func CategoryList(c *gin.Context) {
list = append(list, rear...)
c.JSON(http.StatusOK, &model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: list})
}
// @Summary 分享该应用配置
// @Produce application/json
// @Accept application/json
// @Tags app
// @Security ApiKeyAuth
// @Success 200 {string} string "ok"
// @Router /app/share [post]
func ShareAppFile(c *gin.Context) {
str, _ := ioutil.ReadAll(c.Request.Body)
content := service.MyService.OAPI().ShareAppFile(str)
c.JSON(http.StatusOK, json.RawMessage(content))
}

View File

@@ -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,12 @@ 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() {
if strings.Contains(v.String(), appId) {
service.MyService.App().DelAppConfigDir(v.String())
}
}
//step: 删除install log
service.MyService.Notify().DelLog(appId)
@@ -763,7 +798,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 +907,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 +1019,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 +1127,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)

View File

@@ -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
View 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})
}

35
route/v1/sync.go Normal file
View File

@@ -0,0 +1,35 @@
package v1
import (
"net/http"
"net/http/httputil"
"net/url"
"strings"
"github.com/IceWhaleTech/CasaOS/model"
"github.com/IceWhaleTech/CasaOS/pkg/config"
"github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
"github.com/gin-gonic/gin"
)
func SyncToSyncthing(c *gin.Context) {
u := c.Param("url")
target := "http://" + strings.Split(c.Request.Host, ":")[0] + ":" + 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.Header.Add("X-API-Key", config.SystemConfigInfo.SyncKey)
c.Request.URL.Path = u
proxy.ServeHTTP(c.Writer, c.Request)
}
func GetSyncConfig(c *gin.Context) {
data := make(map[string]string)
data["key"] = config.SystemConfigInfo.SyncKey
data["port"] = config.SystemConfigInfo.SyncPort
c.JSON(http.StatusOK, model.Result{Success: oasis_err.SUCCESS, Message: oasis_err.GetMsg(oasis_err.SUCCESS), Data: data})
}

View File

@@ -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,
})
}

View File

@@ -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
}

View File

@@ -2,35 +2,31 @@ 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(path string)
GetSystemAppList() *[]model2.MyAppList
}
type appStruct struct {
@@ -56,7 +52,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 +65,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 +150,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 +214,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 +223,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(path string) {
command.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;DelAppConfigDir " + 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}
}

View File

@@ -2,34 +2,39 @@ 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
ShareAppFile(body []byte) string
}
type oasisService struct {
type casaService struct {
}
func (o *oasisService) GetTaskList(size int) []model2.TaskDBModel {
func (o *casaService) ShareAppFile(body []byte) string {
head := make(map[string]string)
t := make(chan string)
head["Authorization"] = GetToken()
go func() {
str := httper2.Get(config.ServerInfo.ServerApi+"/token", nil)
content := httper2.Post(config.ServerInfo.ServerApi+"/v1/community/add", body, "application/json", head)
return content
}
t <- gjson.Get(str, "data").String()
}()
head["Authorization"] = <-t
func (o *casaService) GetTaskList(size int) []model2.TaskDBModel {
head := make(map[string]string)
head["Authorization"] = GetToken()
listS := httper2.Get(config.ServerInfo.ServerApi+"/v1/task/list/"+strconv.Itoa(size), head)
@@ -39,18 +44,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 +60,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 +73,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{}
}

View File

@@ -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 {

View File

@@ -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,12 +333,14 @@ func (ds *dockerService) DockerPullImage(imageName string, m model2.AppNotify) e
}
break
}
if !reflect.DeepEqual(m, model2.AppNotify{}) {
m.Type = types2.NOTIFY_TYPE_INSTALL_LOG
m.State = 0
m.Speed = 70
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,13 +447,23 @@ func (ds *dockerService) DockerContainerCreate(imageName string, containerDbId s
if len(path) == 0 {
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{
Type: mount.TypeBind,
@@ -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)

View File

@@ -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":

View File

@@ -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"`
}

View File

@@ -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
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
View 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{}
}

View File

@@ -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
}

View File

@@ -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
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
}
if systemConfig.ShortcutsSwitch != config.SystemConfigInfo.ShortcutsSwitch {
config.Cfg.Section("system").Key("ShortcutsSwitch").SetValue(strconv.FormatBool(systemConfig.ShortcutsSwitch))
config.SystemConfigInfo.ShortcutsSwitch = systemConfig.ShortcutsSwitch
func (s *systemService) GetCasaOSLogs(lineNumber int) string {
file, err := os.Open(s.log.Path())
if err != nil {
return err.Error()
}
if len(systemConfig.SearchEngine) > 0 && systemConfig.SearchEngine != config.SystemConfigInfo.SearchEngine {
config.Cfg.Section("system").Key("SearchEngine").SetValue(systemConfig.SearchEngine)
config.SystemConfigInfo.SearchEngine = systemConfig.SearchEngine
defer file.Close()
content, err := ioutil.ReadAll(file)
if err != nil {
return err.Error()
}
// 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")
return string(content)
}
func NewSystemService(log loger.OLog) SystemService {
return &systemService{log: log}
}

View File

@@ -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
}

View File

@@ -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

BIN
snapshot-mobile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

BIN
snapshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

10
types/search.go Normal file
View File

@@ -0,0 +1,10 @@
package types
const (
APPLICATION = iota
MEDIA
PICTURE
MUSIC
SEARCH
UNKNOWN
)

View File

@@ -1,3 +1,4 @@
package types
const CURRENTVERSION = "0.1.2"
const CURRENTVERSION = "0.2.1"
const BODY = "<li>fixed path error</li>"

9
web/browserconfig.xml Normal file
View 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
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -0,0 +1,72 @@
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 60C0 26.8629 26.8629 0 60 0V0C93.1371 0 120 26.8629 120 60V60C120 93.1371 93.1371 120 60 120V120C26.8629 120 0 93.1371 0 60V60Z" fill="url(#paint0_linear_582:2091)"/>
<g filter="url(#filter0_d_582:2091)">
<g filter="url(#filter1_iiiii_582:2091)">
<path d="M75.1248 42.125C75.1248 50.4783 68.3532 57.25 59.9999 57.25C51.6465 57.25 44.8749 50.4783 44.8749 42.125C44.8749 33.7717 51.6465 27 59.9999 27C68.3532 27 75.1248 33.7717 75.1248 42.125Z" fill="url(#paint1_linear_582:2091)"/>
<path d="M34.422 71.7327C41.316 66.1301 50.2453 62.75 59.9998 62.75C69.7544 62.75 78.6837 66.1301 85.5777 71.7327C89.5123 74.9302 89.5123 80.8198 85.5777 84.0174C78.6837 89.6199 69.7544 93 59.9998 93C50.2453 93 41.316 89.6199 34.422 84.0174C30.4874 80.8198 30.4874 74.9302 34.422 71.7327Z" fill="url(#paint2_linear_582:2091)"/>
</g>
</g>
<defs>
<filter id="filter0_d_582:2091" x="4" y="8" width="112" height="112" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dy="4"/>
<feGaussianBlur stdDeviation="6"/>
<feComposite in2="hardAlpha" operator="out"/>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_582:2091"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_582:2091" result="shape"/>
</filter>
<filter id="filter1_iiiii_582:2091" x="27.4711" y="23" width="63.0576" height="72" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dx="2" dy="2"/>
<feGaussianBlur stdDeviation="3"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.495833 0 0 0 0 0.879 0 0 0 0 1 0 0 0 0.4 0"/>
<feBlend mode="normal" in2="shape" result="effect1_innerShadow_582:2091"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dx="-4" dy="-4"/>
<feGaussianBlur stdDeviation="3"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.0205888 0 0 0 0 0.00944442 0 0 0 0 0.566667 0 0 0 0.2 0"/>
<feBlend mode="normal" in2="effect1_innerShadow_582:2091" result="effect2_innerShadow_582:2091"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dx="1" dy="1"/>
<feGaussianBlur stdDeviation="1"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.816667 0 0 0 0 0.945 0 0 0 0 1 0 0 0 0.2 0"/>
<feBlend mode="normal" in2="effect2_innerShadow_582:2091" result="effect3_innerShadow_582:2091"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dx="-2" dy="-2"/>
<feGaussianBlur stdDeviation="2"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.00608333 0 0 0 0 0 0 0 0 0 0.304167 0 0 0 0.2 0"/>
<feBlend mode="normal" in2="effect3_innerShadow_582:2091" result="effect4_innerShadow_582:2091"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dx="-1" dy="-1"/>
<feGaussianBlur stdDeviation="0.5"/>
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.075 0 0 0 0 0.778 0 0 0 0 1 0 0 0 0.2 0"/>
<feBlend mode="normal" in2="effect4_innerShadow_582:2091" result="effect5_innerShadow_582:2091"/>
</filter>
<linearGradient id="paint0_linear_582:2091" x1="60" y1="0" x2="60" y2="120" gradientUnits="userSpaceOnUse">
<stop stop-color="#5A9CFF"/>
<stop offset="0.87897" stop-color="#2A23D5"/>
<stop offset="1" stop-color="#4A3CEC"/>
</linearGradient>
<linearGradient id="paint1_linear_582:2091" x1="60" y1="40" x2="59.9998" y2="93" gradientUnits="userSpaceOnUse">
<stop offset="0.0350902" stop-color="white"/>
<stop offset="0.525594" stop-color="#B0D4FF"/>
<stop offset="0.837131" stop-color="#DEEDFF"/>
<stop offset="1" stop-color="#FEFEFF"/>
</linearGradient>
<linearGradient id="paint2_linear_582:2091" x1="60" y1="40" x2="59.9998" y2="93" gradientUnits="userSpaceOnUse">
<stop offset="0.0350902" stop-color="white"/>
<stop offset="0.525594" stop-color="#B0D4FF"/>
<stop offset="0.837131" stop-color="#DEEDFF"/>
<stop offset="1" stop-color="#FEFEFF"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<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 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
<g>
<g>
<g>
<path fill="#A4C639" d="M32,0c17.7,0,32,14.3,32,32S49.7,64,32,64S0,49.7,0,32S14.3,0,32,0z"/>
</g>
</g>
<g>
<g>
<path fill="#FFFFFF" d="M16.6,24.6c-1.4,0-2.6,1.2-2.6,2.6L14,38c0,1.4,1.2,2.6,2.6,2.6c1.5,0,2.6-1.2,2.6-2.6l0-10.9
C19.3,25.7,18.1,24.6,16.6,24.6 M37.8,14.8l1.8-3.3c0.1-0.2,0-0.4-0.1-0.5c-0.2-0.1-0.4,0-0.5,0.1l-1.9,3.3
c-1.6-0.7-3.3-1.1-5.1-1.1c-1.8,0-3.6,0.4-5.1,1.1L25,11.2C24.9,11,24.7,11,24.5,11c-0.2,0.1-0.2,0.3-0.1,0.5l1.8,3.3
c-3.6,1.8-6,5.3-6,9.3l23.6,0C43.8,20.2,41.4,16.7,37.8,14.8 M26.6,19.9c-0.5,0-1-0.4-1-1c0-0.5,0.4-1,1-1c0.5,0,1,0.4,1,1
C27.6,19.5,27.2,19.9,26.6,19.9 M37.4,19.9c-0.5,0-1-0.4-1-1c0-0.5,0.4-1,1-1c0.5,0,1,0.4,1,1C38.4,19.5,37.9,19.9,37.4,19.9
M20.3,25.1l0,16.8c0,1.5,1.3,2.8,2.8,2.8l1.9,0l0,5.7c0,1.4,1.2,2.6,2.6,2.6c1.5,0,2.6-1.2,2.6-2.6l0-5.7l3.5,0l0,5.7
c0,1.4,1.2,2.6,2.6,2.6c1.5,0,2.6-1.2,2.6-2.6l0-5.7l1.9,0c1.5,0,2.8-1.2,2.8-2.8l0-16.8L20.3,25.1z M50,27.2
c0-1.4-1.2-2.6-2.6-2.6c-1.4,0-2.6,1.2-2.6,2.6l0,10.9c0,1.4,1.2,2.6,2.6,2.6c1.4,0,2.6-1.2,2.6-2.6L50,27.2z"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
web/img/bg3.1e0d0d23.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 KiB

11
web/img/casa.2579f069.svg Normal file
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
web/img/disk.573d4b55.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
web/img/folder.c8ff81f3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Some files were not shown because too many files have changed in this diff Show More