mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-12-23 13:04:42 +00:00
Compare commits
2 Commits
v0.3.8
...
v0.3.7-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a96f6189ac | ||
|
|
e164a5d4c6 |
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
14
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -28,19 +28,5 @@ If applicable, add screenshots to help explain your problem.
|
|||||||
- Browser [e.g. chrome, safari]
|
- Browser [e.g. chrome, safari]
|
||||||
- Version [e.g. 22]
|
- Version [e.g. 22]
|
||||||
|
|
||||||
**Logs**
|
|
||||||
|
|
||||||
run following command to collect corresponding logs:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo journalctl -xef -u casaos-gateway
|
|
||||||
sudo journalctl -xef -u casaos-user-service
|
|
||||||
sudo journalctl -xef -u casaos-local-storage
|
|
||||||
sudo journalctl -xef -u casaos.service
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**Additional context**
|
**Additional context**
|
||||||
Add any other context about the problem here.
|
Add any other context about the problem here.
|
||||||
|
|||||||
23
.github/ISSUE_TEMPLATE/feedback.yml
vendored
23
.github/ISSUE_TEMPLATE/feedback.yml
vendored
@@ -1,23 +0,0 @@
|
|||||||
name: "Feedback"
|
|
||||||
description: Feedback, showcases, thoughts, needs and questions, etc.
|
|
||||||
title: "[Feedback] "
|
|
||||||
labels: ["feedback"]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
### ❤️ Thanks for your feedback!
|
|
||||||
> Come join our [Discord community](https://discord.gg/knqAbbBbeX) and paint the ideal home cloud with us.
|
|
||||||
- type: textarea
|
|
||||||
id: description
|
|
||||||
attributes:
|
|
||||||
label: Description
|
|
||||||
placeholder: What do you want to tell us?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: additional
|
|
||||||
attributes:
|
|
||||||
label: Additional Information
|
|
||||||
description: Please add logs/files/screenshots if you have them to help us better understanding.
|
|
||||||
|
|
||||||
2
.github/workflows/demo.yml
vendored
2
.github/workflows/demo.yml
vendored
@@ -33,7 +33,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Get old instance and snapshot name, create new instance name
|
- name: Get old instance and snapshot name, create new instance name
|
||||||
run: |
|
run: |
|
||||||
echo "OLD_INSTANCE_SNAPSHOT_NAME=$(aws lightsail get-instance-snapshots | grep '"name": "casaos-0.3.6-1666150291' | sed 's/ //g' | sed 's/"//g' | sed 's/,//g' | sed 's/name://g')" >> $GITHUB_ENV
|
echo "OLD_INSTANCE_SNAPSHOT_NAME=$(aws lightsail get-instance-snapshots | grep '"name": "0.3.3-demo-1658402149' | sed 's/ //g' | sed 's/"//g' | sed 's/,//g' | sed 's/name://g')" >> $GITHUB_ENV
|
||||||
echo "OLD_INSTANCE_NAME=$(aws lightsail get-instances | grep '"name": "CasaOS-Demo-[0-9]' | sed 's/ //g' | sed 's/"//g' | sed 's/,//g' | sed 's/name://g')" >> $GITHUB_ENV
|
echo "OLD_INSTANCE_NAME=$(aws lightsail get-instances | grep '"name": "CasaOS-Demo-[0-9]' | sed 's/ //g' | sed 's/"//g' | sed 's/,//g' | sed 's/name://g')" >> $GITHUB_ENV
|
||||||
echo "NEW_INSTANCE_NAME=CasaOS-Demo-$(date +%s)" >> $GITHUB_ENV
|
echo "NEW_INSTANCE_NAME=CasaOS-Demo-$(date +%s)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
|||||||
24
.github/workflows/release.yml
vendored
24
.github/workflows/release.yml
vendored
@@ -28,10 +28,6 @@ jobs:
|
|||||||
-
|
-
|
||||||
name: Fetch all tags
|
name: Fetch all tags
|
||||||
run: git fetch --force --tags
|
run: git fetch --force --tags
|
||||||
|
|
||||||
- name: Get version
|
|
||||||
id: get_version
|
|
||||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
|
||||||
-
|
-
|
||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
@@ -49,23 +45,3 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
|
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
|
||||||
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||||
|
|
||||||
- name: Upload to oss
|
|
||||||
id: upload_to_oss
|
|
||||||
uses: tvrcgo/upload-to-oss@master
|
|
||||||
with:
|
|
||||||
key-id: ${{ secrets.OSS_KEY_ID }}
|
|
||||||
key-secret: ${{ secrets.OSS_KEY_SECRET }}
|
|
||||||
region: oss-cn-shanghai
|
|
||||||
bucket: casaos
|
|
||||||
assets: |
|
|
||||||
dist/checksums.txt:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/checksums.txt
|
|
||||||
dist/linux-arm-7-casaos-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
|
||||||
dist/linux-arm64-casaos-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
|
||||||
dist/linux-amd64-casaos-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
|
||||||
dist/linux-arm-7-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm-7-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
|
||||||
dist/linux-arm64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
|
||||||
dist/linux-amd64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -36,7 +36,4 @@ main
|
|||||||
github.com
|
github.com
|
||||||
.all-contributorsrc
|
.all-contributorsrc
|
||||||
dist
|
dist
|
||||||
CasaOS
|
CasaOS
|
||||||
|
|
||||||
# System Files
|
|
||||||
.DS_Store
|
|
||||||
48
CHANGELOG.md
48
CHANGELOG.md
@@ -19,53 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
||||||
## [0.3.8-alpha.1] 2022-11-16
|
## [0.3.6-alpha.1] - 2022-09-06
|
||||||
|
|
||||||
### Added
|
|
||||||
- [System] Add system announcement
|
|
||||||
- [App] Allow to turn off the display of "Existing Docker Apps" in the settings.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- [System] Improve the feedback function, you can submit feedback in the bottom right corner of WebUI.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- [System] Fix CPU Temp for other platforms ([#661](https://github.com/IceWhaleTech/CasaOS/issues/661))
|
|
||||||
|
|
||||||
## [0.3.7.1] 2022-11-04
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Fix memory leak issue ([#658](https://github.com/IceWhaleTech/CasaOS/issues/658)[#646](https://github.com/IceWhaleTech/CasaOS/issues/646))
|
|
||||||
- Solve the problem of local application import failure ([#490](https://github.com/IceWhaleTech/CasaOS/issues/490))
|
|
||||||
|
|
||||||
## [0.3.7] 2022-10-28
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- [Storage] Disk merge (Beta), you can merge multiple disks into a single storage space (currently you need to enable this feature from the command line)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- [Files] Changed the cache file storage location, now the file upload size is not limited by the system disk capacity.
|
|
||||||
- [Scripts] Updated installation and upgrade scripts to support more Debian-based Linux distributions.
|
|
||||||
- [Engineering] Refactored Local Storage into a standalone service as part of CasaOS modularization.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- [Apps] App list update mechanism improved, now you can see the latest apps in App Store immediately.
|
|
||||||
- [Storage] Fixed a lot of known issues
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- [Storage] Disk merge (Beta), you can merge multiple disks into a single storage space (currently you need to enable this feature from the command line)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- [Files] Changed the cache file storage location, now the file upload size is not limited by the system disk capacity.
|
|
||||||
- [Scripts] Updated installation and upgrade scripts to support more Debian-based Linux distributions.
|
|
||||||
- [Engineering] Refactored Local Storage into a standalone service as part of CasaOS modularization.
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- [Apps] App list update mechanism improved, now you can see the latest apps in App Store immediately.
|
|
||||||
- [Storage] Fixed a lot of known issues
|
|
||||||
|
|
||||||
|
|
||||||
## [0.3.6] - 2022-09-06
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- [System] Added power and temperature info to performance widget (Intel)
|
- [System] Added power and temperature info to performance widget (Intel)
|
||||||
|
|||||||
40
README.md
40
README.md
@@ -120,13 +120,13 @@ Community Support
|
|||||||
Freshly install a system from the list above and run this command:
|
Freshly install a system from the list above and run this command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
wget -qO- https://get.casaos.io | sudo bash
|
wget -qO- https://get.casaos.io | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -fsSL https://get.casaos.io | sudo bash
|
curl -fsSL https://get.casaos.io | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
### Uninstall CasaOS
|
### Uninstall CasaOS
|
||||||
@@ -141,7 +141,7 @@ casaos-uninstall
|
|||||||
Before v0.3.3
|
Before v0.3.3
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -fsSL https://get.icewhale.io/casaos-uninstall.sh | sudo bash
|
curl -fsSL https://get.icewhale.io/casaos-uninstall.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
@@ -162,8 +162,38 @@ We believes that through community-driven collaborative innovation and open comm
|
|||||||
|
|
||||||
CasaOS is a community-driven open source project and the people involved are CasaOS users. That means CasaOS will always need contributions from community members just like you!
|
CasaOS is a community-driven open source project and the people involved are CasaOS users. That means CasaOS will always need contributions from community members just like you!
|
||||||
|
|
||||||
- See <https://wiki.casaos.io/en/contribute> for ways of contribution to CasaOS
|
<details>
|
||||||
- See <https://wiki.casaos.io/en/contribute/development> if you want to be involved in code contribution specificially
|
<summary><b>How can I get involved? 🧐</b></summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
### Coding 💻 (WIP)
|
||||||
|
|
||||||
|
We are refining documentation that can be used for effective community collaboration. Feel free to start a discussion if you have a good idea.
|
||||||
|
|
||||||
|
### Helping Users 💬
|
||||||
|
|
||||||
|
If you have extensive knowledge of CasaOS and related areas. We highly encourage you to help others as much as you can in Discord and Discussions.
|
||||||
|
|
||||||
|
Discord: [https://discord.gg/knqAbbBbeX](https://discord.gg/knqAbbBbeX)
|
||||||
|
|
||||||
|
GitHub Discussions: [https://github.com/IceWhaleTech/CasaOS/discussions](https://github.com/IceWhaleTech/CasaOS/discussions)
|
||||||
|
|
||||||
|
### Helping with Translations 🌍 (WIP)
|
||||||
|
|
||||||
|
CasaOS officially supports English and Chinese. You are welcome to help make CasaOS available in more languages.
|
||||||
|
|
||||||
|
### Performing Alpha Testing ⚠️
|
||||||
|
|
||||||
|
Alpha testing is quality assurance testing that is engaged and driven by the community. It's a great way to get involved in contributing and experiencing the latest features before a new release.
|
||||||
|
|
||||||
|
The documentation is being refined and you can contact @JohnGuan via [Discord](https://discord.gg/knqAbbBbeX). Ask to join the #casaos-alpha channel.
|
||||||
|
|
||||||
|
### Writing Documentation 📖 (WIP)
|
||||||
|
|
||||||
|
Help make our documentation better by writing new content for the CasaOS Wiki, correcting existing material, or translating content into new languages.
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../..
|
|||||||
SOURCE_ROOT=${BUILD_PATH}/sysroot
|
SOURCE_ROOT=${BUILD_PATH}/sysroot
|
||||||
|
|
||||||
APP_NAME="casaos"
|
APP_NAME="casaos"
|
||||||
|
APP_NAME_FORMAL="CasaOS"
|
||||||
|
#APP_NAME_FORMAL="casaos-alpha"
|
||||||
|
|
||||||
# check if migration is needed
|
# check if migration is needed
|
||||||
SOURCE_BIN_PATH=${SOURCE_ROOT}/usr/bin
|
SOURCE_BIN_PATH=${SOURCE_ROOT}/usr/bin
|
||||||
@@ -83,6 +85,45 @@ if [ "${NEED_MIGRATION}" = "false" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
MIGRATION_SERVICE_DIR=${1}
|
||||||
|
|
||||||
|
if [ -z "${MIGRATION_SERVICE_DIR}" ]; then
|
||||||
|
MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME}
|
||||||
|
fi
|
||||||
|
MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list
|
||||||
|
MIGRATION_PATH=()
|
||||||
|
|
||||||
|
CURRENT_VERSION_FOUND="false"
|
||||||
|
|
||||||
|
# a VERSION_PAIR looks like "v0.3.5 v0.3.6-alpha2"
|
||||||
|
#
|
||||||
|
# - "v0.3.5" is the current version installed on this host
|
||||||
|
# - "v0.3.6-alpha2" is the version of the migration tool from GitHub
|
||||||
|
while read -r VERSION_PAIR; do
|
||||||
|
if [ -z "${VERSION_PAIR}" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# obtain "v0.3.5" from "v0.3.5 v0.3.6-alpha2"
|
||||||
|
VER1=$(echo "${VERSION_PAIR}" | cut -d' ' -f1)
|
||||||
|
|
||||||
|
# obtain "v0.3.6-alpha2" from "v0.3.5 v0.3.6-alpha2"
|
||||||
|
VER2=$(echo "${VERSION_PAIR}" | cut -d' ' -f2)
|
||||||
|
|
||||||
|
if [ "${CURRENT_VERSION}" = "${VER1// /}" ] || [ "${CURRENT_VERSION}" = "LEGACY_WITHOUT_VERSION" ]; then
|
||||||
|
CURRENT_VERSION_FOUND="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${CURRENT_VERSION_FOUND}" = "true" ]; then
|
||||||
|
MIGRATION_PATH+=("${VER2// /}")
|
||||||
|
fi
|
||||||
|
done < "${MIGRATION_LIST_FILE}"
|
||||||
|
|
||||||
|
if [ ${#MIGRATION_PATH[@]} -eq 0 ]; then
|
||||||
|
__warning "No migration path found from ${CURRENT_VERSION} to ${SOURCE_VERSION}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
ARCH="unknown"
|
ARCH="unknown"
|
||||||
|
|
||||||
case $(uname -m) in
|
case $(uname -m) in
|
||||||
@@ -100,59 +141,22 @@ case $(uname -m) in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
__info "ARCH: ${ARCH}"
|
|
||||||
|
|
||||||
MIGRATION_SERVICE_DIR=${1}
|
|
||||||
|
|
||||||
if [ -z "${MIGRATION_SERVICE_DIR}" ]; then
|
|
||||||
MIGRATION_SERVICE_DIR=${BUILD_PATH}/scripts/migration/service.d/${APP_NAME}
|
|
||||||
fi
|
|
||||||
MIGRATION_LIST_FILE=${MIGRATION_SERVICE_DIR}/migration.list
|
|
||||||
MIGRATION_PATH=()
|
|
||||||
|
|
||||||
CURRENT_VERSION_FOUND="false"
|
|
||||||
|
|
||||||
# a VERSION_PAIR looks like "v0.3.5 <url>"
|
|
||||||
#
|
|
||||||
# - "v0.3.5" is the current version installed on this host
|
|
||||||
# - "<url>" is the url of the migration tool
|
|
||||||
while read -r VERSION_PAIR; do
|
|
||||||
if [ -z "${VERSION_PAIR}" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# obtain "v0.3.5" from "v0.3.5 v0.3.6-alpha2"
|
|
||||||
VER1=$(echo "${VERSION_PAIR}" | cut -d' ' -f1)
|
|
||||||
|
|
||||||
# obtain "<url>" from "v0.3.5 <url>"
|
|
||||||
URL=$(eval echo "${VERSION_PAIR}" | cut -d' ' -f2)
|
|
||||||
|
|
||||||
if [ "${CURRENT_VERSION}" = "${VER1// /}" ] || [ "${CURRENT_VERSION}" = "LEGACY_WITHOUT_VERSION" ]; then
|
|
||||||
CURRENT_VERSION_FOUND="true"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${CURRENT_VERSION_FOUND}" = "true" ]; then
|
|
||||||
MIGRATION_PATH+=("${URL// /}")
|
|
||||||
fi
|
|
||||||
done < "${MIGRATION_LIST_FILE}"
|
|
||||||
|
|
||||||
if [ ${#MIGRATION_PATH[@]} -eq 0 ]; then
|
|
||||||
__warning "No migration path found from ${CURRENT_VERSION} to ${SOURCE_VERSION}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "${MIGRATION_SERVICE_DIR}"
|
pushd "${MIGRATION_SERVICE_DIR}"
|
||||||
|
|
||||||
{ for URL in "${MIGRATION_PATH[@]}"; do
|
{ for VER2 in "${MIGRATION_PATH[@]}"; do
|
||||||
MIGRATION_TOOL_FILE=$(basename "${URL}")
|
|
||||||
|
|
||||||
|
MIGRATION_TOOL_FILE=linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz
|
||||||
|
|
||||||
if [ -f "${MIGRATION_TOOL_FILE}" ]; then
|
if [ -f "${MIGRATION_TOOL_FILE}" ]; then
|
||||||
__info "Migration tool ${MIGRATION_TOOL_FILE} exists. Skip downloading."
|
__info "Migration tool ${MIGRATION_TOOL_FILE} exists. Skip downloading."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
__info "Dowloading ${URL}..."
|
# MIGRATION_TOOL_URL=http://192.168.2.197:8000/v1/package/migration?type=release&name="${APP_NAME_FORMAL}"&version=${VER2}&arch=${ARCH}
|
||||||
curl -fsSL -o "${MIGRATION_TOOL_FILE}" -O "${URL}"
|
MIGRATION_TOOL_URL=https://github.com/IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz
|
||||||
|
echo "Dowloading ${MIGRATION_TOOL_URL}..."
|
||||||
|
curl -sL -O "${MIGRATION_TOOL_URL}"
|
||||||
done
|
done
|
||||||
} || {
|
} || {
|
||||||
popd
|
popd
|
||||||
@@ -160,8 +164,8 @@ pushd "${MIGRATION_SERVICE_DIR}"
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
for URL in "${MIGRATION_PATH[@]}"; do
|
for VER2 in "${MIGRATION_PATH[@]}"; do
|
||||||
MIGRATION_TOOL_FILE=$(basename "${URL}")
|
MIGRATION_TOOL_FILE=linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz
|
||||||
__info "Extracting ${MIGRATION_TOOL_FILE}..."
|
__info "Extracting ${MIGRATION_TOOL_FILE}..."
|
||||||
tar zxvf "${MIGRATION_TOOL_FILE}" || __error "Failed to extract ${MIGRATION_TOOL_FILE}"
|
tar zxvf "${MIGRATION_TOOL_FILE}" || __error "Failed to extract ${MIGRATION_TOOL_FILE}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
LEGACY_WITHOUT_VERSION https://github.com/IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz
|
LEGACY_WITHOUT_VERSION v0.3.6
|
||||||
v0.3.5 https://github.com/IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz
|
v0.3.5 v0.3.6
|
||||||
v0.3.5.1 https://github.com/IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz
|
v0.3.5.1 v0.3.6
|
||||||
|
v0.3.6 v0.3.7
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAME}"
|
|||||||
|
|
||||||
{
|
{
|
||||||
echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..."
|
echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..."
|
||||||
$BASH "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}"
|
$SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}"
|
||||||
} || {
|
} || {
|
||||||
echo "🟥 ${SETUP_SCRIPT_FILENAME} failed."
|
echo "🟥 ${SETUP_SCRIPT_FILENAME} failed."
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -31,10 +31,15 @@ if [ ! -f "${CONF_FILE}" ]; then
|
|||||||
cp -v "${CONF_FILE_SAMPLE}" "${CONF_FILE}"
|
cp -v "${CONF_FILE_SAMPLE}" "${CONF_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf /etc/systemd/system/casaos.service # remove old service file
|
if systemctl is-active "${APP_NAME}.service" &>/dev/null ;then
|
||||||
|
echo "server started"
|
||||||
|
else
|
||||||
|
# enable and start service
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
systemctl daemon-reload
|
echo "Enabling service..."
|
||||||
|
systemctl enable --force --no-ask-password "${APP_NAME}.service"
|
||||||
|
|
||||||
# enable service (without starting)
|
#echo "Starting service..."
|
||||||
echo "Enabling service..."
|
#systemctl start --force --no-ask-password "${APP_NAME}.service"
|
||||||
systemctl enable --force --no-ask-password "${APP_NAME}.service"
|
fi
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
###
|
|
||||||
# @Author: LinkLeong link@icewhale.org
|
|
||||||
# @Date: 2022-11-15 15:51:44
|
|
||||||
# @LastEditors: LinkLeong
|
|
||||||
# @LastEditTime: 2022-11-15 15:53:37
|
|
||||||
# @FilePath: /CasaOS/build/sysroot/usr/share/casaos/cleanup/script.d/03-cleanup-casaos.sh
|
|
||||||
# @Description:
|
|
||||||
# @Website: https://www.casaos.io
|
|
||||||
# Copyright (c) 2022 by icewhale, All Rights Reserved.
|
|
||||||
###
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
readonly APP_NAME_SHORT=casaos
|
|
||||||
|
|
||||||
__get_setup_script_directory_by_os_release() {
|
|
||||||
pushd "$(dirname "${BASH_SOURCE[0]}")/../service.d/${APP_NAME_SHORT}" &>/dev/null
|
|
||||||
|
|
||||||
{
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
{
|
|
||||||
source /etc/os-release
|
|
||||||
{
|
|
||||||
pushd "${ID}"/"${VERSION_CODENAME}" &>/dev/null
|
|
||||||
} || {
|
|
||||||
pushd "${ID}" &>/dev/null
|
|
||||||
} || {
|
|
||||||
pushd "${ID_LIKE}" &>/dev/null
|
|
||||||
} || {
|
|
||||||
echo "Unsupported OS: ${ID} ${VERSION_CODENAME} (${ID_LIKE})"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
pwd
|
|
||||||
|
|
||||||
popd &>/dev/null
|
|
||||||
|
|
||||||
} || {
|
|
||||||
echo "Unsupported OS: unknown"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
popd &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
SETUP_SCRIPT_DIRECTORY=$(__get_setup_script_directory_by_os_release)
|
|
||||||
|
|
||||||
readonly SETUP_SCRIPT_DIRECTORY
|
|
||||||
readonly SETUP_SCRIPT_FILENAME="cleanup-${APP_NAME_SHORT}.sh"
|
|
||||||
readonly SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAME}"
|
|
||||||
|
|
||||||
echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..."
|
|
||||||
$SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}"
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../cleanup-casaos.sh
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
readonly CASA_SERVICES=(
|
|
||||||
"casaos.service"
|
|
||||||
"devmon@devmon.service"
|
|
||||||
)
|
|
||||||
|
|
||||||
readonly CASA_EXEC=casaos
|
|
||||||
readonly CASA_CONF=/etc/casaos/casaos.conf
|
|
||||||
readonly CASA_URL=/var/run/casaos/casaos.url
|
|
||||||
readonly CASA_SERVICE_USR=/usr/lib/systemd/system/casaos.service
|
|
||||||
readonly CASA_SERVICE_LIB=/lib/systemd/system/casaos.service
|
|
||||||
readonly CASA_SERVICE_ETC=/etc/systemd/system/casaos.service
|
|
||||||
|
|
||||||
# Old Casa Files
|
|
||||||
readonly CASA_PATH=/casaOS
|
|
||||||
readonly CASA_CONF_PATH_OLD=/etc/casaos.conf
|
|
||||||
|
|
||||||
readonly aCOLOUR=(
|
|
||||||
'\e[38;5;154m' # green | Lines, bullets and separators
|
|
||||||
'\e[1m' # Bold white | Main descriptions
|
|
||||||
'\e[90m' # Grey | Credits
|
|
||||||
'\e[91m' # Red | Update notifications Alert
|
|
||||||
'\e[33m' # Yellow | Emphasis
|
|
||||||
)
|
|
||||||
|
|
||||||
Show() {
|
|
||||||
# OK
|
|
||||||
if (($1 == 0)); then
|
|
||||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
|
||||||
# FAILED
|
|
||||||
elif (($1 == 1)); then
|
|
||||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
|
||||||
# INFO
|
|
||||||
elif (($1 == 2)); then
|
|
||||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
|
||||||
# NOTICE
|
|
||||||
elif (($1 == 3)); then
|
|
||||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
Warn() {
|
|
||||||
echo -e "${aCOLOUR[3]}$1$COLOUR_RESET"
|
|
||||||
}
|
|
||||||
|
|
||||||
trap 'onCtrlC' INT
|
|
||||||
onCtrlC() {
|
|
||||||
echo -e "${COLOUR_RESET}"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Detecting_CasaOS() {
|
|
||||||
if [[ ! -x "$(command -v ${CASA_EXEC})" ]]; then
|
|
||||||
Show 2 "CasaOS is not detected, exit the script."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
Show 0 "This script will delete the containers you no longer use, and the CasaOS configuration files."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
Uninstall_Container() {
|
|
||||||
if [[ ${UNINSTALL_ALL_CONTAINER} == true && "$(docker ps -aq)" != "" ]]; then
|
|
||||||
Show 2 "Start deleting containers."
|
|
||||||
docker stop "$(docker ps -aq)" || Show 1 "Failed to stop all containers."
|
|
||||||
docker rm "$(docker ps -aq)" || Show 1 "Failed to delete all containers."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
Remove_Images() {
|
|
||||||
if [[ ${REMOVE_IMAGES} == "all" && "$(docker images -q)" != "" ]]; then
|
|
||||||
Show 2 "Start deleting all images."
|
|
||||||
docker rmi "$(docker images -q)" || Show 1 "Failed to delete all images."
|
|
||||||
elif [[ ${REMOVE_IMAGES} == "unuse" && "$(docker images -q)" != "" ]]; then
|
|
||||||
Show 2 "Start deleting unuse images."
|
|
||||||
docker image prune -af || Show 1 "Failed to delete unuse images."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Uninstall_Casaos() {
|
|
||||||
|
|
||||||
for SERVICE in "${CASA_SERVICES[@]}"; do
|
|
||||||
Show 2 "Stopping ${SERVICE}..."
|
|
||||||
systemctl disable --now "${SERVICE}" || Show 3 "Failed to disable ${SERVICE}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Remove Service file
|
|
||||||
if [[ -f ${CASA_SERVICE_USR} ]]; then
|
|
||||||
rm -rvf ${CASA_SERVICE_USR}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f ${CASA_SERVICE_LIB} ]]; then
|
|
||||||
rm -rvf ${CASA_SERVICE_LIB}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f ${CASA_SERVICE_ETC} ]]; then
|
|
||||||
rm -rvf ${CASA_SERVICE_ETC}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Old Casa Files
|
|
||||||
if [[ -d ${CASA_PATH} ]]; then
|
|
||||||
rm -rvf ${CASA_PATH} || Show 1 "Failed to delete legacy CasaOS files."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f ${CASA_CONF_PATH_OLD} ]]; then
|
|
||||||
rm -rvf ${CASA_CONF_PATH_OLD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# New Casa Files
|
|
||||||
if [[ ${REMOVE_APP_DATA} = true ]]; then
|
|
||||||
rm -rvf /DATA/AppData || Show 1 "Failed to delete AppData."
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rvf "$(which ${CASA_EXEC})" || Show 3 "Failed to remove ${CASA_EXEC}"
|
|
||||||
rm -rvf ${CASA_CONF} || Show 3 "Failed to remove ${CASA_CONF}"
|
|
||||||
rm -rvf ${CASA_URL} || Show 3 "Failed to remove ${CASA_URL}"
|
|
||||||
|
|
||||||
rm -rvf /var/lib/casaos/app_category.json
|
|
||||||
rm -rvf /var/lib/casaos/app_list.json
|
|
||||||
rm -rvf /var/lib/casaos/docker_root
|
|
||||||
}
|
|
||||||
|
|
||||||
Detecting_CasaOS
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
echo -n -e " ${aCOLOUR[4]}Do you want delete all containers? Y/n :${COLOUR_RESET}"
|
|
||||||
read -r input
|
|
||||||
case $input in
|
|
||||||
[yY][eE][sS] | [yY])
|
|
||||||
UNINSTALL_ALL_CONTAINER=true
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN][oO] | [nN])
|
|
||||||
UNINSTALL_ALL_CONTAINER=false
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
Warn " Invalid input..."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ${UNINSTALL_ALL_CONTAINER} == true ]]; then
|
|
||||||
while true; do
|
|
||||||
echo -n -e " ${aCOLOUR[4]}Do you want delete all images? Y/n :${COLOUR_RESET}"
|
|
||||||
read -r input
|
|
||||||
case $input in
|
|
||||||
[yY][eE][sS] | [yY])
|
|
||||||
REMOVE_IMAGES="all"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN][oO] | [nN])
|
|
||||||
REMOVE_IMAGES="none"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
Warn " Invalid input..."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
echo -n -e " ${aCOLOUR[4]}Do you want delete all AppData of CasaOS? Y/n :${COLOUR_RESET}"
|
|
||||||
read -r input
|
|
||||||
case $input in
|
|
||||||
[yY][eE][sS] | [yY])
|
|
||||||
REMOVE_APP_DATA=true
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN][oO] | [nN])
|
|
||||||
REMOVE_APP_DATA=false
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
Warn " Invalid input..."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
else
|
|
||||||
while true; do
|
|
||||||
echo -n -e " ${aCOLOUR[4]}Do you want to delete all images that are not used by the container? Y/n :${COLOUR_RESET}"
|
|
||||||
read -r input
|
|
||||||
case $input in
|
|
||||||
[yY][eE][sS] | [yY])
|
|
||||||
REMOVE_IMAGES="unuse"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
[nN][oO] | [nN])
|
|
||||||
REMOVE_IMAGES="none"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
Warn " Invalid input..."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
Uninstall_Container
|
|
||||||
Remove_Images
|
|
||||||
Uninstall_Casaos
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../debian/cleanup-casaos.sh
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../debian/bullseye/cleanup-casaos.sh
|
|
||||||
@@ -9,4 +9,4 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
|
|
||||||
curl -fsSL https://raw.githubusercontent.com/IceWhaleTech/get/main/update.sh | bash
|
curl -fsSL https://raw.githubusercontent.com/LinkLeong/casaos-alpha/main/new.update.sh | bash
|
||||||
@@ -83,7 +83,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
migrationTools := []interfaces.MigrationTool{
|
migrationTools := []interfaces.MigrationTool{
|
||||||
// nothing to migrate from last version
|
NewMigrationToolFor_035(),
|
||||||
|
NewMigrationToolFor_036(),
|
||||||
}
|
}
|
||||||
|
|
||||||
var selectedMigrationTool interfaces.MigrationTool
|
var selectedMigrationTool interfaces.MigrationTool
|
||||||
@@ -114,7 +115,8 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := selectedMigrationTool.PostMigrate(); err != nil {
|
selectedMigrationTool.PostMigrate()
|
||||||
_logger.Error("Migration succeeded, but post-migration failed: %s", err)
|
_logger.Info("casaos migration ok")
|
||||||
}
|
// panic(err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
182
cmd/migration-tool/migration-034-035.go
Normal file
182
cmd/migration-tool/migration-034-035.go
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.org
|
||||||
|
* @Date: 2022-08-24 17:36:00
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-09-05 11:24:27
|
||||||
|
* @FilePath: /CasaOS/cmd/migration-tool/migration-034-035.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
interfaces "github.com/IceWhaleTech/CasaOS-Common"
|
||||||
|
"github.com/IceWhaleTech/CasaOS-Common/utils/version"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type migrationTool036 struct{}
|
||||||
|
|
||||||
|
func (u *migrationTool036) IsMigrationNeeded() (bool, error) {
|
||||||
|
|
||||||
|
majorVersion, minorVersion, patchVersion, err := version.DetectLegacyVersion()
|
||||||
|
if err != nil {
|
||||||
|
if err == version.ErrLegacyVersionNotFound {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if majorVersion > 0 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if minorVersion > 3 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if minorVersion == 3 && patchVersion > 5 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("Migration is needed for a CasaOS version 0.3.5 and older...")
|
||||||
|
return true, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *migrationTool036) PreMigrate() error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *migrationTool036) Migrate() error {
|
||||||
|
|
||||||
|
if service.MyService.System().GetSysInfo().KernelArch == "aarch64" && config.ServerInfo.USBAutoMount != "True" && strings.Contains(service.MyService.System().GetDeviceTree(), "Raspberry Pi") {
|
||||||
|
service.MyService.System().UpdateUSBAutoMount("False")
|
||||||
|
service.MyService.System().ExecUSBAutoMountShell("False")
|
||||||
|
}
|
||||||
|
newAPIUrl := "https://api.casaos.io/casaos-api"
|
||||||
|
if config.ServerInfo.ServerApi == "https://api.casaos.zimaboard.com" {
|
||||||
|
config.ServerInfo.ServerApi = newAPIUrl
|
||||||
|
config.Cfg.Section("server").Key("ServerApi").SetValue(newAPIUrl)
|
||||||
|
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
||||||
|
}
|
||||||
|
command.OnlyExec("curl -fsSL https://raw.githubusercontent.com/IceWhaleTech/get/main/assist.sh | bash")
|
||||||
|
if !file.CheckNotExist("/casaOS") {
|
||||||
|
command.OnlyExec("source /casaOS/server/shell/update.sh ;")
|
||||||
|
command.OnlyExec("source " + config.AppInfo.ShellPath + "/delete-old-service.sh ;")
|
||||||
|
}
|
||||||
|
|
||||||
|
service.MyService.App().ImportApplications(true)
|
||||||
|
|
||||||
|
src := "/casaOS/server/conf/conf.ini"
|
||||||
|
if file.Exists(src) {
|
||||||
|
dst := "/etc/casaos/casaos.conf"
|
||||||
|
source, err := os.Open(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer source.Close()
|
||||||
|
|
||||||
|
destination, err := os.Create(dst)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer destination.Close()
|
||||||
|
_, err = io.Copy(destination, source)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if file.Exists("/casaOS/server/db") {
|
||||||
|
var fds []os.FileInfo
|
||||||
|
var err error
|
||||||
|
to := "/var/lib/casaos/db"
|
||||||
|
file.IsNotExistMkDir(to)
|
||||||
|
from := "/casaOS/server/db"
|
||||||
|
if fds, err = ioutil.ReadDir(from); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, fd := range fds {
|
||||||
|
srcfp := path.Join(from, fd.Name())
|
||||||
|
dstfp := path.Join(to, fd.Name())
|
||||||
|
source, err := os.Open(srcfp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer source.Close()
|
||||||
|
|
||||||
|
destination, err := os.Create(dstfp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer destination.Close()
|
||||||
|
_, err = io.Copy(destination, source)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if file.Exists("/casaOS/server/conf") {
|
||||||
|
var fds []os.FileInfo
|
||||||
|
var err error
|
||||||
|
to := "/var/lib/casaos/conf"
|
||||||
|
file.IsNotExistMkDir(to)
|
||||||
|
from := "/casaOS/server/conf"
|
||||||
|
if fds, err = ioutil.ReadDir(from); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, fd := range fds {
|
||||||
|
fExt := path.Ext(fd.Name())
|
||||||
|
if fExt != ".json" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
srcfp := path.Join(from, fd.Name())
|
||||||
|
dstfp := path.Join(to, fd.Name())
|
||||||
|
source, err := os.Open(srcfp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer source.Close()
|
||||||
|
|
||||||
|
destination, err := os.Create(dstfp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer destination.Close()
|
||||||
|
_, err = io.Copy(destination, source)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("update done")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *migrationTool036) PostMigrate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMigrationToolFor_035() interfaces.MigrationTool {
|
||||||
|
return &migrationTool{}
|
||||||
|
}
|
||||||
@@ -11,13 +11,18 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
interfaces "github.com/IceWhaleTech/CasaOS-Common"
|
interfaces "github.com/IceWhaleTech/CasaOS-Common"
|
||||||
"github.com/IceWhaleTech/CasaOS-Common/utils/version"
|
"github.com/IceWhaleTech/CasaOS-Common/utils/version"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
type migrationTool struct{}
|
type migrationTool struct{}
|
||||||
|
|
||||||
func (u *migrationTool) IsMigrationNeeded() (bool, error) {
|
func (u *migrationTool) IsMigrationNeeded() (bool, error) {
|
||||||
|
|
||||||
majorVersion, minorVersion, patchVersion, err := version.DetectLegacyVersion()
|
majorVersion, minorVersion, patchVersion, err := version.DetectLegacyVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == version.ErrLegacyVersionNotFound {
|
if err == version.ErrLegacyVersionNotFound {
|
||||||
@@ -41,13 +46,22 @@ func (u *migrationTool) IsMigrationNeeded() (bool, error) {
|
|||||||
|
|
||||||
_logger.Info("Migration is needed for a CasaOS version 0.3.5 and older...")
|
_logger.Info("Migration is needed for a CasaOS version 0.3.5 and older...")
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *migrationTool) PreMigrate() error {
|
func (u *migrationTool) PreMigrate() error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *migrationTool) Migrate() error {
|
func (u *migrationTool) Migrate() error {
|
||||||
|
|
||||||
|
if service.MyService.System().GetSysInfo().KernelArch == "aarch64" && config.ServerInfo.USBAutoMount != "True" && strings.Contains(service.MyService.System().GetDeviceTree(), "Raspberry Pi") {
|
||||||
|
service.MyService.System().UpdateUSBAutoMount("False")
|
||||||
|
service.MyService.System().ExecUSBAutoMountShell("False")
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("update done")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
2
go.mod
2
go.mod
@@ -4,7 +4,7 @@ go 1.16
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
||||||
github.com/IceWhaleTech/CasaOS-Common v0.3.7-5
|
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220929035515-b1287110d6d8
|
||||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6
|
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6
|
||||||
github.com/Microsoft/go-winio v0.5.0 // indirect
|
github.com/Microsoft/go-winio v0.5.0 // indirect
|
||||||
github.com/ambelovsky/go-structs v1.1.0 // indirect
|
github.com/ambelovsky/go-structs v1.1.0 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -84,8 +84,8 @@ github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
|||||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d/go.mod h1:lW9x+yEjqKdPbE3+cf2fGPJXCw/hChX3Omi9QHTLFsQ=
|
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d/go.mod h1:lW9x+yEjqKdPbE3+cf2fGPJXCw/hChX3Omi9QHTLFsQ=
|
||||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||||
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk=
|
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220901034123-ca130f6b5ce9/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk=
|
||||||
github.com/IceWhaleTech/CasaOS-Common v0.3.7-5 h1:CLPeUaFoGCA3WNnOWxtdFbBmLIg7odCQglZJ/c878uU=
|
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220929035515-b1287110d6d8 h1:r8nhgQ6tnrn6ikXN9aLH/K4H4H64Nc0hZ6jyW2B22x0=
|
||||||
github.com/IceWhaleTech/CasaOS-Common v0.3.7-5/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk=
|
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220929035515-b1287110d6d8/go.mod h1:2MiivEMzvh41codhEKUcn46WK3Ffesop/04qa9jsvQk=
|
||||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg=
|
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 h1:2tQQo85+jzbbjqIsKKn77QlAA73bc7vZsVCFvWnK4mg=
|
||||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA=
|
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6/go.mod h1:hnZwGUzcOyiufMpVO7l3gu2gAm6Ws4TY4Nlj3kMshXA=
|
||||||
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
|
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
|
||||||
|
|||||||
7
main.go
7
main.go
@@ -8,7 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS-Common/model"
|
"github.com/IceWhaleTech/CasaOS-Gateway/common"
|
||||||
"github.com/IceWhaleTech/CasaOS/model/notify"
|
"github.com/IceWhaleTech/CasaOS/model/notify"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/cache"
|
"github.com/IceWhaleTech/CasaOS/pkg/cache"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||||
@@ -56,7 +56,6 @@ func init() {
|
|||||||
service.Cache = cache.Init()
|
service.Cache = cache.Init()
|
||||||
|
|
||||||
service.GetToken()
|
service.GetToken()
|
||||||
service.GetCPUThermalZone()
|
|
||||||
|
|
||||||
service.NewVersionApp = make(map[string]string)
|
service.NewVersionApp = make(map[string]string)
|
||||||
route.InitFunction()
|
route.InitFunction()
|
||||||
@@ -113,7 +112,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
routers := []string{"sys", "apps", "container", "app-categories", "port", "file", "folder", "batch", "image", "samba", "notify"}
|
routers := []string{"sys", "apps", "container", "app-categories", "port", "file", "folder", "batch", "image", "samba", "notify"}
|
||||||
for _, v := range routers {
|
for _, v := range routers {
|
||||||
err = service.MyService.Gateway().CreateRoute(&model.Route{
|
err = service.MyService.Gateway().CreateRoute(&common.Route{
|
||||||
Path: "/v1/" + v,
|
Path: "/v1/" + v,
|
||||||
Target: "http://" + listener.Addr().String(),
|
Target: "http://" + listener.Addr().String(),
|
||||||
})
|
})
|
||||||
@@ -127,7 +126,7 @@ func main() {
|
|||||||
time.Sleep(time.Second * 2)
|
time.Sleep(time.Second * 2)
|
||||||
// v0.3.6
|
// v0.3.6
|
||||||
if config.ServerInfo.HttpPort != "" {
|
if config.ServerInfo.HttpPort != "" {
|
||||||
changePort := model.ChangePortRequest{}
|
changePort := common.ChangePortRequest{}
|
||||||
changePort.Port = config.ServerInfo.HttpPort
|
changePort.Port = config.ServerInfo.HttpPort
|
||||||
err := service.MyService.Gateway().ChangePort(&changePort)
|
err := service.MyService.Gateway().ChangePort(&changePort)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ type ServerModel struct {
|
|||||||
Token string
|
Token string
|
||||||
USBAutoMount string
|
USBAutoMount string
|
||||||
SocketPort string
|
SocketPort string
|
||||||
UpdateUrl string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务配置
|
// 服务配置
|
||||||
@@ -74,8 +73,3 @@ type FileSetting struct {
|
|||||||
ShareDir []string `json:"share_dir" delim:"|"`
|
ShareDir []string `json:"share_dir" delim:"|"`
|
||||||
DownloadDir string `json:"download_dir"`
|
DownloadDir string `json:"download_dir"`
|
||||||
}
|
}
|
||||||
type BaseInfo struct {
|
|
||||||
Hash string `json:"i"`
|
|
||||||
Version string `json:"v"`
|
|
||||||
Channel string `json:"c,omitempty"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ func SpliceFiles(dir, path string, length int, startPoint int) error {
|
|||||||
|
|
||||||
// todo: here should have a goroutine to remove each partial file after it is read, to save disk space
|
// todo: here should have a goroutine to remove each partial file after it is read, to save disk space
|
||||||
|
|
||||||
for i := 0; i < length+startPoint-1; i++ {
|
for i := 0; i < length+startPoint; i++ {
|
||||||
data, err := ioutil.ReadFile(dir + "/" + strconv.Itoa(i+startPoint))
|
data, err := ioutil.ReadFile(dir + "/" + strconv.Itoa(i+startPoint))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,65 +1,21 @@
|
|||||||
/*
|
|
||||||
* @Author: LinkLeong link@icewhale.org
|
|
||||||
* @Date: 2022-11-15 15:51:44
|
|
||||||
* @LastEditors: LinkLeong
|
|
||||||
* @LastEditTime: 2022-11-15 15:55:16
|
|
||||||
* @FilePath: /CasaOS/route/init.go
|
|
||||||
* @Description:
|
|
||||||
* @Website: https://www.casaos.io
|
|
||||||
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
|
||||||
*/
|
|
||||||
package route
|
package route
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS/model"
|
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/samba"
|
"github.com/IceWhaleTech/CasaOS/pkg/samba"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/encryption"
|
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||||
"github.com/IceWhaleTech/CasaOS/service"
|
"github.com/IceWhaleTech/CasaOS/service"
|
||||||
"github.com/IceWhaleTech/CasaOS/types"
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitFunction() {
|
func InitFunction() {
|
||||||
go InitNetworkMount()
|
go InitNetworkMount()
|
||||||
go InitInfo()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitInfo() {
|
|
||||||
mb := model.BaseInfo{}
|
|
||||||
if file.Exists(config.AppInfo.DBPath + "/baseinfo.conf") {
|
|
||||||
err := json.Unmarshal(file.ReadFullFile(config.AppInfo.DBPath+"/baseinfo.conf"), &mb)
|
|
||||||
if err != nil {
|
|
||||||
loger.Error("baseinfo.conf", zap.String("error", err.Error()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if file.Exists("/etc/CHANNEL") {
|
|
||||||
channel := file.ReadFullFile("/etc/CHANNEL")
|
|
||||||
mb.Channel = string(channel)
|
|
||||||
}
|
|
||||||
mac, err := service.MyService.System().GetMacAddress()
|
|
||||||
if err != nil {
|
|
||||||
loger.Error("GetMacAddress", zap.String("error", err.Error()))
|
|
||||||
}
|
|
||||||
mb.Hash = encryption.GetMD5ByStr(mac)
|
|
||||||
mb.Version = types.CURRENTVERSION
|
|
||||||
os.Remove(config.AppInfo.DBPath + "/baseinfo.conf")
|
|
||||||
by, err := json.Marshal(mb)
|
|
||||||
if err != nil {
|
|
||||||
loger.Error("init info err", zap.Any("err", err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
file.WriteToFullPath(by, config.AppInfo.DBPath+"/baseinfo.conf", 0o666)
|
|
||||||
}
|
|
||||||
|
|
||||||
func InitNetworkMount() {
|
func InitNetworkMount() {
|
||||||
time.Sleep(time.Second * 10)
|
time.Sleep(time.Second * 10)
|
||||||
connections := service.MyService.Connections().GetConnectionsList()
|
connections := service.MyService.Connections().GetConnectionsList()
|
||||||
|
|||||||
@@ -146,6 +146,9 @@ func InitRouter() *gin.Engine {
|
|||||||
// v1SysGroup.GET("/disk", v1.GetSystemDiskInfo)
|
// v1SysGroup.GET("/disk", v1.GetSystemDiskInfo)
|
||||||
// v1SysGroup.GET("/network", v1.GetSystemNetInfo)
|
// v1SysGroup.GET("/network", v1.GetSystemNetInfo)
|
||||||
|
|
||||||
|
v1SysGroup.PUT("/usb-auto-mount", v1.PutSystemUSBAutoMount) ///sys/usb/:status
|
||||||
|
v1SysGroup.GET("/usb-auto-mount", v1.GetSystemUSBAutoMount) ///sys/usb/status
|
||||||
|
|
||||||
v1SysGroup.GET("/server-info", nil)
|
v1SysGroup.GET("/server-info", nil)
|
||||||
v1SysGroup.PUT("/server-info", nil)
|
v1SysGroup.PUT("/server-info", nil)
|
||||||
v1SysGroup.GET("/apps-state", v1.GetSystemAppsStatus)
|
v1SysGroup.GET("/apps-state", v1.GetSystemAppsStatus)
|
||||||
|
|||||||
@@ -1126,7 +1126,7 @@ func ContainerUpdateInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, v := range info.Config.Env {
|
for _, v := range info.Config.Env {
|
||||||
if len(showENVList) > 0 && info.Config.Labels["origin"] != "local" {
|
if len(showENVList) > 0 {
|
||||||
if _, ok := showENVMap[strings.Split(v, "=")[0]]; ok {
|
if _, ok := showENVMap[strings.Split(v, "=")[0]]; ok {
|
||||||
temp := model.Env{
|
temp := model.Env{
|
||||||
Name: strings.Split(v, "=")[0],
|
Name: strings.Split(v, "=")[0],
|
||||||
|
|||||||
@@ -407,6 +407,7 @@ func PostFileUpload(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
c.JSON(http.StatusBadRequest, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tempDir := filepath.Join(path, ".temp", hash+strconv.Itoa(totalChunks)) + "/"
|
tempDir := filepath.Join(path, ".temp", hash+strconv.Itoa(totalChunks)) + "/"
|
||||||
|
|
||||||
if fileName != relative {
|
if fileName != relative {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
http2 "github.com/IceWhaleTech/CasaOS-Common/utils/http"
|
|
||||||
"github.com/IceWhaleTech/CasaOS/model"
|
"github.com/IceWhaleTech/CasaOS/model"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
||||||
@@ -165,6 +164,51 @@ func PostKillCasaOS(c *gin.Context) {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Summary Turn off usb auto-mount
|
||||||
|
// @Produce application/json
|
||||||
|
// @Accept application/json
|
||||||
|
// @Tags sys
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Success 200 {string} string "ok"
|
||||||
|
// @Router /sys/usb/off [put]
|
||||||
|
func PutSystemUSBAutoMount(c *gin.Context) {
|
||||||
|
js := make(map[string]string)
|
||||||
|
c.ShouldBind(&js)
|
||||||
|
status := js["state"]
|
||||||
|
if status == "on" {
|
||||||
|
service.MyService.System().UpdateUSBAutoMount("True")
|
||||||
|
service.MyService.System().ExecUSBAutoMountShell("True")
|
||||||
|
} else {
|
||||||
|
service.MyService.System().UpdateUSBAutoMount("False")
|
||||||
|
service.MyService.System().ExecUSBAutoMountShell("False")
|
||||||
|
}
|
||||||
|
c.JSON(common_err.SUCCESS,
|
||||||
|
model.Result{
|
||||||
|
Success: common_err.SUCCESS,
|
||||||
|
Message: common_err.GetMsg(common_err.SUCCESS),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary Turn off usb auto-mount
|
||||||
|
// @Produce application/json
|
||||||
|
// @Accept application/json
|
||||||
|
// @Tags sys
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Success 200 {string} string "ok"
|
||||||
|
// @Router /sys/usb [get]
|
||||||
|
func GetSystemUSBAutoMount(c *gin.Context) {
|
||||||
|
state := "True"
|
||||||
|
if config.ServerInfo.USBAutoMount == "False" {
|
||||||
|
state = "False"
|
||||||
|
}
|
||||||
|
c.JSON(common_err.SUCCESS,
|
||||||
|
model.Result{
|
||||||
|
Success: common_err.SUCCESS,
|
||||||
|
Message: common_err.GetMsg(common_err.SUCCESS),
|
||||||
|
Data: state,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func GetSystemAppsStatus(c *gin.Context) {
|
func GetSystemAppsStatus(c *gin.Context) {
|
||||||
systemAppList := service.MyService.App().GetSystemAppList()
|
systemAppList := service.MyService.App().GetSystemAppList()
|
||||||
appList := []model2.MyAppList{}
|
appList := []model2.MyAppList{}
|
||||||
@@ -181,12 +225,12 @@ func GetSystemAppsStatus(c *gin.Context) {
|
|||||||
Id: v.ID,
|
Id: v.ID,
|
||||||
Port: v.Labels["web"],
|
Port: v.Labels["web"],
|
||||||
Index: v.Labels["index"],
|
Index: v.Labels["index"],
|
||||||
// Order: m.Labels["order"],
|
//Order: m.Labels["order"],
|
||||||
Image: v.Image,
|
Image: v.Image,
|
||||||
Latest: false,
|
Latest: false,
|
||||||
// Type: m.Labels["origin"],
|
//Type: m.Labels["origin"],
|
||||||
// Slogan: m.Slogan,
|
//Slogan: m.Slogan,
|
||||||
// Rely: m.Rely,
|
//Rely: m.Rely,
|
||||||
Host: v.Labels["host"],
|
Host: v.Labels["host"],
|
||||||
Protocol: v.Labels["protocol"],
|
Protocol: v.Labels["protocol"],
|
||||||
})
|
})
|
||||||
@@ -207,6 +251,7 @@ func GetSystemAppsStatus(c *gin.Context) {
|
|||||||
// @Success 200 {string} string "ok"
|
// @Success 200 {string} string "ok"
|
||||||
// @Router /sys/hardware/info [get]
|
// @Router /sys/hardware/info [get]
|
||||||
func GetSystemHardwareInfo(c *gin.Context) {
|
func GetSystemHardwareInfo(c *gin.Context) {
|
||||||
|
|
||||||
data := make(map[string]string, 1)
|
data := make(map[string]string, 1)
|
||||||
data["drive_model"] = service.MyService.System().GetDeviceTree()
|
data["drive_model"] = service.MyService.System().GetDeviceTree()
|
||||||
c.JSON(common_err.SUCCESS,
|
c.JSON(common_err.SUCCESS,
|
||||||
@@ -225,7 +270,7 @@ func GetSystemHardwareInfo(c *gin.Context) {
|
|||||||
// @Success 200 {string} string "ok"
|
// @Success 200 {string} string "ok"
|
||||||
// @Router /sys/utilization [get]
|
// @Router /sys/utilization [get]
|
||||||
func GetSystemUtilization(c *gin.Context) {
|
func GetSystemUtilization(c *gin.Context) {
|
||||||
data := make(map[string]interface{})
|
var data = make(map[string]interface{}, 6)
|
||||||
cpu := service.MyService.System().GetCpuPercent()
|
cpu := service.MyService.System().GetCpuPercent()
|
||||||
num := service.MyService.System().GetCpuCoreNum()
|
num := service.MyService.System().GetCpuCoreNum()
|
||||||
cpuData := make(map[string]interface{})
|
cpuData := make(map[string]interface{})
|
||||||
@@ -237,7 +282,7 @@ func GetSystemUtilization(c *gin.Context) {
|
|||||||
data["cpu"] = cpuData
|
data["cpu"] = cpuData
|
||||||
data["mem"] = service.MyService.System().GetMemInfo()
|
data["mem"] = service.MyService.System().GetMemInfo()
|
||||||
|
|
||||||
// 拼装网络信息
|
//拼装网络信息
|
||||||
netList := service.MyService.System().GetNetInfo()
|
netList := service.MyService.System().GetNetInfo()
|
||||||
newNet := []model.IOCountersStat{}
|
newNet := []model.IOCountersStat{}
|
||||||
nets := service.MyService.System().GetNet(true)
|
nets := service.MyService.System().GetNet(true)
|
||||||
@@ -254,9 +299,7 @@ func GetSystemUtilization(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data["net"] = newNet
|
data["net"] = newNet
|
||||||
for k, v := range service.MyService.Notify().GetSystemTempMap() {
|
|
||||||
data[k] = v
|
|
||||||
}
|
|
||||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,6 +311,7 @@ func GetSystemUtilization(c *gin.Context) {
|
|||||||
// @Success 200 {string} string "ok"
|
// @Success 200 {string} string "ok"
|
||||||
// @Router /sys/socket/port [get]
|
// @Router /sys/socket/port [get]
|
||||||
func GetSystemSocketPort(c *gin.Context) {
|
func GetSystemSocketPort(c *gin.Context) {
|
||||||
|
|
||||||
c.JSON(common_err.SUCCESS,
|
c.JSON(common_err.SUCCESS,
|
||||||
model.Result{
|
model.Result{
|
||||||
Success: common_err.SUCCESS,
|
Success: common_err.SUCCESS,
|
||||||
@@ -290,6 +334,7 @@ func GetSystemCupInfo(c *gin.Context) {
|
|||||||
data["percent"] = cpu
|
data["percent"] = cpu
|
||||||
data["num"] = num
|
data["num"] = num
|
||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary get mem info
|
// @Summary get mem info
|
||||||
@@ -302,6 +347,7 @@ func GetSystemCupInfo(c *gin.Context) {
|
|||||||
func GetSystemMemInfo(c *gin.Context) {
|
func GetSystemMemInfo(c *gin.Context) {
|
||||||
mem := service.MyService.System().GetMemInfo()
|
mem := service.MyService.System().GetMemInfo()
|
||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: mem})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: mem})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary get disk info
|
// @Summary get disk info
|
||||||
@@ -343,7 +389,7 @@ func GetSystemNetInfo(c *gin.Context) {
|
|||||||
|
|
||||||
func GetSystemProxy(c *gin.Context) {
|
func GetSystemProxy(c *gin.Context) {
|
||||||
url := c.Query("url")
|
url := c.Query("url")
|
||||||
resp, err := http2.Get(url, 30*time.Second)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -560,7 +560,6 @@ func (ds *dockerService) DockerContainerCreate(m model.CustomizationPostData, id
|
|||||||
//container, err := cli.ContainerCreate(context.Background(), info.Config, info.HostConfig, &network.NetworkingConfig{info.NetworkSettings.Networks}, nil, info.Name)
|
//container, err := cli.ContainerCreate(context.Background(), info.Config, info.HostConfig, &network.NetworkingConfig{info.NetworkSettings.Networks}, nil, info.Name)
|
||||||
|
|
||||||
hostConfig.Mounts = volumes
|
hostConfig.Mounts = volumes
|
||||||
hostConfig.Binds = []string{}
|
|
||||||
hostConfig.Privileged = m.Privileged
|
hostConfig.Privileged = m.Privileged
|
||||||
hostConfig.CapAdd = m.CapAdd
|
hostConfig.CapAdd = m.CapAdd
|
||||||
hostConfig.NetworkMode = container.NetworkMode(m.NetworkModel)
|
hostConfig.NetworkMode = container.NetworkMode(m.NetworkModel)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ type NotifyServer interface {
|
|||||||
SendStorageBySocket(message notify.StorageMessage)
|
SendStorageBySocket(message notify.StorageMessage)
|
||||||
SendNotify(path string, message map[string]interface{})
|
SendNotify(path string, message map[string]interface{})
|
||||||
SettingSystemTempData(message map[string]interface{})
|
SettingSystemTempData(message map[string]interface{})
|
||||||
GetSystemTempMap() map[string]interface{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type notifyServer struct {
|
type notifyServer struct {
|
||||||
@@ -443,11 +442,7 @@ func SendMeg() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// }
|
// }
|
||||||
func (i *notifyServer) GetSystemTempMap() map[string]interface{} {
|
|
||||||
|
|
||||||
return i.SystemTempMap
|
|
||||||
|
|
||||||
}
|
|
||||||
func NewNotifyService(db *gorm.DB) NotifyServer {
|
func NewNotifyService(db *gorm.DB) NotifyServer {
|
||||||
return ¬ifyServer{db: db, SystemTempMap: make(map[string]interface{})}
|
return ¬ifyServer{db: db, SystemTempMap: make(map[string]interface{})}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/IceWhaleTech/CasaOS-Common/external"
|
gateway "github.com/IceWhaleTech/CasaOS-Gateway/common"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/patrickmn/go-cache"
|
"github.com/patrickmn/go-cache"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@@ -35,12 +35,12 @@ type Repository interface {
|
|||||||
System() SystemService
|
System() SystemService
|
||||||
Shares() SharesService
|
Shares() SharesService
|
||||||
Connections() ConnectionsService
|
Connections() ConnectionsService
|
||||||
Gateway() external.ManagementService
|
Gateway() gateway.ManagementService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(db *gorm.DB, RuntimePath string) Repository {
|
func NewService(db *gorm.DB, RuntimePath string) Repository {
|
||||||
|
|
||||||
gatewayManagement, err := external.NewManagementService(RuntimePath)
|
gatewayManagement, err := gateway.NewManagementService(RuntimePath)
|
||||||
if err != nil && len(RuntimePath) > 0 {
|
if err != nil && len(RuntimePath) > 0 {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -68,10 +68,10 @@ type store struct {
|
|||||||
system SystemService
|
system SystemService
|
||||||
shares SharesService
|
shares SharesService
|
||||||
connections ConnectionsService
|
connections ConnectionsService
|
||||||
gateway external.ManagementService
|
gateway gateway.ManagementService
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *store) Gateway() external.ManagementService {
|
func (c *store) Gateway() gateway.ManagementService {
|
||||||
return c.gateway
|
return c.gateway
|
||||||
}
|
}
|
||||||
func (s *store) Connections() ConnectionsService {
|
func (s *store) Connections() ConnectionsService {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v3/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/disk"
|
"github.com/shirou/gopsutil/v3/disk"
|
||||||
"github.com/shirou/gopsutil/v3/host"
|
"github.com/shirou/gopsutil/v3/host"
|
||||||
@@ -31,6 +30,8 @@ type SystemService interface {
|
|||||||
UpdateAssist()
|
UpdateAssist()
|
||||||
UpSystemPort(port string)
|
UpSystemPort(port string)
|
||||||
GetTimeZone() string
|
GetTimeZone() string
|
||||||
|
UpdateUSBAutoMount(state string)
|
||||||
|
ExecUSBAutoMountShell(state string)
|
||||||
UpAppOrderFile(str, id string)
|
UpAppOrderFile(str, id string)
|
||||||
GetAppOrderFile(id string) []byte
|
GetAppOrderFile(id string) []byte
|
||||||
GetNet(physics bool) []string
|
GetNet(physics bool) []string
|
||||||
@@ -51,18 +52,16 @@ type SystemService interface {
|
|||||||
IsServiceRunning(name string) bool
|
IsServiceRunning(name string) bool
|
||||||
GetCPUTemperature() int
|
GetCPUTemperature() int
|
||||||
GetCPUPower() map[string]string
|
GetCPUPower() map[string]string
|
||||||
GetMacAddress() (string, error)
|
|
||||||
}
|
}
|
||||||
type systemService struct{}
|
type systemService struct {
|
||||||
|
}
|
||||||
|
|
||||||
func (c *systemService) GetMacAddress() (string, error) {
|
func (s *systemService) UpdateUSBAutoMount(state string) {
|
||||||
interfaces, err := net.Interfaces()
|
config.ServerInfo.USBAutoMount = state
|
||||||
if err != nil {
|
config.Cfg.Section("server").Key("USBAutoMount").SetValue(state)
|
||||||
return "", err
|
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
||||||
}
|
|
||||||
inter := interfaces[0]
|
|
||||||
return inter.HardwareAddr, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) MkdirAll(path string) (int, error) {
|
func (c *systemService) MkdirAll(path string) (int, error) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -77,8 +76,8 @@ func (c *systemService) MkdirAll(path string) (int, error) {
|
|||||||
}
|
}
|
||||||
return common_err.SERVICE_ERROR, err
|
return common_err.SERVICE_ERROR, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) RenameFile(oldF, newF string) (int, error) {
|
func (c *systemService) RenameFile(oldF, newF string) (int, error) {
|
||||||
|
|
||||||
_, err := os.Stat(newF)
|
_, err := os.Stat(newF)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return common_err.DIR_ALREADY_EXISTS, nil
|
return common_err.DIR_ALREADY_EXISTS, nil
|
||||||
@@ -93,7 +92,6 @@ func (c *systemService) RenameFile(oldF, newF string) (int, error) {
|
|||||||
}
|
}
|
||||||
return common_err.SERVICE_ERROR, err
|
return common_err.SERVICE_ERROR, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) CreateFile(path string) (int, error) {
|
func (c *systemService) CreateFile(path string) (int, error) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -106,11 +104,9 @@ func (c *systemService) CreateFile(path string) (int, error) {
|
|||||||
}
|
}
|
||||||
return common_err.SERVICE_ERROR, err
|
return common_err.SERVICE_ERROR, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) GetDeviceTree() string {
|
func (c *systemService) GetDeviceTree() string {
|
||||||
return command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetDeviceTree")
|
return command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetDeviceTree")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) GetSysInfo() host.InfoStat {
|
func (c *systemService) GetSysInfo() host.InfoStat {
|
||||||
info, _ := host.Info()
|
info, _ := host.Info()
|
||||||
return *info
|
return *info
|
||||||
@@ -132,7 +128,9 @@ func (c *systemService) GetNetState(name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) GetDirPathOne(path string) (m model.Path) {
|
func (c *systemService) GetDirPathOne(path string) (m model.Path) {
|
||||||
|
|
||||||
f, err := os.Stat(path)
|
f, err := os.Stat(path)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -177,7 +175,6 @@ func (c *systemService) GetDirPath(path string) []model.Path {
|
|||||||
}
|
}
|
||||||
return dirs
|
return dirs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) GetCpuInfo() []cpu.InfoStat {
|
func (c *systemService) GetCpuInfo() []cpu.InfoStat {
|
||||||
info, _ := cpu.Info()
|
info, _ := cpu.Info()
|
||||||
return info
|
return info
|
||||||
@@ -210,7 +207,6 @@ func (c *systemService) GetNetInfo() []net.IOCountersStat {
|
|||||||
parts, _ := net.IOCounters(true)
|
parts, _ := net.IOCounters(true)
|
||||||
return parts
|
return parts
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *systemService) GetNet(physics bool) []string {
|
func (c *systemService) GetNet(physics bool) []string {
|
||||||
t := "1"
|
t := "1"
|
||||||
if physics {
|
if physics {
|
||||||
@@ -225,16 +221,10 @@ func (s *systemService) UpdateSystemVersion(version string) {
|
|||||||
}
|
}
|
||||||
file.CreateFile(config.AppInfo.LogPath + "/upgrade.log")
|
file.CreateFile(config.AppInfo.LogPath + "/upgrade.log")
|
||||||
//go command2.OnlyExec("curl -fsSL https://raw.githubusercontent.com/LinkLeong/casaos-alpha/main/update.sh | bash")
|
//go command2.OnlyExec("curl -fsSL https://raw.githubusercontent.com/LinkLeong/casaos-alpha/main/update.sh | bash")
|
||||||
if len(config.ServerInfo.UpdateUrl) > 0 {
|
go command2.OnlyExec("curl -fsSL https://raw.githubusercontent.com/IceWhaleTech/get/main/update.sh | sudo bash")
|
||||||
go command2.OnlyExec("curl -fsSL " + config.ServerInfo.UpdateUrl + " | bash")
|
|
||||||
} else {
|
|
||||||
go command2.OnlyExec("curl -fsSL https://raw.githubusercontent.com/IceWhaleTech/get/main/update.sh | bash")
|
|
||||||
}
|
|
||||||
|
|
||||||
//s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
//s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
||||||
//s.log.Error(command2.ExecResultStr(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version))
|
//s.log.Error(command2.ExecResultStr(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) UpdateAssist() {
|
func (s *systemService) UpdateAssist() {
|
||||||
command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/assist.sh")
|
command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/assist.sh")
|
||||||
}
|
}
|
||||||
@@ -243,6 +233,14 @@ func (s *systemService) GetTimeZone() string {
|
|||||||
return command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetTimeZone")
|
return command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetTimeZone")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *systemService) ExecUSBAutoMountShell(state string) {
|
||||||
|
if state == "False" {
|
||||||
|
command2.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;USB_Stop_Auto")
|
||||||
|
} else {
|
||||||
|
command2.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;USB_Start_Auto")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *systemService) GetSystemConfigDebug() []string {
|
func (s *systemService) GetSystemConfigDebug() []string {
|
||||||
return command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;GetSysInfo")
|
return command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;GetSysInfo")
|
||||||
}
|
}
|
||||||
@@ -250,11 +248,9 @@ func (s *systemService) GetSystemConfigDebug() []string {
|
|||||||
func (s *systemService) UpAppOrderFile(str, id string) {
|
func (s *systemService) UpAppOrderFile(str, id string) {
|
||||||
file.WriteToPath([]byte(str), config.AppInfo.DBPath+"/"+id, "app_order.json")
|
file.WriteToPath([]byte(str), config.AppInfo.DBPath+"/"+id, "app_order.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) GetAppOrderFile(id string) []byte {
|
func (s *systemService) GetAppOrderFile(id string) []byte {
|
||||||
return file.ReadFullFile(config.AppInfo.UserDataPath + "/" + id + "/app_order.json")
|
return file.ReadFullFile(config.AppInfo.UserDataPath + "/" + id + "/app_order.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) UpSystemPort(port string) {
|
func (s *systemService) UpSystemPort(port string) {
|
||||||
if len(port) > 0 && port != config.ServerInfo.HttpPort {
|
if len(port) > 0 && port != config.ServerInfo.HttpPort {
|
||||||
config.Cfg.Section("server").Key("HttpPort").SetValue(port)
|
config.Cfg.Section("server").Key("HttpPort").SetValue(port)
|
||||||
@@ -262,7 +258,6 @@ func (s *systemService) UpSystemPort(port string) {
|
|||||||
}
|
}
|
||||||
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) GetCasaOSLogs(lineNumber int) string {
|
func (s *systemService) GetCasaOSLogs(lineNumber int) string {
|
||||||
file, err := os.Open(filepath.Join(config.AppInfo.LogPath, fmt.Sprintf("%s.%s",
|
file, err := os.Open(filepath.Join(config.AppInfo.LogPath, fmt.Sprintf("%s.%s",
|
||||||
config.AppInfo.LogSaveName,
|
config.AppInfo.LogSaveName,
|
||||||
@@ -299,48 +294,14 @@ func GetDeviceAllIP() []string {
|
|||||||
func (s *systemService) IsServiceRunning(name string) bool {
|
func (s *systemService) IsServiceRunning(name string) bool {
|
||||||
status := command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;CheckServiceStatus smbd")
|
status := command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;CheckServiceStatus smbd")
|
||||||
return strings.TrimSpace(status) == "running"
|
return strings.TrimSpace(status) == "running"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// find thermal_zone of cpu.
|
|
||||||
// assertions:
|
|
||||||
// * thermal_zone "type" and "temp" are required fields
|
|
||||||
// (https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-thermal)
|
|
||||||
func GetCPUThermalZone() string {
|
|
||||||
keyName := "cpu_thermal_zone"
|
|
||||||
|
|
||||||
var path string
|
|
||||||
if result, ok := Cache.Get(keyName); ok {
|
|
||||||
path, ok = result.(string)
|
|
||||||
if ok {
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
|
||||||
path := "/sys/devices/virtual/thermal/thermal_zone" + strconv.Itoa(i)
|
|
||||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
|
||||||
name := strings.TrimSuffix(string(file.ReadFullFile(path + "/type")), "\n")
|
|
||||||
cpu_types := []string{"x86_pkg_temp", "cpu", "CPU", "soc"}
|
|
||||||
for _, s := range cpu_types {
|
|
||||||
if strings.HasPrefix(name, s) {
|
|
||||||
loger.Info(fmt.Sprintf("CPU thermal zone found: %s, path: %s.", name, path))
|
|
||||||
Cache.SetDefault(keyName, path)
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loger.Error("CPUThermalZone not found. CPU Temp will not be displayed.")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *systemService) GetCPUTemperature() int {
|
func (s *systemService) GetCPUTemperature() int {
|
||||||
outPut := ""
|
outPut := ""
|
||||||
path := GetCPUThermalZone()
|
if file.Exists("/sys/class/thermal/thermal_zone0/temp") {
|
||||||
if len(path)>0 {
|
outPut = string(file.ReadFullFile("/sys/class/thermal/thermal_zone0/temp"))
|
||||||
outPut = string(file.ReadFullFile(path + "/temp"))
|
} else if file.Exists("/sys/class/hwmon/hwmon0/temp1_input") {
|
||||||
|
outPut = string(file.ReadFullFile("/sys/class/hwmon/hwmon0/temp1_input"))
|
||||||
} else {
|
} else {
|
||||||
outPut = "0"
|
outPut = "0"
|
||||||
}
|
}
|
||||||
@@ -352,7 +313,6 @@ func (s *systemService) GetCPUTemperature() int {
|
|||||||
}
|
}
|
||||||
return celsius
|
return celsius
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) GetCPUPower() map[string]string {
|
func (s *systemService) GetCPUPower() map[string]string {
|
||||||
data := make(map[string]string, 2)
|
data := make(map[string]string, 2)
|
||||||
data["timestamp"] = strconv.FormatInt(time.Now().Unix(), 10)
|
data["timestamp"] = strconv.FormatInt(time.Now().Unix(), 10)
|
||||||
@@ -363,7 +323,6 @@ func (s *systemService) GetCPUPower() map[string]string {
|
|||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSystemService() SystemService {
|
func NewSystemService() SystemService {
|
||||||
return &systemService{}
|
return &systemService{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,3 @@
|
|||||||
/*
|
|
||||||
* @Author: LinkLeong link@icewhale.org
|
|
||||||
* @Date: 2022-11-15 15:51:44
|
|
||||||
* @LastEditors: LinkLeong
|
|
||||||
* @LastEditTime: 2022-11-15 15:56:03
|
|
||||||
* @FilePath: /CasaOS/types/system.go
|
|
||||||
* @Description:
|
|
||||||
* @Website: https://www.casaos.io
|
|
||||||
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
|
||||||
*/
|
|
||||||
/*@Author: LinkLeong link@icewhale.com
|
/*@Author: LinkLeong link@icewhale.com
|
||||||
*@Date: 2022-02-17 18:53:22
|
*@Date: 2022-02-17 18:53:22
|
||||||
*@LastEditors: LinkLeong
|
*@LastEditors: LinkLeong
|
||||||
@@ -19,6 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
package types
|
package types
|
||||||
|
|
||||||
const CURRENTVERSION = "0.3.8"
|
const CURRENTVERSION = "0.3.7"
|
||||||
|
|
||||||
const BODY = " "
|
const BODY = " "
|
||||||
|
|||||||
Reference in New Issue
Block a user