continue beOS rebrand and add native verification
Some checks failed
Native Verification / Build Docs (pull_request) Successful in 1m12s
Native Verification / Build App-Service Native (pull_request) Successful in 1m27s
Native Verification / Build Daemon Native (pull_request) Successful in 42s
Lint and Test Charts / lint-test (pull_request_target) Failing after 19s
Lint and Test Charts / test-version (pull_request_target) Successful in 0s
Lint and Test Charts / push-image (pull_request_target) Failing after 15s
Lint and Test Charts / upload-cli (pull_request_target) Failing after 1m15s
Lint and Test Charts / upload-daemon (pull_request_target) Failing after 1m12s
Lint and Test Charts / push-deps (pull_request_target) Has been skipped
Lint and Test Charts / push-deps-arm64 (pull_request_target) Has been skipped
Lint and Test Charts / push-image-arm64 (pull_request_target) Has been cancelled
Lint and Test Charts / upload-package (pull_request_target) Has been cancelled
Lint and Test Charts / install-test (pull_request_target) Has been cancelled
Some checks failed
Native Verification / Build Docs (pull_request) Successful in 1m12s
Native Verification / Build App-Service Native (pull_request) Successful in 1m27s
Native Verification / Build Daemon Native (pull_request) Successful in 42s
Lint and Test Charts / lint-test (pull_request_target) Failing after 19s
Lint and Test Charts / test-version (pull_request_target) Successful in 0s
Lint and Test Charts / push-image (pull_request_target) Failing after 15s
Lint and Test Charts / upload-cli (pull_request_target) Failing after 1m15s
Lint and Test Charts / upload-daemon (pull_request_target) Failing after 1m12s
Lint and Test Charts / push-deps (pull_request_target) Has been skipped
Lint and Test Charts / push-deps-arm64 (pull_request_target) Has been skipped
Lint and Test Charts / push-image-arm64 (pull_request_target) Has been cancelled
Lint and Test Charts / upload-package (pull_request_target) Has been cancelled
Lint and Test Charts / install-test (pull_request_target) Has been cancelled
This commit is contained in:
85
.gitea/workflows/native-verification.yaml
Normal file
85
.gitea/workflows/native-verification.yaml
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
name: Native Verification
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- release-*
|
||||||
|
paths:
|
||||||
|
- .gitea/workflows/native-verification.yaml
|
||||||
|
- daemon/**
|
||||||
|
- framework/app-service/**
|
||||||
|
- docs/**
|
||||||
|
- build/verify-native-in-container.sh
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- .gitea/workflows/native-verification.yaml
|
||||||
|
- daemon/**
|
||||||
|
- framework/app-service/**
|
||||||
|
- docs/**
|
||||||
|
- build/verify-native-in-container.sh
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docs-build:
|
||||||
|
name: Build Docs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: docs
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install docs dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build docs
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
appservice-native-build:
|
||||||
|
name: Build App-Service Native
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24.11'
|
||||||
|
|
||||||
|
- name: Install native dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y btrfs-progs libbtrfs-dev
|
||||||
|
|
||||||
|
- name: Build app-service
|
||||||
|
run: go build ./...
|
||||||
|
working-directory: framework/app-service
|
||||||
|
|
||||||
|
daemon-native-build:
|
||||||
|
name: Build Daemon Native
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24.11'
|
||||||
|
|
||||||
|
- name: Install native dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libudev-dev libpcap-dev
|
||||||
|
|
||||||
|
- name: Build daemon
|
||||||
|
run: go build ./cmd/...
|
||||||
|
working-directory: daemon
|
||||||
@@ -24,9 +24,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y btrfs-progs libbtrfs-dev
|
sudo apt-get install -y btrfs-progs libbtrfs-dev
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: '1.24.6'
|
go-version: '1.24.11'
|
||||||
- run: make build
|
- run: make build
|
||||||
working-directory: framework/app-service
|
working-directory: framework/app-service
|
||||||
|
|||||||
88
.github/workflows/native-verification.yaml
vendored
Normal file
88
.github/workflows/native-verification.yaml
vendored
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
name: Native Verification
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- 'release-*'
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/native-verification.yaml'
|
||||||
|
- 'daemon/**'
|
||||||
|
- 'framework/app-service/**'
|
||||||
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/native-verification.yaml'
|
||||||
|
- 'daemon/**'
|
||||||
|
- 'framework/app-service/**'
|
||||||
|
- 'docs/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docs-build:
|
||||||
|
name: Build Docs
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: docs
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: docs/package-lock.json
|
||||||
|
|
||||||
|
- name: Install docs dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build docs
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
appservice-native-build:
|
||||||
|
name: Build App-Service Native
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24.11'
|
||||||
|
|
||||||
|
- name: Install native dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y btrfs-progs libbtrfs-dev
|
||||||
|
|
||||||
|
- name: Build app-service
|
||||||
|
run: go build ./...
|
||||||
|
working-directory: framework/app-service
|
||||||
|
|
||||||
|
daemon-native-build:
|
||||||
|
name: Build Daemon Native
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24.11'
|
||||||
|
|
||||||
|
- name: Install native dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libudev-dev libpcap-dev
|
||||||
|
|
||||||
|
- name: Build daemon
|
||||||
|
run: go build ./cmd/...
|
||||||
|
working-directory: daemon
|
||||||
@@ -35,11 +35,15 @@ if [[ "${REPO_PATH}" != "" && "$REPO_PATH" != "/" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
find $BASE_DIR/../ -type f -name Olares.yaml | while read f; do
|
find $BASE_DIR/../ -type f \( -name BeOS.yaml -o -name Olares.yaml \) | while read f; do
|
||||||
if [[ "$f" == *"/vendor/"* ]]; then
|
if [[ "$f" == *"/vendor/"* ]]; then
|
||||||
echo "skip vendor file $f"
|
echo "skip vendor file $f"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
if [[ "$f" == *"/Olares.yaml"* && -f "${f%Olares.yaml}BeOS.yaml" ]]; then
|
||||||
|
echo "skip legacy manifest $f"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
echo "Processing $f"
|
echo "Processing $f"
|
||||||
declare -a bins
|
declare -a bins
|
||||||
IFS=
|
IFS=
|
||||||
|
|||||||
68
build/verify-native-in-container.sh
Executable file
68
build/verify-native-in-container.sh
Executable file
@@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||||
|
|
||||||
|
require_docker() {
|
||||||
|
if ! command -v docker >/dev/null 2>&1; then
|
||||||
|
echo "docker is required" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_docs() {
|
||||||
|
echo "==> Building docs in container"
|
||||||
|
docker run --rm \
|
||||||
|
-v "$ROOT_DIR/docs":/src:ro \
|
||||||
|
node:20-bookworm \
|
||||||
|
bash -lc 'cp -a /src /tmp/docs && cd /tmp/docs && npm ci && npm run build'
|
||||||
|
}
|
||||||
|
|
||||||
|
run_appservice() {
|
||||||
|
echo "==> Building app-service in container"
|
||||||
|
docker run --rm \
|
||||||
|
-v "$ROOT_DIR":/src:ro \
|
||||||
|
-w /src/framework/app-service \
|
||||||
|
golang:1.24-bookworm \
|
||||||
|
bash -lc 'export PATH=/usr/local/go/bin:$PATH GOFLAGS=-buildvcs=false && apt-get update && apt-get install -y btrfs-progs libbtrfs-dev && go build ./...'
|
||||||
|
}
|
||||||
|
|
||||||
|
run_daemon() {
|
||||||
|
echo "==> Building daemon in container"
|
||||||
|
docker run --rm \
|
||||||
|
-v "$ROOT_DIR":/src:ro \
|
||||||
|
-w /src/daemon \
|
||||||
|
golang:1.24-bookworm \
|
||||||
|
bash -lc 'export PATH=/usr/local/go/bin:$PATH GOFLAGS=-buildvcs=false && apt-get update && apt-get install -y libudev-dev libpcap-dev && go build ./cmd/...'
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
require_docker
|
||||||
|
|
||||||
|
local targets=("$@")
|
||||||
|
if [ ${#targets[@]} -eq 0 ] || { [ ${#targets[@]} -eq 1 ] && [ "${targets[0]}" = "all" ]; }; then
|
||||||
|
targets=(docs app-service daemon)
|
||||||
|
fi
|
||||||
|
|
||||||
|
local target
|
||||||
|
for target in "${targets[@]}"; do
|
||||||
|
case "$target" in
|
||||||
|
docs)
|
||||||
|
run_docs
|
||||||
|
;;
|
||||||
|
app-service|appservice)
|
||||||
|
run_appservice
|
||||||
|
;;
|
||||||
|
daemon)
|
||||||
|
run_daemon
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown target: $target" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
project_name: olares-cli
|
project_name: beos-cli
|
||||||
builds:
|
builds:
|
||||||
- env:
|
- env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
binary: olares-cli
|
binary: beos-cli
|
||||||
main: ./cmd/main.go
|
main: ./cmd/main.go
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
@@ -26,14 +26,14 @@ builds:
|
|||||||
ldflags:
|
ldflags:
|
||||||
- -s
|
- -s
|
||||||
- -w
|
- -w
|
||||||
- -X github.com/beclab/Olares/cli/version.VERSION={{ .Version }}
|
- -X github.com/beclab/beOS Pro/cli/version.VERSION={{ .Version }}
|
||||||
- >-
|
- >-
|
||||||
{{- if index .Env "OLARES_VENDOR_TYPE" }}
|
{{- if index .Env "OLARES_VENDOR_TYPE" }}
|
||||||
-X github.com/beclab/Olares/cli/version.VENDOR={{ .Env.OLARES_VENDOR_TYPE }}
|
-X github.com/beclab/beOS Pro/cli/version.VENDOR={{ .Env.OLARES_VENDOR_TYPE }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
- >-
|
- >-
|
||||||
{{- if index .Env "OLARES_VENDOR_REPO_PATH" }}
|
{{- if index .Env "OLARES_VENDOR_REPO_PATH" }}
|
||||||
-X github.com/beclab/Olares/cli/version.VENDOR_REPO_PATH={{ .Env.OLARES_VENDOR_REPO_PATH }}
|
-X github.com/beclab/beOS Pro/cli/version.VENDOR_REPO_PATH={{ .Env.OLARES_VENDOR_REPO_PATH }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
dist: ./output
|
dist: ./output
|
||||||
archives:
|
archives:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func AddVersionFlagBy(flagSetter CommandFlagSetter) {
|
|||||||
flagSetter.Add(common.FlagVersion,
|
flagSetter.Add(common.FlagVersion,
|
||||||
"v",
|
"v",
|
||||||
version.VERSION,
|
version.VERSION,
|
||||||
"Set Olares version, e.g., 1.10.0, 1.10.0-20241109",
|
"Set beOS version, e.g., 1.10.0, 1.10.0-20241109",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ func AddBaseDirFlagBy(flagSetter CommandFlagSetter) {
|
|||||||
flagSetter.Add(common.FlagBaseDir,
|
flagSetter.Add(common.FlagBaseDir,
|
||||||
"b",
|
"b",
|
||||||
"",
|
"",
|
||||||
"Set Olares package base dir, defaults to $HOME/"+cc.DefaultBaseDir,
|
"Set beOS package base dir, defaults to $HOME/"+cc.DefaultBaseDir,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +60,8 @@ func AddKubeTypeFlagBy(flagSetter CommandFlagSetter) {
|
|||||||
func AddCDNServiceFlagBy(flagSetter CommandFlagSetter) {
|
func AddCDNServiceFlagBy(flagSetter CommandFlagSetter) {
|
||||||
flagSetter.Add(common.FlagCDNService,
|
flagSetter.Add(common.FlagCDNService,
|
||||||
"",
|
"",
|
||||||
cc.DefaultOlaresCDNService,
|
cc.DefaultBeOSCDNService,
|
||||||
"Set the CDN accelerated download address in the format https://cdn.olares.cn. If not set, the default download address will be used",
|
"Set an optional CDN download address in the format https://cdn.example.com. If not set, configured defaults will be used",
|
||||||
).WithEnv(common.ENV_OLARES_CDN_SERVICE)
|
).WithEnv(common.ENV_OLARES_CDN_SERVICE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
// 2) Enable viper to read environment variables
|
// 2) Enable viper to read environment variables
|
||||||
// 3) Bind environment variables for all known keys we care about
|
// 3) Bind environment variables for all known keys we care about
|
||||||
func Init() {
|
func Init() {
|
||||||
godotenv.Load(common.OlaresReleaseFile)
|
godotenv.Load(common.BeOSReleaseFile)
|
||||||
viper.SetEnvPrefix("OLARES")
|
viper.SetEnvPrefix("OLARES")
|
||||||
viper.SetEnvKeyReplacer(envKeyReplacer)
|
viper.SetEnvKeyReplacer(envKeyReplacer)
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|||||||
@@ -12,5 +12,3 @@ func NewCmdAmdGpu() *cobra.Command {
|
|||||||
cmd.AddCommand(NewCmdAmdGpuStatus())
|
cmd.AddCommand(NewCmdAmdGpuStatus())
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultOlaresVGName = "olares-vg"
|
const defaultBeOSVGName = "beos-vg"
|
||||||
|
|
||||||
func NewExtendDiskCommand() *cobra.Command {
|
func NewExtendDiskCommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
@@ -196,7 +196,7 @@ func selectExtendingLV(vgName string, lvs []*lvm.LvItem) (string, error) {
|
|||||||
return lvs[0].LvName, nil
|
return lvs[0].LvName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if vgName == defaultOlaresVGName {
|
if vgName == defaultBeOSVGName {
|
||||||
selectedLv := ""
|
selectedLv := ""
|
||||||
for _, lv := range lvs {
|
for _, lv := range lvs {
|
||||||
if lv.LvName == "root" {
|
if lv.LvName == "root" {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
func NewCmdDisableGpu() *cobra.Command {
|
func NewCmdDisableGpu() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "disable",
|
Use: "disable",
|
||||||
Short: "Disable GPU drivers for Olares node",
|
Short: "Disable GPU drivers for beOS node",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.DisableGpuNode(); err != nil {
|
if err := pipelines.DisableGpuNode(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
|
|||||||
@@ -19,5 +19,3 @@ func NewCmdDisableNouveau() *cobra.Command {
|
|||||||
}
|
}
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
func NewCmdEnableGpu() *cobra.Command {
|
func NewCmdEnableGpu() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "enable",
|
Use: "enable",
|
||||||
Short: "Enable GPU drivers for Olares node",
|
Short: "Enable GPU drivers for beOS node",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.EnableGpuNode(); err != nil {
|
if err := pipelines.EnableGpuNode(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
func NewCmdInstallGpu() *cobra.Command {
|
func NewCmdInstallGpu() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "install",
|
Use: "install",
|
||||||
Short: "Install GPU drivers for Olares",
|
Short: "Install GPU drivers for beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.InstallGpuDrivers(); err != nil {
|
if err := pipelines.InstallGpuDrivers(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
func NewCmdUninstallpu() *cobra.Command {
|
func NewCmdUninstallpu() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "uninstall",
|
Use: "uninstall",
|
||||||
Short: "uninstall GPU drivers for Olares",
|
Short: "uninstall GPU drivers for beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.UninstallGpuDrivers(); err != nil {
|
if err := pipelines.UninstallGpuDrivers(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
func NewCmdChangeIP() *cobra.Command {
|
func NewCmdChangeIP() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "change-ip",
|
Use: "change-ip",
|
||||||
Short: "change The IP address of Olares OS",
|
Short: "change The IP address of beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.ChangeIPPipeline(); err != nil {
|
if err := pipelines.ChangeIPPipeline(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
func NewCmdRootDownload() *cobra.Command {
|
func NewCmdRootDownload() *cobra.Command {
|
||||||
rootDownloadCmd := &cobra.Command{
|
rootDownloadCmd := &cobra.Command{
|
||||||
Use: "download",
|
Use: "download",
|
||||||
Short: "Download the packages and components needed to install Olares",
|
Short: "Download the packages and components needed to install beOS Pro",
|
||||||
}
|
}
|
||||||
|
|
||||||
rootDownloadCmd.AddCommand(NewCmdCheckDownload())
|
rootDownloadCmd.AddCommand(NewCmdCheckDownload())
|
||||||
@@ -25,7 +25,7 @@ func NewCmdRootDownload() *cobra.Command {
|
|||||||
func NewCmdDownload() *cobra.Command {
|
func NewCmdDownload() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "component",
|
Use: "component",
|
||||||
Short: "Download the packages and components needed to install Olares",
|
Short: "Download the packages and components needed to install beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
if err := pipelines.DownloadInstallationPackage(); err != nil {
|
if err := pipelines.DownloadInstallationPackage(); err != nil {
|
||||||
@@ -45,7 +45,7 @@ func NewCmdDownload() *cobra.Command {
|
|||||||
func NewCmdDownloadWizard() *cobra.Command {
|
func NewCmdDownloadWizard() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "wizard",
|
Use: "wizard",
|
||||||
Short: "Download the Olares installation wizard",
|
Short: "Download the beOS installation wizard",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
if err := pipelines.DownloadInstallationWizard(); err != nil {
|
if err := pipelines.DownloadInstallationWizard(); err != nil {
|
||||||
@@ -67,7 +67,7 @@ func NewCmdDownloadWizard() *cobra.Command {
|
|||||||
func NewCmdCheckDownload() *cobra.Command {
|
func NewCmdCheckDownload() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "check",
|
Use: "check",
|
||||||
Short: "Check Downloaded Olares Installation Package",
|
Short: "Check Downloaded beOS Pro Installation Package",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
if err := pipelines.CheckDownloadInstallationPackage(); err != nil {
|
if err := pipelines.CheckDownloadInstallationPackage(); err != nil {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
func NewCmdPrintInfo() *cobra.Command {
|
func NewCmdPrintInfo() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "info",
|
Use: "info",
|
||||||
Short: "Print Olares info",
|
Short: "Print beOS Pro info",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
pipelines.PrintTerminusInfo()
|
pipelines.PrintTerminusInfo()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
func NewCmdInstallOs() *cobra.Command {
|
func NewCmdInstallOs() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "install",
|
Use: "install",
|
||||||
Short: "Install Olares",
|
Short: "Install beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.CliInstallTerminusPipeline(); err != nil {
|
if err := pipelines.CliInstallTerminusPipeline(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
@@ -23,17 +23,17 @@ func NewCmdInstallOs() *cobra.Command {
|
|||||||
flagSetter.Add(common.FlagOSUserName,
|
flagSetter.Add(common.FlagOSUserName,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"Set the username for the Olares instance, if not set, will be prompted for input",
|
"Set the username for the beOS Pro instance, if not set, will be prompted for input",
|
||||||
).WithEnv(common.EnvLegacyOSUserName)
|
).WithEnv(common.EnvLegacyOSUserName)
|
||||||
flagSetter.Add(common.FlagOSDomainName,
|
flagSetter.Add(common.FlagOSDomainName,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"Set the domain name for the Olares instance, if not set, will be prompted for input",
|
"Set the domain name for the beOS Pro instance, if not set, will be prompted for input",
|
||||||
).WithEnv(common.EnvLegacyOSDomainName)
|
).WithEnv(common.EnvLegacyOSDomainName)
|
||||||
flagSetter.Add(common.FlagOSPassword,
|
flagSetter.Add(common.FlagOSPassword,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"Set the inital password for the first user of the Olares instance, if not set, a randomly generated password will be used",
|
"Set the inital password for the first user of the beOS Pro instance, if not set, a randomly generated password will be used",
|
||||||
)
|
)
|
||||||
flagSetter.Add(common.FlagEnableReverseProxy,
|
flagSetter.Add(common.FlagEnableReverseProxy,
|
||||||
"",
|
"",
|
||||||
@@ -43,7 +43,7 @@ func NewCmdInstallOs() *cobra.Command {
|
|||||||
flagSetter.Add(common.FlagEnableJuiceFS,
|
flagSetter.Add(common.FlagEnableJuiceFS,
|
||||||
"",
|
"",
|
||||||
false,
|
false,
|
||||||
"Use JuiceFS as the rootfs for Olares workloads, rather than the local disk.",
|
"Use JuiceFS as the rootfs for beOS workloads, rather than the local disk.",
|
||||||
).WithAlias(common.FlagLegacyEnableJuiceFS).WithEnv(common.EnvLegacyEnableJuiceFS)
|
).WithAlias(common.FlagLegacyEnableJuiceFS).WithEnv(common.EnvLegacyEnableJuiceFS)
|
||||||
flagSetter.Add(common.FlagEnablePodSwap,
|
flagSetter.Add(common.FlagEnablePodSwap,
|
||||||
"",
|
"",
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ type LogCollectOptions struct {
|
|||||||
SkipKubeAPISserver bool
|
SkipKubeAPISserver bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var servicesToCollectLogs = []string{"k3s", "containerd", "olaresd", "kubelet", "juicefs", "redis", "minio", "etcd", "NetworkManager"}
|
var servicesToCollectLogs = []string{"k3s", "containerd", "beosd", "olaresd", "kubelet", "juicefs", "redis", "minio", "etcd", "NetworkManager"}
|
||||||
|
|
||||||
// setSkipIfK8sNotReachable checks if the Kubernetes API server port is reachable
|
// setSkipIfK8sNotReachable checks if the Kubernetes API server port is reachable
|
||||||
// and automatically sets skip-kube-apiserver to true if not reachable
|
// and automatically sets skip-kube-apiserver to true if not reachable
|
||||||
@@ -124,9 +124,9 @@ func collectLogs(options *LogCollectOptions) error {
|
|||||||
return fmt.Errorf("failed to collect kubernetes logs: %v", err)
|
return fmt.Errorf("failed to collect kubernetes logs: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("collecting olares-cli logs...")
|
fmt.Println("collecting beos-cli logs...")
|
||||||
if err := collectOlaresCLILogs(tw, options); err != nil {
|
if err := collectBeOSCLILogs(tw, options); err != nil {
|
||||||
return fmt.Errorf("failed to collect OlaresCLI logs: %v", err)
|
return fmt.Errorf("failed to collect BeOSCLI logs: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("collecting network configs...")
|
fmt.Println("collecting network configs...")
|
||||||
@@ -138,14 +138,14 @@ func collectLogs(options *LogCollectOptions) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectOlaresCLILogs(tw *tar.Writer, options *LogCollectOptions) error {
|
func collectBeOSCLILogs(tw *tar.Writer, options *LogCollectOptions) error {
|
||||||
basedir, err := getBaseDir()
|
basedir, err := getBaseDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cliLogDir := filepath.Join(basedir, "logs")
|
cliLogDir := filepath.Join(basedir, "logs")
|
||||||
if _, err := os.Stat(cliLogDir); err != nil {
|
if _, err := os.Stat(cliLogDir); err != nil {
|
||||||
fmt.Printf("warning: directory %s does not exist, skipping collecting olares-cli logs\n", cliLogDir)
|
fmt.Printf("warning: directory %s does not exist, skipping collecting beos-cli logs\n", cliLogDir)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err = filepath.Walk(cliLogDir, func(path string, info os.FileInfo, err error) error {
|
err = filepath.Walk(cliLogDir, func(path string, info os.FileInfo, err error) error {
|
||||||
@@ -169,7 +169,7 @@ func collectOlaresCLILogs(tw *tar.Writer, options *LogCollectOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
header := &tar.Header{
|
header := &tar.Header{
|
||||||
Name: filepath.Join("olares-cli", relPath),
|
Name: filepath.Join("beos-cli", relPath),
|
||||||
Mode: 0644,
|
Mode: 0644,
|
||||||
Size: info.Size(),
|
Size: info.Size(),
|
||||||
ModTime: info.ModTime(),
|
ModTime: info.ModTime(),
|
||||||
@@ -185,7 +185,7 @@ func collectOlaresCLILogs(tw *tar.Writer, options *LogCollectOptions) error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect olares-cli logs from %s: %v", cliLogDir, err)
|
return fmt.Errorf("failed to collect beos-cli logs from %s: %v", cliLogDir, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -652,16 +652,16 @@ func NewCmdLogs() *cobra.Command {
|
|||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "logs",
|
Use: "logs",
|
||||||
Short: "Collect logs from all Olares system components",
|
Short: "Collect logs from all beOS Pro system components",
|
||||||
Long: `Collect logs from various Olares system components, that may or may not be installed on this machine, including:
|
Long: `Collect logs from various beOS Pro system components, that may or may not be installed on this machine, including:
|
||||||
- K3s/Kubelet logs
|
- K3s/Kubelet logs
|
||||||
- Containerd logs
|
- Containerd logs
|
||||||
- JuiceFS logs
|
- JuiceFS logs
|
||||||
- Redis logs
|
- Redis logs
|
||||||
- MinIO logs
|
- MinIO logs
|
||||||
- etcd logs
|
- etcd logs
|
||||||
- Olaresd logs
|
- BeOSd logs
|
||||||
- olares-cli logs
|
- beos-cli logs
|
||||||
- network configurations
|
- network configurations
|
||||||
- Kubernetes pod info and logs
|
- Kubernetes pod info and logs
|
||||||
- Kubernetes node info`,
|
- Kubernetes node info`,
|
||||||
@@ -675,7 +675,7 @@ func NewCmdLogs() *cobra.Command {
|
|||||||
cmd.Flags().StringVar(&options.Since, "since", options.Since, "Only return logs newer than a relative duration like 5s, 2m, or 3h, to limit the log file")
|
cmd.Flags().StringVar(&options.Since, "since", options.Since, "Only return logs newer than a relative duration like 5s, 2m, or 3h, to limit the log file")
|
||||||
cmd.Flags().IntVar(&options.MaxLines, "max-lines", options.MaxLines, "Maximum number of lines to collect per log source, to limit the log file size")
|
cmd.Flags().IntVar(&options.MaxLines, "max-lines", options.MaxLines, "Maximum number of lines to collect per log source, to limit the log file size")
|
||||||
cmd.Flags().StringVar(&options.OutputDir, "output-dir", options.OutputDir, "Directory to store collected logs, will be created if not existing")
|
cmd.Flags().StringVar(&options.OutputDir, "output-dir", options.OutputDir, "Directory to store collected logs, will be created if not existing")
|
||||||
cmd.Flags().StringSliceVar(&options.Components, "components", nil, "Specific components (systemd service) to collect logs from (comma-separated). If empty, collects from all Olares-related components that can be found")
|
cmd.Flags().StringSliceVar(&options.Components, "components", nil, "Specific components (systemd service) to collect logs from (comma-separated). If empty, collects from all beOS-related components that can be found")
|
||||||
cmd.Flags().BoolVar(&options.IgnoreKubeErrors, "ignore-kube-errors", options.IgnoreKubeErrors, "Continue collecting logs even if kubectl commands fail")
|
cmd.Flags().BoolVar(&options.IgnoreKubeErrors, "ignore-kube-errors", options.IgnoreKubeErrors, "Continue collecting logs even if kubectl commands fail")
|
||||||
cmd.Flags().BoolVar(&options.SkipKubeAPISserver, "skip-kube-apiserver", options.SkipKubeAPISserver, "Skip retrieving logs from kube-apiserver, it's automatically set if apiserver is not reachable. To tolerate other cases, set the ignore-kube-errors")
|
cmd.Flags().BoolVar(&options.SkipKubeAPISserver, "skip-kube-apiserver", options.SkipKubeAPISserver, "Skip retrieving logs from kube-apiserver, it's automatically set if apiserver is not reachable. To tolerate other cases, set the ignore-kube-errors")
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
func NewCmdRelease() *cobra.Command {
|
func NewCmdRelease() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "release",
|
Use: "release",
|
||||||
Short: "Build release based on a local Olares repository",
|
Short: "Build release based on a local beOS repository",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
baseDir := viper.GetString(common.FlagBaseDir)
|
baseDir := viper.GetString(common.FlagBaseDir)
|
||||||
version := viper.GetString(common.FlagVersion)
|
version := viper.GetString(common.FlagVersion)
|
||||||
@@ -35,7 +35,7 @@ func NewCmdRelease() *cobra.Command {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(strings.ToLower(filepath.Base(cwd)), "olares") {
|
if !strings.HasPrefix(strings.ToLower(filepath.Base(cwd)), "olares") {
|
||||||
fmt.Println("error: please run release command under the root path of Olares repo")
|
fmt.Println("error: please run release command under the root path of beOS repo")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if baseDir == "" {
|
if baseDir == "" {
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import (
|
|||||||
func NewCmdStart() *cobra.Command {
|
func NewCmdStart() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "start",
|
Use: "start",
|
||||||
Short: "Start the Olares OS",
|
Short: "Start the beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.StartOlares(); err != nil {
|
if err := pipelines.StartBeOS(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -29,9 +29,9 @@ func NewCmdStop() *cobra.Command {
|
|||||||
)
|
)
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "stop",
|
Use: "stop",
|
||||||
Short: "Stop the Olares OS",
|
Short: "Stop the beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.StopOlares(timeout, checkInterval); err != nil {
|
if err := pipelines.StopBeOS(timeout, checkInterval); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
func NewCmdInstallStorage() *cobra.Command {
|
func NewCmdInstallStorage() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "storage",
|
Use: "storage",
|
||||||
Short: "install a storage backend for the Olares shared filesystem, or in the case of external storage, validate the config",
|
Short: "install a storage backend for the beOS Pro shared filesystem, or in the case of external storage, validate the config",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.CliInstallStoragePipeline(); err != nil {
|
if err := pipelines.CliInstallStoragePipeline(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
func NewCmdUninstallOs() *cobra.Command {
|
func NewCmdUninstallOs() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "uninstall",
|
Use: "uninstall",
|
||||||
Short: "Uninstall Olares",
|
Short: "Uninstall beOS Pro",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
err := pipelines.UninstallTerminusPipeline()
|
err := pipelines.UninstallTerminusPipeline()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -31,7 +31,7 @@ func NewCmdUninstallOs() *cobra.Command {
|
|||||||
|
|
||||||
// these two flags' names are too general, and only used in cmd options, so we manually bind them to the viper
|
// these two flags' names are too general, and only used in cmd options, so we manually bind them to the viper
|
||||||
// inside the pipeline creator, it still uses the flag vars to get the values
|
// inside the pipeline creator, it still uses the flag vars to get the values
|
||||||
cmd.Flags().Bool("all", false, "Uninstall Olares completely, including prepared dependencies")
|
cmd.Flags().Bool("all", false, "Uninstall beOS Pro completely, including prepared dependencies")
|
||||||
viper.BindPFlag(common.FlagUninstallAll, cmd.Flags().Lookup("all"))
|
viper.BindPFlag(common.FlagUninstallAll, cmd.Flags().Lookup("all"))
|
||||||
cmd.Flags().String("phase", cluster.PhaseInstall.String(), "Uninstall from a specified phase and revert to the previous one. For example, using --phase install will remove the tasks performed in the 'install' phase, effectively returning the system to the 'prepare' state.")
|
cmd.Flags().String("phase", cluster.PhaseInstall.String(), "Uninstall from a specified phase and revert to the previous one. For example, using --phase install will remove the tasks performed in the 'install' phase, effectively returning the system to the 'prepare' state.")
|
||||||
viper.BindPFlag(common.FlagUninstallPhase, cmd.Flags().Lookup("phase"))
|
viper.BindPFlag(common.FlagUninstallPhase, cmd.Flags().Lookup("phase"))
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import (
|
|||||||
func NewCmdUpgradeOs() *cobra.Command {
|
func NewCmdUpgradeOs() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "upgrade",
|
Use: "upgrade",
|
||||||
Short: "Upgrade Olares to a newer version",
|
Short: "Upgrade beOS Pro to a newer version",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.UpgradeOlaresPipeline(); err != nil {
|
if err := pipelines.UpgradeBeOSPipeline(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -40,7 +40,7 @@ func NewCmdCurrentVersionUpgradeSpec() *cobra.Command {
|
|||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "spec",
|
Use: "spec",
|
||||||
Aliases: []string{"current-spec"},
|
Aliases: []string{"current-spec"},
|
||||||
Short: fmt.Sprintf("Get the upgrade spec of the current olares-cli version (%s)", version.VERSION),
|
Short: fmt.Sprintf("Get the upgrade spec of the current beos-cli version (%s)", version.VERSION),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
spec, err := upgrade.CurrentVersionSpec()
|
spec, err := upgrade.CurrentVersionSpec()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -62,7 +62,7 @@ func NewCmdUpgradeViable() *cobra.Command {
|
|||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if baseVersionStr == "" {
|
if baseVersionStr == "" {
|
||||||
var err error
|
var err error
|
||||||
baseVersionStr, err = phase.GetOlaresVersion()
|
baseVersionStr, err = phase.GetBeOSVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -84,14 +84,14 @@ func NewCmdUpgradeViable() *cobra.Command {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd.Flags().StringVarP(&baseVersionStr, "base", "b", "", "base version, defaults to the current Olares system's version")
|
cmd.Flags().StringVarP(&baseVersionStr, "base", "b", "", "base version, defaults to the current beOS Pro system's version")
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCmdUpgradePrecheck() *cobra.Command {
|
func NewCmdUpgradePrecheck() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "precheck",
|
Use: "precheck",
|
||||||
Short: "Precheck Olares for Upgrade",
|
Short: "Precheck beOS Pro for Upgrade",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if err := pipelines.UpgradePreCheckPipeline(); err != nil {
|
if err := pipelines.UpgradePreCheckPipeline(); err != nil {
|
||||||
log.Fatalf("error: %v", err)
|
log.Fatalf("error: %v", err)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type activateUserOptions struct {
|
|||||||
BflUrl string
|
BflUrl string
|
||||||
VaultUrl string
|
VaultUrl string
|
||||||
Password string
|
Password string
|
||||||
OlaresId string
|
BeOSId string
|
||||||
ResetPassword string
|
ResetPassword string
|
||||||
|
|
||||||
Location string
|
Location string
|
||||||
@@ -27,11 +27,11 @@ type activateUserOptions struct {
|
|||||||
func NewCmdActivateUser() *cobra.Command {
|
func NewCmdActivateUser() *cobra.Command {
|
||||||
o := &activateUserOptions{}
|
o := &activateUserOptions{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "activate {Olares ID (e.g., user@example.com)}",
|
Use: "activate {beOS ID (e.g., user@example.com)}",
|
||||||
Short: "activate a new user",
|
Short: "activate a new user",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
o.OlaresId = args[0]
|
o.BeOSId = args[0]
|
||||||
if err := o.Validate(); err != nil {
|
if err := o.Validate(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -58,8 +58,8 @@ func (o *activateUserOptions) AddFlags(cmd *cobra.Command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *activateUserOptions) Validate() error {
|
func (o *activateUserOptions) Validate() error {
|
||||||
if o.OlaresId == "" {
|
if o.BeOSId == "" {
|
||||||
return fmt.Errorf("Olares ID is required")
|
return fmt.Errorf("beOS ID is required")
|
||||||
}
|
}
|
||||||
if o.Password == "" {
|
if o.Password == "" {
|
||||||
return fmt.Errorf("Password is required")
|
return fmt.Errorf("Password is required")
|
||||||
@@ -76,24 +76,24 @@ func (o *activateUserOptions) Validate() error {
|
|||||||
func (c *activateUserOptions) Run() error {
|
func (c *activateUserOptions) Run() error {
|
||||||
log.Println("=== TermiPass CLI - User Bind Terminus ===")
|
log.Println("=== TermiPass CLI - User Bind Terminus ===")
|
||||||
|
|
||||||
localName := c.OlaresId
|
localName := c.BeOSId
|
||||||
if strings.Contains(c.OlaresId, "@") {
|
if strings.Contains(c.BeOSId, "@") {
|
||||||
localName = strings.Split(c.OlaresId, "@")[0]
|
localName = strings.Split(c.BeOSId, "@")[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Parameters:")
|
log.Printf("Parameters:")
|
||||||
log.Printf(" BflUrl: %s", c.BflUrl)
|
log.Printf(" BflUrl: %s", c.BflUrl)
|
||||||
log.Printf(" VaultUrl: %s", c.VaultUrl)
|
log.Printf(" VaultUrl: %s", c.VaultUrl)
|
||||||
log.Printf(" Terminus Name: %s", c.OlaresId)
|
log.Printf(" Terminus Name: %s", c.BeOSId)
|
||||||
log.Printf(" Local Name: %s", localName)
|
log.Printf(" Local Name: %s", localName)
|
||||||
|
|
||||||
log.Printf("Initializing global stores with mnemonic...")
|
log.Printf("Initializing global stores with mnemonic...")
|
||||||
err := wizard.InitializeGlobalStores(c.Mnemonic, c.OlaresId)
|
err := wizard.InitializeGlobalStores(c.Mnemonic, c.BeOSId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to initialize global stores: %v", err)
|
return fmt.Errorf("failed to initialize global stores: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
accessToken, err := wizard.UserBindTerminus(c.Mnemonic, c.BflUrl, c.VaultUrl, c.Password, c.OlaresId, localName)
|
accessToken, err := wizard.UserBindTerminus(c.Mnemonic, c.BflUrl, c.VaultUrl, c.Password, c.BeOSId, localName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("user bind failed: %v", err)
|
return fmt.Errorf("user bind failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func NewCmdCreateUser() *cobra.Command {
|
|||||||
|
|
||||||
func (o *createUserOptions) AddFlags(cmd *cobra.Command) {
|
func (o *createUserOptions) AddFlags(cmd *cobra.Command) {
|
||||||
cmd.Flags().StringVar(&o.displayName, "display-name", "", "display name (optional)")
|
cmd.Flags().StringVar(&o.displayName, "display-name", "", "display name (optional)")
|
||||||
cmd.Flags().StringVar(&o.domain, "domain", "", "domain (optional, defaults to the Olares system's domain)")
|
cmd.Flags().StringVar(&o.domain, "domain", "", "domain (optional, defaults to the beOS Pro system's domain)")
|
||||||
cmd.Flags().StringVarP(&o.role, "role", "r", "normal", "owner role (optional, one of owner, admin, normal)")
|
cmd.Flags().StringVarP(&o.role, "role", "r", "normal", "owner role (optional, one of owner, admin, normal)")
|
||||||
cmd.Flags().StringVarP(&o.memoryLimit, "memory-limit", "m", defaultMemoryLimit, "memory limit (optional)")
|
cmd.Flags().StringVarP(&o.memoryLimit, "memory-limit", "m", defaultMemoryLimit, "memory limit (optional)")
|
||||||
cmd.Flags().StringVarP(&o.cpuLimit, "cpu-limit", "c", defaultCPULimit, "cpu limit (optional)")
|
cmd.Flags().StringVarP(&o.cpuLimit, "cpu-limit", "c", defaultCPULimit, "cpu limit (optional)")
|
||||||
@@ -146,7 +146,7 @@ func (o *createUserOptions) Run() error {
|
|||||||
log.Println("generated initial password:", password)
|
log.Println("generated initial password:", password)
|
||||||
o.password = passwordEncrypted
|
o.password = passwordEncrypted
|
||||||
} else {
|
} else {
|
||||||
o.password = utils.MD5(o.password + "@Olares2025")
|
o.password = utils.MD5(o.password + "@beOSPro2025")
|
||||||
}
|
}
|
||||||
|
|
||||||
olaresName := fmt.Sprintf("%s@%s", o.name, o.domain)
|
olaresName := fmt.Sprintf("%s@%s", o.name, o.domain)
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
resetNamespace = "os-framework"
|
resetNamespace = "os-framework"
|
||||||
resetServiceAccount = "olares-cli-sa"
|
resetServiceAccount = "beos-cli-sa"
|
||||||
resetServiceName = "auth-provider-svc"
|
resetServiceName = "auth-provider-svc"
|
||||||
resetServicePortName = "server"
|
resetServicePortName = "server"
|
||||||
defaultServicePort = 28080
|
defaultServicePort = 28080
|
||||||
passwordSaltSuffix = "@Olares2025"
|
passwordSaltSuffix = "@beOSPro2025"
|
||||||
authHeaderBearer = "Bearer "
|
authHeaderBearer = "Bearer "
|
||||||
cliAuthHeader = "Olares-CLI-Authorization"
|
cliAuthHeader = "BeOS-CLI-Authorization"
|
||||||
resetRequestPathTmpl = "http://%s:%d/cli/api/reset/%s/password"
|
resetRequestPathTmpl = "http://%s:%d/cli/api/reset/%s/password"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/beclab/beos/framework/app-service/api/sys.bytetrade.io/v1alpha1"
|
|
||||||
iamv1alpha2 "github.com/beclab/api/iam/v1alpha2"
|
iamv1alpha2 "github.com/beclab/api/iam/v1alpha2"
|
||||||
|
"github.com/beclab/beos/framework/app-service/api/sys.bytetrade.io/v1alpha1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func (t *InstallAmdRocm) Execute(runtime connector.Runtime) error {
|
|||||||
rocmV, _ := connector.RocmVersion()
|
rocmV, _ := connector.RocmVersion()
|
||||||
min := semver.MustParse("7.1.1")
|
min := semver.MustParse("7.1.1")
|
||||||
if rocmV != nil && rocmV.LessThan(min) {
|
if rocmV != nil && rocmV.LessThan(min) {
|
||||||
return fmt.Errorf("detected ROCm version %s, which is lower than required %s; please uninstall existing ROCm/AMDGPU components before installation with command: olares-cli amdgpu uninstall", rocmV.Original(), min.Original())
|
return fmt.Errorf("detected ROCm version %s, which is lower than required %s; please uninstall existing ROCm/AMDGPU components before installation with command: beos-cli amdgpu uninstall", rocmV.Original(), min.Original())
|
||||||
}
|
}
|
||||||
if rocmV != nil && rocmV.GreaterThan(min) {
|
if rocmV != nil && rocmV.GreaterThan(min) {
|
||||||
logger.Warnf("Warning: detected ROCm version %s great than maximum tested version %s")
|
logger.Warnf("Warning: detected ROCm version %s great than maximum tested version %s")
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ func (n *NodeConfigureOS) Execute(runtime connector.Runtime) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if running in docker container, /etc/hosts file is bind mounting, cannot be replaced via mv command
|
// if running in docker container, /etc/hosts file is bind mounting, cannot be replaced via mv command
|
||||||
if !n.KubeConf.Arg.IsOlaresInContainer {
|
if !n.KubeConf.Arg.IsBeOSInContainer {
|
||||||
_, err1 := runtime.GetRunner().SudoCmd(fmt.Sprintf("hostnamectl set-hostname %s && sed -i '/^127.0.1.1/s/.*/127.0.1.1 %s/g' /etc/hosts", host.GetName(), host.GetName()), false, false)
|
_, err1 := runtime.GetRunner().SudoCmd(fmt.Sprintf("hostnamectl set-hostname %s && sed -i '/^127.0.1.1/s/.*/127.0.1.1 %s/g' /etc/hosts", host.GetName(), host.GetName()), false, false)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
return errors.Wrap(errors.WithStack(err1), "Failed to override hostname")
|
return errors.Wrap(errors.WithStack(err1), "Failed to override hostname")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
var SwapServiceTmpl = template.Must(template.New("olares-swap.service").Parse(
|
var SwapServiceTmpl = template.Must(template.New("olares-swap.service").Parse(
|
||||||
dedent.Dedent(`[Unit]
|
dedent.Dedent(`[Unit]
|
||||||
Description=Olares Swap Configuring Service
|
Description=beOS Pro Swap Configuring Service
|
||||||
After=local-fs.target
|
After=local-fs.target
|
||||||
StartLimitIntervalSec=0
|
StartLimitIntervalSec=0
|
||||||
|
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ func (t *DisableLocalDNSTask) configResolvConf(runtime connector.Runtime) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
primaryDNSServer, secondaryDNSServer := "1.1.1.1", "114.114.114.114"
|
primaryDNSServer, secondaryDNSServer := "1.1.1.1", "114.114.114.114"
|
||||||
if strings.Contains(t.KubeConf.Arg.RegistryMirrors, common.OlaresRegistryMirrorHost) || strings.Contains(t.KubeConf.Arg.RegistryMirrors, common.OlaresRegistryMirrorHostLegacy) {
|
if strings.Contains(t.KubeConf.Arg.RegistryMirrors, common.BeOSRegistryMirrorHost) || strings.Contains(t.KubeConf.Arg.RegistryMirrors, common.BeOSRegistryMirrorHostLegacy) {
|
||||||
primaryDNSServer, secondaryDNSServer = secondaryDNSServer, primaryDNSServer
|
primaryDNSServer, secondaryDNSServer = secondaryDNSServer, primaryDNSServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ func (t *RequiredPortsCheck) Check(runtime connector.Runtime) error {
|
|||||||
defer l.Close()
|
defer l.Close()
|
||||||
}
|
}
|
||||||
if len(unbindablePorts) > 0 {
|
if len(unbindablePorts) > 0 {
|
||||||
return fmt.Errorf("port %v required by Olares cannot be bound, you can check which process using the command `sudo netstat -tlnp`", unbindablePorts)
|
return fmt.Errorf("port %v required by beOS Pro cannot be bound, you can check which process using the command `sudo netstat -tlnp`", unbindablePorts)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -135,14 +135,14 @@ func (t *ConflictingContainerdCheck) Check(runtime connector.Runtime) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
fixMSG := "\nIf it is installed as a component of Docker, it should be uninstalled per the official doc https://docs.docker.com/engine/install/ubuntu/#uninstall-old-versions"
|
fixMSG := "\nIf it is installed as a component of Docker, it should be uninstalled per the official doc https://docs.docker.com/engine/install/ubuntu/#uninstall-old-versions"
|
||||||
fixMSG += "\nIf it is left over from a previous installation of Olares, clean it up using the command `sudo olares-cli uninstall --all`"
|
fixMSG += "\nIf it is left over from a previous installation of beOS Pro, clean it up using the command `sudo beos-cli uninstall --all`"
|
||||||
containerdBin, err := util.GetCommand("containerd")
|
containerdBin, err := util.GetCommand("containerd")
|
||||||
if err == nil && containerdBin != "" {
|
if err == nil && containerdBin != "" {
|
||||||
return fmt.Errorf("found existing containerd binary: %s, a containerd managed by Olares is required to ensure normal function%s", containerdBin, fixMSG)
|
return fmt.Errorf("found existing containerd binary: %s, a containerd managed by beOS Pro is required to ensure normal function%s", containerdBin, fixMSG)
|
||||||
}
|
}
|
||||||
containerdSocket := "/run/containerd/containerd.sock"
|
containerdSocket := "/run/containerd/containerd.sock"
|
||||||
if util.IsExist(containerdSocket) {
|
if util.IsExist(containerdSocket) {
|
||||||
return fmt.Errorf("found existing containerd socket: %s, a containerd managed by Olares is required to ensure normal function%s", containerdSocket, fixMSG)
|
return fmt.Errorf("found existing containerd socket: %s, a containerd managed by beOS Pro is required to ensure normal function%s", containerdSocket, fixMSG)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ func (t *SystemdCheck) Check(runtime connector.Runtime) error {
|
|||||||
if util.IsExist("/run/systemd/system") {
|
if util.IsExist("/run/systemd/system") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("this system is not inited by systemd, which is required by Olares")
|
return errors.New("this system is not inited by systemd, which is required by beOS Pro")
|
||||||
}
|
}
|
||||||
|
|
||||||
type MasterNodeReadyCheck struct{}
|
type MasterNodeReadyCheck struct{}
|
||||||
@@ -288,7 +288,7 @@ func (t *NvidiaCardArchChecker) Check(runtime connector.Runtime) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !slices.Contains(supportedArchs, arch) {
|
if !slices.Contains(supportedArchs, arch) {
|
||||||
return fmt.Errorf("unsupported NVIDIA card %s of architecture: %s, Olares only supports the following architectures: %s", model, arch, strings.Join(supportedArchs, ", "))
|
return fmt.Errorf("unsupported NVIDIA card %s of architecture: %s, beOS Pro only supports the following architectures: %s", model, arch, strings.Join(supportedArchs, ", "))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ func (n *NouveauChecker) Check(runtime connector.Runtime) error {
|
|||||||
}
|
}
|
||||||
val := strings.TrimSpace(string(data))
|
val := strings.TrimSpace(string(data))
|
||||||
if val == "1" || val == "-1" {
|
if val == "1" || val == "-1" {
|
||||||
return fmt.Errorf("detected nouveau kernel module loaded with modeset=%s; this conflicts with the NVIDIA driver that Olares will install, please disable it by running `sudo olares-cli gpu disable-nouveau`, REBOOT your machine, and try again", val)
|
return fmt.Errorf("detected nouveau kernel module loaded with modeset=%s; this conflicts with the NVIDIA driver that beOS Pro will install, please disable it by running `sudo beos-cli gpu disable-nouveau`, REBOOT your machine, and try again", val)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ func (r *RocmChecker) Check(runtime connector.Runtime) error {
|
|||||||
|
|
||||||
min := semver.MustParse("7.1.1")
|
min := semver.MustParse("7.1.1")
|
||||||
if curV.LessThan(min) {
|
if curV.LessThan(min) {
|
||||||
return fmt.Errorf("detected ROCm version %s, which is lower than required %s; please uninstall existing ROCm/AMDGPU components before installation with command: olares-cli amdgpu uninstall", curV.Original(), min.Original())
|
return fmt.Errorf("detected ROCm version %s, which is lower than required %s; please uninstall existing ROCm/AMDGPU components before installation with command: beos-cli amdgpu uninstall", curV.Original(), min.Original())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -424,7 +424,7 @@ type GreetingsTask struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *GreetingsTask) Execute(runtime connector.Runtime) error {
|
func (h *GreetingsTask) Execute(runtime connector.Runtime) error {
|
||||||
_, err := runtime.GetRunner().Cmd("echo 'Greetings, Olares'", false, true)
|
_, err := runtime.GetRunner().Cmd("echo 'Greetings, beOS Pro'", false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -605,8 +605,8 @@ func (t *RemoveWSLChattr) Execute(runtime connector.Runtime) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrUnsupportedCudaVersion = errors.New("unsupported cuda version, please uninstall it using the command `sudo olares-cli gpu uninstall`, REBOOT your machine, and try again")
|
var ErrUnsupportedCudaVersion = errors.New("unsupported cuda version, please uninstall it using the command `sudo beos-cli gpu uninstall`, REBOOT your machine, and try again")
|
||||||
var ErrKernelDriverUninstalledButRunning = errors.New("NVIDIA driver is uninstalled, but the kernel driver is still running, please REBOOT your machine, and try again")
|
var ErrKernelDriverUninstalledButRunning = errors.New("NVIDIA driver is uninstalled, but the kernel driver is still running, please REBOOT your machine, and try again")
|
||||||
var ErrNotInstalledByRunfile = errors.New("NVIDIA driver is installed, but not installed by runfile, please uninstall it using the command `sudo olares-cli gpu uninstall`, REBOOT your machine, and try again")
|
var ErrNotInstalledByRunfile = errors.New("NVIDIA driver is installed, but not installed by runfile, please uninstall it using the command `sudo beos-cli gpu uninstall`, REBOOT your machine, and try again")
|
||||||
var ErrDriverLibraryVersionMismatch = errors.New("NVIDIA driver is installed, but the library version with the running version is mismatched, please REBOOT your machine, and try again")
|
var ErrDriverLibraryVersionMismatch = errors.New("NVIDIA driver is installed, but the library version with the running version is mismatched, please REBOOT your machine, and try again")
|
||||||
var supportedCudaVersions = []string{common.CurrentVerifiedCudaVersion}
|
var supportedCudaVersions = []string{common.CurrentVerifiedCudaVersion}
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
OlaresRegistryMirrorHost = "mirrors.joinolares.cn"
|
BeOSRegistryMirrorHost = "mirrors.beos.local"
|
||||||
OlaresRegistryMirrorHostLegacy = "mirrors.jointerminus.cn"
|
BeOSRegistryMirrorHostLegacy = "mirrors-legacy.beos.local"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -137,7 +137,7 @@ const (
|
|||||||
TerminusStateFilePrepared = ".prepared"
|
TerminusStateFilePrepared = ".prepared"
|
||||||
TerminusStateFileInstalled = ".installed"
|
TerminusStateFileInstalled = ".installed"
|
||||||
MasterHostConfigFile = "master.conf"
|
MasterHostConfigFile = "master.conf"
|
||||||
OlaresReleaseFile = "/etc/olares/release"
|
BeOSReleaseFile = "/etc/olares/release"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -308,5 +308,5 @@ func SetSystemEnv(key, value string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HelmValuesKeyOlaresRootFSPath = "rootPath"
|
HelmValuesKeyBeOSRootFSPath = "rootPath"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,15 +46,15 @@ type KubeRuntime struct {
|
|||||||
|
|
||||||
type Argument struct {
|
type Argument struct {
|
||||||
KubernetesVersion string `json:"kubernetes_version"`
|
KubernetesVersion string `json:"kubernetes_version"`
|
||||||
OlaresVersion string `json:"olares_version"`
|
BeOSVersion string `json:"olares_version"`
|
||||||
SecurityEnhancement bool `json:"security_enhancement"`
|
SecurityEnhancement bool `json:"security_enhancement"`
|
||||||
InCluster bool `json:"in_cluster"`
|
InCluster bool `json:"in_cluster"`
|
||||||
ContainerManager string `json:"container_manager"`
|
ContainerManager string `json:"container_manager"`
|
||||||
Kubetype string `json:"kube_type"`
|
Kubetype string `json:"kube_type"`
|
||||||
SystemInfo connector.Systems
|
SystemInfo connector.Systems
|
||||||
|
|
||||||
RegistryMirrors string `json:"registry_mirrors"`
|
RegistryMirrors string `json:"registry_mirrors"`
|
||||||
OlaresCDNService string `json:"olares_cdn_service"`
|
BeOSCDNService string `json:"olares_cdn_service"`
|
||||||
|
|
||||||
// Swap config
|
// Swap config
|
||||||
*SwapConfig
|
*SwapConfig
|
||||||
@@ -84,7 +84,7 @@ type Argument struct {
|
|||||||
ConsoleLogTruncate bool `json:"console_log_truncate"`
|
ConsoleLogTruncate bool `json:"console_log_truncate"`
|
||||||
HostIP string `json:"host_ip"`
|
HostIP string `json:"host_ip"`
|
||||||
|
|
||||||
IsOlaresInContainer bool `json:"is_olares_in_container"`
|
IsBeOSInContainer bool `json:"is_olares_in_container"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SwapConfig struct {
|
type SwapConfig struct {
|
||||||
@@ -199,7 +199,7 @@ func NewArgument() *Argument {
|
|||||||
},
|
},
|
||||||
NetworkSettings: &NetworkSettings{},
|
NetworkSettings: &NetworkSettings{},
|
||||||
RegistryMirrors: viper.GetString(FlagRegistryMirrors),
|
RegistryMirrors: viper.GetString(FlagRegistryMirrors),
|
||||||
OlaresCDNService: viper.GetString(FlagCDNService),
|
BeOSCDNService: viper.GetString(FlagCDNService),
|
||||||
HostIP: viper.GetString(ENV_HOST_IP),
|
HostIP: viper.GetString(ENV_HOST_IP),
|
||||||
Environment: os.Environ(),
|
Environment: os.Environ(),
|
||||||
MasterHostConfig: &MasterHostConfig{},
|
MasterHostConfig: &MasterHostConfig{},
|
||||||
@@ -208,8 +208,8 @@ func NewArgument() *Argument {
|
|||||||
// default enable GPU unless explicitly set to "0"
|
// default enable GPU unless explicitly set to "0"
|
||||||
arg.GPU.Enable = !strings.EqualFold(os.Getenv(ENV_LOCAL_GPU_ENABLE), "0")
|
arg.GPU.Enable = !strings.EqualFold(os.Getenv(ENV_LOCAL_GPU_ENABLE), "0")
|
||||||
arg.IsCloudInstance, _ = strconv.ParseBool(os.Getenv(ENV_TERMINUS_IS_CLOUD_VERSION))
|
arg.IsCloudInstance, _ = strconv.ParseBool(os.Getenv(ENV_TERMINUS_IS_CLOUD_VERSION))
|
||||||
arg.IsOlaresInContainer = os.Getenv(ENV_CONTAINER_MODE) == "oic"
|
arg.IsBeOSInContainer = os.Getenv(ENV_CONTAINER_MODE) == "oic"
|
||||||
si.IsOIC = arg.IsOlaresInContainer
|
si.IsOIC = arg.IsBeOSInContainer
|
||||||
si.ProductName = arg.GetProductName()
|
si.ProductName = arg.GetProductName()
|
||||||
|
|
||||||
// Ensure BaseDir is initialized before loading master.conf
|
// Ensure BaseDir is initialized before loading master.conf
|
||||||
@@ -223,22 +223,22 @@ func (a *Argument) SaveReleaseInfo(withoutName bool) error {
|
|||||||
if a.BaseDir == "" {
|
if a.BaseDir == "" {
|
||||||
return errors.New("invalid: empty base directory")
|
return errors.New("invalid: empty base directory")
|
||||||
}
|
}
|
||||||
if a.OlaresVersion == "" {
|
if a.BeOSVersion == "" {
|
||||||
return errors.New("invalid: empty olares version")
|
return errors.New("invalid: empty olares version")
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseInfoMap := map[string]string{
|
releaseInfoMap := map[string]string{
|
||||||
ENV_OLARES_BASE_DIR: a.BaseDir,
|
ENV_OLARES_BASE_DIR: a.BaseDir,
|
||||||
ENV_OLARES_VERSION: a.OlaresVersion,
|
ENV_OLARES_VERSION: a.BeOSVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !withoutName {
|
if !withoutName {
|
||||||
if a.User != nil && a.User.UserName != "" && a.User.DomainName != "" {
|
if a.User != nil && a.User.UserName != "" && a.User.DomainName != "" {
|
||||||
releaseInfoMap["OLARES_NAME"] = fmt.Sprintf("%s@%s", a.User.UserName, a.User.DomainName)
|
releaseInfoMap["OLARES_NAME"] = fmt.Sprintf("%s@%s", a.User.UserName, a.User.DomainName)
|
||||||
} else {
|
} else {
|
||||||
if util.IsExist(OlaresReleaseFile) {
|
if util.IsExist(BeOSReleaseFile) {
|
||||||
// if the user is not set, try to load the user name from the release file
|
// if the user is not set, try to load the user name from the release file
|
||||||
envs, err := godotenv.Read(OlaresReleaseFile)
|
envs, err := godotenv.Read(BeOSReleaseFile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if userName, ok := envs["OLARES_NAME"]; ok {
|
if userName, ok := envs["OLARES_NAME"]; ok {
|
||||||
releaseInfoMap["OLARES_NAME"] = userName
|
releaseInfoMap["OLARES_NAME"] = userName
|
||||||
@@ -248,12 +248,12 @@ func (a *Argument) SaveReleaseInfo(withoutName bool) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !util.IsExist(filepath.Dir(OlaresReleaseFile)) {
|
if !util.IsExist(filepath.Dir(BeOSReleaseFile)) {
|
||||||
if err := os.MkdirAll(filepath.Dir(OlaresReleaseFile), 0755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(BeOSReleaseFile), 0755); err != nil {
|
||||||
return fmt.Errorf("failed to create directory %s: %v", filepath.Dir(OlaresReleaseFile), err)
|
return fmt.Errorf("failed to create directory %s: %v", filepath.Dir(BeOSReleaseFile), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return godotenv.Write(releaseInfoMap, OlaresReleaseFile)
|
return godotenv.Write(releaseInfoMap, BeOSReleaseFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Argument) GetWslUserPath() string {
|
func (a *Argument) GetWslUserPath() string {
|
||||||
@@ -278,12 +278,12 @@ func (a *Argument) GetWslUserPath() string {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Argument) SetOlaresCDNService(url string) {
|
func (a *Argument) SetBeOSCDNService(url string) {
|
||||||
u := strings.TrimSuffix(url, "/")
|
u := strings.TrimSuffix(url, "/")
|
||||||
if u == "" {
|
if u == "" {
|
||||||
u = common.DefaultOlaresCDNService
|
u = common.DefaultBeOSCDNService
|
||||||
}
|
}
|
||||||
a.OlaresCDNService = u
|
a.BeOSCDNService = u
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Argument) SetGPU(enable bool) {
|
func (a *Argument) SetGPU(enable bool) {
|
||||||
@@ -293,7 +293,7 @@ func (a *Argument) SetGPU(enable bool) {
|
|||||||
a.GPU.Enable = enable
|
a.GPU.Enable = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Argument) SetOlaresVersion(version string) {
|
func (a *Argument) SetBeOSVersion(version string) {
|
||||||
if version == "" || len(version) <= 2 {
|
if version == "" || len(version) <= 2 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -301,7 +301,7 @@ func (a *Argument) SetOlaresVersion(version string) {
|
|||||||
if version[0] == 'v' {
|
if version[0] == 'v' {
|
||||||
version = version[1:]
|
version = version[1:]
|
||||||
}
|
}
|
||||||
a.OlaresVersion = version
|
a.BeOSVersion = version
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Argument) SetStorage(storage *Storage) {
|
func (a *Argument) SetStorage(storage *Storage) {
|
||||||
@@ -475,7 +475,7 @@ func NewKubeRuntime(arg Argument) (*KubeRuntime, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
base := connector.NewBaseRuntime(cluster.Name, connector.NewDialer(),
|
base := connector.NewBaseRuntime(cluster.Name, connector.NewDialer(),
|
||||||
arg.BaseDir, arg.OlaresVersion, arg.ConsoleLogFileName, arg.ConsoleLogTruncate, arg.SystemInfo)
|
arg.BaseDir, arg.BeOSVersion, arg.ConsoleLogFileName, arg.ConsoleLogTruncate, arg.SystemInfo)
|
||||||
|
|
||||||
clusterSpec := &cluster.Spec
|
clusterSpec := &cluster.Spec
|
||||||
defaultCluster, roleGroups := clusterSpec.SetDefaultClusterSpec(arg.InCluster, arg.SystemInfo.IsDarwin())
|
defaultCluster, roleGroups := clusterSpec.SetDefaultClusterSpec(arg.InCluster, arg.SystemInfo.IsDarwin())
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const (
|
|||||||
WizardDir = "wizard"
|
WizardDir = "wizard"
|
||||||
ComponentsDir = "components"
|
ComponentsDir = "components"
|
||||||
DeployDir = "deploy"
|
DeployDir = "deploy"
|
||||||
OlaresDir = "olares"
|
BeOSDir = "olares"
|
||||||
|
|
||||||
DefaultBaseDir = ".beos-pro"
|
DefaultBaseDir = ".beos-pro"
|
||||||
DefaultDomainName = "beos.local"
|
DefaultDomainName = "beos.local"
|
||||||
@@ -92,8 +92,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultOlaresCDNService = ""
|
DefaultBeOSCDNService = ""
|
||||||
DefaultBashUrl = "beos.sh"
|
DefaultBashUrl = "beos.sh"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ func (u *UninstallTerminusdModule) Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReplaceOlaresdBinaryModule struct {
|
type ReplaceBeOSdBinaryModule struct {
|
||||||
common.KubeModule
|
common.KubeModule
|
||||||
manifest.ManifestModule
|
manifest.ManifestModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ReplaceOlaresdBinaryModule) Init() {
|
func (m *ReplaceBeOSdBinaryModule) Init() {
|
||||||
m.Name = "ReplaceBeOSdBinaryModule"
|
m.Name = "ReplaceBeOSdBinaryModule"
|
||||||
m.Desc = "Replace beosd"
|
m.Desc = "Replace beosd"
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ func (m *ReplaceOlaresdBinaryModule) Init() {
|
|||||||
updateEnv := &task.LocalTask{
|
updateEnv := &task.LocalTask{
|
||||||
Name: "UpdateBeOSdEnv",
|
Name: "UpdateBeOSdEnv",
|
||||||
Desc: "Update beosd env",
|
Desc: "Update beosd env",
|
||||||
Action: new(UpdateOlaresdServiceEnv),
|
Action: new(UpdateBeOSdServiceEnv),
|
||||||
}
|
}
|
||||||
|
|
||||||
restart := &task.LocalTask{
|
restart := &task.LocalTask{
|
||||||
|
|||||||
@@ -25,33 +25,36 @@ func (g *InstallTerminusdBinary) Execute(runtime connector.Runtime) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
binary, err := g.Manifest.Get("olaresd")
|
binary, err := g.Manifest.Get("beosd")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get kube binary olaresd info failed: %w", err)
|
binary, err = g.Manifest.Get("olaresd")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("get kube binary beosd info failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
path := binary.FilePath(g.BaseDir)
|
path := binary.FilePath(g.BaseDir)
|
||||||
|
|
||||||
dst := filepath.Join(common.TmpDir, binary.Filename)
|
dst := filepath.Join(common.TmpDir, binary.Filename)
|
||||||
if err := runtime.GetRunner().Scp(path, dst); err != nil {
|
if err := runtime.GetRunner().Scp(path, dst); err != nil {
|
||||||
return errors.Wrap(errors.WithStack(err), "sync olaresd tar.gz failed")
|
return errors.Wrap(errors.WithStack(err), "sync beosd tar.gz failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
installCmd := fmt.Sprintf("tar -zxf %s && cp -f olaresd /usr/local/bin/beosd && cp -f olaresd /usr/local/bin/olaresd && chmod +x /usr/local/bin/beosd /usr/local/bin/olaresd && rm -rf olaresd*", dst)
|
installCmd := fmt.Sprintf("tar -zxf %s && src=$( [ -f beosd ] && printf beosd || printf olaresd ) && cp -f \"$src\" /usr/local/bin/beosd && cp -f \"$src\" /usr/local/bin/olaresd && chmod +x /usr/local/bin/beosd /usr/local/bin/olaresd && rm -rf beosd* olaresd*", dst)
|
||||||
if _, err := runtime.GetRunner().SudoCmd(installCmd, false, false); err != nil {
|
if _, err := runtime.GetRunner().SudoCmd(installCmd, false, false); err != nil {
|
||||||
return errors.Wrap(errors.WithStack(err), "install beosd binaries failed")
|
return errors.Wrap(errors.WithStack(err), "install beosd binaries failed")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateOlaresdServiceEnv struct {
|
type UpdateBeOSdServiceEnv struct {
|
||||||
common.KubeAction
|
common.KubeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *UpdateOlaresdServiceEnv) Execute(runtime connector.Runtime) error {
|
func (a *UpdateBeOSdServiceEnv) Execute(runtime connector.Runtime) error {
|
||||||
envFilePath := filepath.Join("/etc/systemd/system/", templates.TerminusdEnv.Name())
|
envFilePath := filepath.Join("/etc/systemd/system/", templates.TerminusdEnv.Name())
|
||||||
versionKey := "INSTALLED_VERSION"
|
versionKey := "INSTALLED_VERSION"
|
||||||
updateVersionCMD := fmt.Sprintf("sed -i '/%s/c\\%s=%s' %s ", versionKey, versionKey, a.KubeConf.Arg.OlaresVersion, envFilePath)
|
updateVersionCMD := fmt.Sprintf("sed -i '/%s/c\\%s=%s' %s ", versionKey, versionKey, a.KubeConf.Arg.BeOSVersion, envFilePath)
|
||||||
if _, err := runtime.GetRunner().SudoCmd(updateVersionCMD, false, false); err != nil {
|
if _, err := runtime.GetRunner().SudoCmd(updateVersionCMD, false, false); err != nil {
|
||||||
return fmt.Errorf("update beosd env failed: %v", err)
|
return fmt.Errorf("update beosd env failed: %v", err)
|
||||||
}
|
}
|
||||||
@@ -65,11 +68,11 @@ type GenerateTerminusdServiceEnv struct {
|
|||||||
func (g *GenerateTerminusdServiceEnv) Execute(runtime connector.Runtime) error {
|
func (g *GenerateTerminusdServiceEnv) Execute(runtime connector.Runtime) error {
|
||||||
var baseDir = runtime.GetBaseDir()
|
var baseDir = runtime.GetBaseDir()
|
||||||
templateAction := action.Template{
|
templateAction := action.Template{
|
||||||
Name: "OlaresdServiceEnv",
|
Name: "BeOSdServiceEnv",
|
||||||
Template: templates.TerminusdEnv,
|
Template: templates.TerminusdEnv,
|
||||||
Dst: filepath.Join("/etc/systemd/system/", templates.TerminusdEnv.Name()),
|
Dst: filepath.Join("/etc/systemd/system/", templates.TerminusdEnv.Name()),
|
||||||
Data: util.Data{
|
Data: util.Data{
|
||||||
"Version": g.KubeConf.Arg.OlaresVersion,
|
"Version": g.KubeConf.Arg.BeOSVersion,
|
||||||
"KubeType": g.KubeConf.Arg.Kubetype,
|
"KubeType": g.KubeConf.Arg.Kubetype,
|
||||||
"RegistryMirrors": g.KubeConf.Arg.RegistryMirrors,
|
"RegistryMirrors": g.KubeConf.Arg.RegistryMirrors,
|
||||||
"BaseDir": baseDir,
|
"BaseDir": baseDir,
|
||||||
@@ -91,7 +94,7 @@ type GenerateTerminusdService struct {
|
|||||||
|
|
||||||
func (g *GenerateTerminusdService) Execute(runtime connector.Runtime) error {
|
func (g *GenerateTerminusdService) Execute(runtime connector.Runtime) error {
|
||||||
templateAction := action.Template{
|
templateAction := action.Template{
|
||||||
Name: "OlaresdService",
|
Name: "BeOSdService",
|
||||||
Template: templates.TerminusdService,
|
Template: templates.TerminusdService,
|
||||||
Dst: filepath.Join("/etc/systemd/system/", templates.TerminusdService.Name()),
|
Dst: filepath.Join("/etc/systemd/system/", templates.TerminusdService.Name()),
|
||||||
Data: util.Data{},
|
Data: util.Data{},
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ func NewKubeBinary(name, arch, osType, osVersion, osPlatformFamily, version, pre
|
|||||||
component.Type = COMPONENT
|
component.Type = COMPONENT
|
||||||
component.FileName = fmt.Sprintf("redis-%s.tar.gz", version)
|
component.FileName = fmt.Sprintf("redis-%s.tar.gz", version)
|
||||||
component.FileNameHash = utils.MD5(component.FileName)
|
component.FileNameHash = utils.MD5(component.FileName)
|
||||||
component.Url = fmt.Sprintf(RedisUrl, common.DefaultOlaresCDNService, component.FileNameHash)
|
component.Url = fmt.Sprintf(RedisUrl, common.DefaultBeOSCDNService, component.FileNameHash)
|
||||||
component.CheckSum = false
|
component.CheckSum = false
|
||||||
component.BaseDir = filepath.Join(prePath, component.Type)
|
component.BaseDir = filepath.Join(prePath, component.Type)
|
||||||
case juicefs:
|
case juicefs:
|
||||||
@@ -330,21 +330,21 @@ func NewKubeBinary(name, arch, osType, osVersion, osPlatformFamily, version, pre
|
|||||||
component.Type = GPU
|
component.Type = GPU
|
||||||
component.FileName = fmt.Sprintf("%s_%s_cuda-keyring_%s-1_all.deb", osPlatformFamily, osVersion, version)
|
component.FileName = fmt.Sprintf("%s_%s_cuda-keyring_%s-1_all.deb", osPlatformFamily, osVersion, version)
|
||||||
component.FileNameHash = utils.MD5(component.FileName)
|
component.FileNameHash = utils.MD5(component.FileName)
|
||||||
component.Url = fmt.Sprintf(CudaKeyringCNDUrl, common.DefaultOlaresCDNService, getGpuCDNPrefix(arch, component.FileNameHash)) //getCudaKeyringUrl(arch, constants.OsVersion, version)
|
component.Url = fmt.Sprintf(CudaKeyringCNDUrl, common.DefaultBeOSCDNService, getGpuCDNPrefix(arch, component.FileNameHash)) //getCudaKeyringUrl(arch, constants.OsVersion, version)
|
||||||
component.CheckSum = false
|
component.CheckSum = false
|
||||||
component.BaseDir = filepath.Join(prePath, component.Type)
|
component.BaseDir = filepath.Join(prePath, component.Type)
|
||||||
case gpgkey:
|
case gpgkey:
|
||||||
component.Type = GPU
|
component.Type = GPU
|
||||||
component.FileName = "gpgkey"
|
component.FileName = "gpgkey"
|
||||||
component.FileNameHash = utils.MD5(component.FileName)
|
component.FileNameHash = utils.MD5(component.FileName)
|
||||||
component.Url = fmt.Sprintf(CudaKeyringCNDUrl, common.DefaultOlaresCDNService, getGpuCDNPrefix(arch, component.FileNameHash))
|
component.Url = fmt.Sprintf(CudaKeyringCNDUrl, common.DefaultBeOSCDNService, getGpuCDNPrefix(arch, component.FileNameHash))
|
||||||
component.CheckSum = false
|
component.CheckSum = false
|
||||||
component.BaseDir = filepath.Join(prePath, component.Type)
|
component.BaseDir = filepath.Join(prePath, component.Type)
|
||||||
case libnvidia:
|
case libnvidia:
|
||||||
component.Type = GPU
|
component.Type = GPU
|
||||||
component.FileName = fmt.Sprintf("%s_%s_libnvidia-container.list", osPlatformFamily, osVersion)
|
component.FileName = fmt.Sprintf("%s_%s_libnvidia-container.list", osPlatformFamily, osVersion)
|
||||||
component.FileNameHash = utils.MD5(component.FileName)
|
component.FileNameHash = utils.MD5(component.FileName)
|
||||||
component.Url = fmt.Sprintf(CudaKeyringCNDUrl, common.DefaultOlaresCDNService, getGpuCDNPrefix(arch, component.FileNameHash))
|
component.Url = fmt.Sprintf(CudaKeyringCNDUrl, common.DefaultBeOSCDNService, getGpuCDNPrefix(arch, component.FileNameHash))
|
||||||
component.CheckSum = false
|
component.CheckSum = false
|
||||||
component.BaseDir = filepath.Join(prePath, component.Type)
|
component.BaseDir = filepath.Join(prePath, component.Type)
|
||||||
case wsl: // + wsl
|
case wsl: // + wsl
|
||||||
@@ -377,7 +377,7 @@ func NewKubeBinary(name, arch, osType, osVersion, osPlatformFamily, version, pre
|
|||||||
|
|
||||||
func (b *KubeBinary) GetDownloadMirrors(downloadMirrors string) string {
|
func (b *KubeBinary) GetDownloadMirrors(downloadMirrors string) string {
|
||||||
if downloadMirrors == "" {
|
if downloadMirrors == "" {
|
||||||
return common.DefaultOlaresCDNService
|
return common.DefaultBeOSCDNService
|
||||||
}
|
}
|
||||||
return downloadMirrors
|
return downloadMirrors
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ func (t *UpdateNvidiaContainerToolkitSource) Execute(runtime connector.Runtime)
|
|||||||
|
|
||||||
// decide mirror based on OLARES_SYSTEM_CDN_SERVICE
|
// decide mirror based on OLARES_SYSTEM_CDN_SERVICE
|
||||||
var mirrorHost string
|
var mirrorHost string
|
||||||
cdnService := t.KubeConf.Arg.OlaresCDNService
|
cdnService := t.KubeConf.Arg.BeOSCDNService
|
||||||
if cdnService != "" {
|
if cdnService != "" {
|
||||||
cdnRaw := cdnService
|
cdnRaw := cdnService
|
||||||
if !strings.HasPrefix(cdnRaw, "http") {
|
if !strings.HasPrefix(cdnRaw, "http") {
|
||||||
@@ -176,10 +176,10 @@ func (t *UpdateNvidiaContainerToolkitSource) Execute(runtime connector.Runtime)
|
|||||||
if host == "" {
|
if host == "" {
|
||||||
host = cdnService
|
host = cdnService
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(host, "olares.cn") {
|
if strings.HasSuffix(host, ".cn") {
|
||||||
mirrorHost = "mirrors.ustc.edu.cn"
|
mirrorHost = "mirrors.ustc.edu.cn"
|
||||||
}
|
}
|
||||||
} else if strings.HasSuffix(cdnService, "olares.cn") {
|
} else if strings.HasSuffix(cdnService, ".cn") {
|
||||||
mirrorHost = "mirrors.ustc.edu.cn"
|
mirrorHost = "mirrors.ustc.edu.cn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func (t *LoadImages) Execute(runtime connector.Runtime) (reserr error) {
|
|||||||
// loadParm = "--snapshotter=zfs"
|
// loadParm = "--snapshotter=zfs"
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if t.KubeConf.Arg.IsOlaresInContainer {
|
if t.KubeConf.Arg.IsBeOSInContainer {
|
||||||
loadParm = "--no-unpack"
|
loadParm = "--no-unpack"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ func (g *GenerateK3sService) Execute(runtime connector.Runtime) error {
|
|||||||
"JuiceFSPreCheckEnabled": util.IsExist(storage.JuiceFsServiceFile),
|
"JuiceFSPreCheckEnabled": util.IsExist(storage.JuiceFsServiceFile),
|
||||||
"JuiceFSServiceUnit": storagetpl.JuicefsService.Name(),
|
"JuiceFSServiceUnit": storagetpl.JuicefsService.Name(),
|
||||||
"JuiceFSBinPath": storage.JuiceFsFile,
|
"JuiceFSBinPath": storage.JuiceFsFile,
|
||||||
"JuiceFSMountPoint": storage.OlaresJuiceFSRootDir,
|
"JuiceFSMountPoint": storage.BeOSJuiceFSRootDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
templateAction := action.Template{
|
templateAction := action.Template{
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ type GetKubeVersion struct{}
|
|||||||
func (g *GetKubeVersion) Execute() (string, string, error) {
|
func (g *GetKubeVersion) Execute() (string, string, error) {
|
||||||
var kubectlpath, err = util.GetCommand(common.CommandKubectl)
|
var kubectlpath, err = util.GetCommand(common.CommandKubectl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", fmt.Errorf("kubectl not found, Olares might not be installed.")
|
return "", "", fmt.Errorf("kubectl not found, beOS Pro might not be installed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
@@ -224,7 +224,7 @@ func (t *GenerateKubeletService) Execute(runtime connector.Runtime) error {
|
|||||||
"JuiceFSPreCheckEnabled": util.IsExist(storage.JuiceFsServiceFile),
|
"JuiceFSPreCheckEnabled": util.IsExist(storage.JuiceFsServiceFile),
|
||||||
"JuiceFSServiceUnit": storagetpl.JuicefsService.Name(),
|
"JuiceFSServiceUnit": storagetpl.JuicefsService.Name(),
|
||||||
"JuiceFSBinPath": storage.JuiceFsFile,
|
"JuiceFSBinPath": storage.JuiceFsFile,
|
||||||
"JuiceFSMountPoint": storage.OlaresJuiceFSRootDir,
|
"JuiceFSMountPoint": storage.BeOSJuiceFSRootDir,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return tplActions.Execute(runtime)
|
return tplActions.Execute(runtime)
|
||||||
|
|||||||
@@ -232,12 +232,12 @@ func (t *CreateSharedPathInMiniKubeContainer) Execute(runtime connector.Runtime)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get minikube command: %w", err)
|
return fmt.Errorf("failed to get minikube command: %w", err)
|
||||||
}
|
}
|
||||||
createCMD := fmt.Sprintf("%s ssh 'sudo mkdir -p %s' -p %s", minikube, storage.OlaresSharedLibDir, t.KubeConf.Arg.MinikubeProfile)
|
createCMD := fmt.Sprintf("%s ssh 'sudo mkdir -p %s' -p %s", minikube, storage.BeOSSharedLibDir, t.KubeConf.Arg.MinikubeProfile)
|
||||||
_, err = runtime.GetRunner().Cmd(createCMD, false, false)
|
_, err = runtime.GetRunner().Cmd(createCMD, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create shared path in minikube container: %w", err)
|
return fmt.Errorf("failed to create shared path in minikube container: %w", err)
|
||||||
}
|
}
|
||||||
chownCMD := fmt.Sprintf("%s ssh 'sudo chown 1000:1000 %s' -p %s", minikube, storage.OlaresSharedLibDir, t.KubeConf.Arg.MinikubeProfile)
|
chownCMD := fmt.Sprintf("%s ssh 'sudo chown 1000:1000 %s' -p %s", minikube, storage.BeOSSharedLibDir, t.KubeConf.Arg.MinikubeProfile)
|
||||||
_, err = runtime.GetRunner().Cmd(chownCMD, false, false)
|
_, err = runtime.GetRunner().Cmd(chownCMD, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to change ownership of shared path in minikube container: %w", err)
|
return fmt.Errorf("failed to change ownership of shared path in minikube container: %w", err)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func ChangeIP(runtime *common.KubeRuntime) *pipeline.Pipeline {
|
|||||||
runtime.Arg.HostIP = si.GetLocalIp()
|
runtime.Arg.HostIP = si.GetLocalIp()
|
||||||
modules = []module.Module{&terminus.ChangeHostIPModule{}}
|
modules = []module.Module{&terminus.ChangeHostIPModule{}}
|
||||||
} else {
|
} else {
|
||||||
logger.Infof("changing the Olares OS IP to %s ...", si.GetLocalIp())
|
logger.Infof("changing the beOS Pro IP to %s ...", si.GetLocalIp())
|
||||||
modules = []module.Module{
|
modules = []module.Module{
|
||||||
&terminus.CheckPreparedModule{},
|
&terminus.CheckPreparedModule{},
|
||||||
&terminus.CheckInstalledModule{},
|
&terminus.CheckInstalledModule{},
|
||||||
@@ -24,7 +24,7 @@ func ChangeIP(runtime *common.KubeRuntime) *pipeline.Pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &pipeline.Pipeline{
|
return &pipeline.Pipeline{
|
||||||
Name: "Change the IP address of Olares OS components",
|
Name: "Change the IP address of beOS Pro components",
|
||||||
Modules: modules,
|
Modules: modules,
|
||||||
Runtime: runtime,
|
Runtime: runtime,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ func UninstallTerminus(phase string, runtime *common.KubeRuntime) pipeline.Pipel
|
|||||||
}
|
}
|
||||||
|
|
||||||
return pipeline.Pipeline{
|
return pipeline.Pipeline{
|
||||||
Name: "Uninstall Olares",
|
Name: "Uninstall beOS Pro",
|
||||||
Runtime: builder.runtime,
|
Runtime: builder.runtime,
|
||||||
Modules: builder.modules,
|
Modules: builder.modules,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ type windowsUninstallPhaseBuilder struct {
|
|||||||
|
|
||||||
func (w *windowsUninstallPhaseBuilder) build() []module.Module {
|
func (w *windowsUninstallPhaseBuilder) build() []module.Module {
|
||||||
return []module.Module{
|
return []module.Module{
|
||||||
&windows.UninstallOlaresModule{},
|
&windows.UninstallBeOSModule{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func NewCheckDownload(mainifest string, runtime *common.KubeRuntime) *pipeline.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &pipeline.Pipeline{
|
return &pipeline.Pipeline{
|
||||||
Name: "Check Downloaded Olares Installation Package",
|
Name: "Check Downloaded beOS Pro Installation Package",
|
||||||
Modules: m,
|
Modules: m,
|
||||||
Runtime: runtime,
|
Runtime: runtime,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func NewDownloadPackage(mainifest string, runtime *common.KubeRuntime) *pipeline
|
|||||||
|
|
||||||
m := []module.Module{
|
m := []module.Module{
|
||||||
&precheck.GreetingsModule{},
|
&precheck.GreetingsModule{},
|
||||||
&download.PackageDownloadModule{Manifest: mainifest, BaseDir: runtime.GetBaseDir(), CDNService: runtime.Arg.OlaresCDNService},
|
&download.PackageDownloadModule{Manifest: mainifest, BaseDir: runtime.GetBaseDir(), CDNService: runtime.Arg.BeOSCDNService},
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pipeline.Pipeline{
|
return &pipeline.Pipeline{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func NewDownloadWizard(runtime *common.KubeRuntime, urlOverride, releaseID strin
|
|||||||
|
|
||||||
m := []module.Module{
|
m := []module.Module{
|
||||||
&precheck.GreetingsModule{},
|
&precheck.GreetingsModule{},
|
||||||
&terminus.InstallWizardDownloadModule{Version: runtime.Arg.OlaresVersion, CDNService: runtime.Arg.OlaresCDNService, UrlOverride: urlOverride, ReleaseID: releaseID},
|
&terminus.InstallWizardDownloadModule{Version: runtime.Arg.BeOSVersion, CDNService: runtime.Arg.BeOSCDNService, UrlOverride: urlOverride, ReleaseID: releaseID},
|
||||||
}
|
}
|
||||||
|
|
||||||
return &pipeline.Pipeline{
|
return &pipeline.Pipeline{
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"github.com/beclab/beos/cli/pkg/terminus"
|
"github.com/beclab/beos/cli/pkg/terminus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetOlaresVersion() (string, error) {
|
func GetBeOSVersion() (string, error) {
|
||||||
var terminusTask = &terminus.GetOlaresVersion{}
|
var terminusTask = &terminus.GetBeOSVersion{}
|
||||||
return terminusTask.Execute()
|
return terminusTask.Execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ import (
|
|||||||
func AddNodePipeline() error {
|
func AddNodePipeline() error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
if !arg.SystemInfo.IsLinux() {
|
if !arg.SystemInfo.IsLinux() {
|
||||||
fmt.Println("error: Only Linux nodes can be added to an Olares cluster!")
|
fmt.Println("error: Only Linux nodes can be added to an beOS Pro cluster!")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetConsoleLog("addnode.log", true)
|
arg.SetConsoleLog("addnode.log", true)
|
||||||
|
|
||||||
if err := arg.MasterHostConfig.Validate(); err != nil {
|
if err := arg.MasterHostConfig.Validate(); err != nil {
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ func ChangeIPPipeline() error {
|
|||||||
terminusVersion := viper.GetString(common.FlagVersion)
|
terminusVersion := viper.GetString(common.FlagVersion)
|
||||||
kubeType := phase.GetKubeType()
|
kubeType := phase.GetKubeType()
|
||||||
if terminusVersion == "" {
|
if terminusVersion == "" {
|
||||||
terminusVersion, _ = phase.GetOlaresVersion()
|
terminusVersion, _ = phase.GetBeOSVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
var arg = common.NewArgument()
|
var arg = common.NewArgument()
|
||||||
arg.SetOlaresVersion(terminusVersion)
|
arg.SetBeOSVersion(terminusVersion)
|
||||||
arg.SetConsoleLog("changeip.log", true)
|
arg.SetConsoleLog("changeip.log", true)
|
||||||
arg.SetKubeVersion(kubeType)
|
arg.SetKubeVersion(kubeType)
|
||||||
arg.SetMinikubeProfile(viper.GetString(common.FlagMiniKubeProfile))
|
arg.SetMinikubeProfile(viper.GetString(common.FlagMiniKubeProfile))
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func CheckDownloadInstallationPackage() error {
|
func CheckDownloadInstallationPackage() error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
|
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ import (
|
|||||||
|
|
||||||
func DownloadInstallationPackage() error {
|
func DownloadInstallationPackage() error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetOlaresCDNService(viper.GetString(common.FlagCDNService))
|
arg.SetBeOSCDNService(viper.GetString(common.FlagCDNService))
|
||||||
|
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok := utils.CheckUrl(arg.OlaresCDNService); !ok {
|
if ok := utils.CheckUrl(arg.BeOSCDNService); !ok {
|
||||||
return fmt.Errorf("invalid cdn service")
|
return fmt.Errorf("invalid cdn service")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ import (
|
|||||||
|
|
||||||
func DownloadInstallationWizard() error {
|
func DownloadInstallationWizard() error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetOlaresCDNService(viper.GetString(common.FlagCDNService))
|
arg.SetBeOSCDNService(viper.GetString(common.FlagCDNService))
|
||||||
|
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok := utils.CheckUrl(arg.OlaresCDNService); !ok {
|
if ok := utils.CheckUrl(arg.BeOSCDNService); !ok {
|
||||||
return fmt.Errorf("invalid cdn service")
|
return fmt.Errorf("invalid cdn service")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
func InstallGpuDrivers() error {
|
func InstallGpuDrivers() error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetConsoleLog("gpuinstall.log", true)
|
arg.SetConsoleLog("gpuinstall.log", true)
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func PrintTerminusInfo() {
|
func PrintTerminusInfo() {
|
||||||
var cli = &terminus.GetOlaresVersion{}
|
var cli = &terminus.GetBeOSVersion{}
|
||||||
terminusVersion, err := cli.Execute()
|
terminusVersion, err := cli.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Olares: not installed\n")
|
fmt.Printf("beOS Pro: not installed\n")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Olares: %s\n", terminusVersion)
|
fmt.Printf("beOS Pro: %s\n", terminusVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func CliInstallTerminusPipeline() error {
|
func CliInstallTerminusPipeline() error {
|
||||||
var terminusVersion, _ = phase.GetOlaresVersion()
|
var terminusVersion, _ = phase.GetBeOSVersion()
|
||||||
if terminusVersion != "" {
|
if terminusVersion != "" {
|
||||||
return errors.New("Olares is already installed, please uninstall it first.")
|
return errors.New("beOS Pro is already installed, please uninstall it first.")
|
||||||
}
|
}
|
||||||
|
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetKubeVersion(viper.GetString(common.FlagKubeType))
|
arg.SetKubeVersion(viper.GetString(common.FlagKubeType))
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetMinikubeProfile(viper.GetString(common.FlagMiniKubeProfile))
|
arg.SetMinikubeProfile(viper.GetString(common.FlagMiniKubeProfile))
|
||||||
arg.SetStorage(getStorageConfig())
|
arg.SetStorage(getStorageConfig())
|
||||||
arg.SetSwapConfig(common.SwapConfig{
|
arg.SetSwapConfig(common.SwapConfig{
|
||||||
@@ -49,7 +49,7 @@ func CliInstallTerminusPipeline() error {
|
|||||||
runtime.Arg.SetManifest(manifest)
|
runtime.Arg.SetManifest(manifest)
|
||||||
|
|
||||||
var p = cluster.InstallSystemPhase(runtime)
|
var p = cluster.InstallSystemPhase(runtime)
|
||||||
logger.InfoInstallationProgress("Start to Install Olares ...")
|
logger.InfoInstallationProgress("Start to Install beOS Pro ...")
|
||||||
if err := p.Start(); err != nil {
|
if err := p.Start(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
func MasterInfoPipeline() error {
|
func MasterInfoPipeline() error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
if !arg.SystemInfo.IsLinux() {
|
if !arg.SystemInfo.IsLinux() {
|
||||||
fmt.Println("error: Only Linux nodes can be added to an Olares cluster!")
|
fmt.Println("error: Only Linux nodes can be added to an beOS Pro cluster!")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
arg.SetConsoleLog("masterinfo.log", true)
|
arg.SetConsoleLog("masterinfo.log", true)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func StartPreCheckPipeline() error {
|
func StartPreCheckPipeline() error {
|
||||||
var arg = common.NewArgument()
|
var arg = common.NewArgument()
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetConsoleLog("precheck.log", true)
|
arg.SetConsoleLog("precheck.log", true)
|
||||||
|
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func PrepareSystemPipeline(components []string) error {
|
func PrepareSystemPipeline(components []string) error {
|
||||||
var terminusVersion, _ = phase.GetOlaresVersion()
|
var terminusVersion, _ = phase.GetBeOSVersion()
|
||||||
if terminusVersion != "" && len(components) == 0 {
|
if terminusVersion != "" && len(components) == 0 {
|
||||||
return errors.New("beOS Pro is already installed; uninstall it first")
|
return errors.New("beOS Pro is already installed; uninstall it first")
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ func PrepareSystemPipeline(components []string) error {
|
|||||||
var arg = common.NewArgument()
|
var arg = common.NewArgument()
|
||||||
arg.SetKubeVersion(viper.GetString(common.FlagKubeType))
|
arg.SetKubeVersion(viper.GetString(common.FlagKubeType))
|
||||||
arg.SetMinikubeProfile(viper.GetString(common.FlagMiniKubeProfile))
|
arg.SetMinikubeProfile(viper.GetString(common.FlagMiniKubeProfile))
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetStorage(getStorageConfig())
|
arg.SetStorage(getStorageConfig())
|
||||||
arg.ClearMasterHostConfig()
|
arg.ClearMasterHostConfig()
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ func PrepareSystemPipeline(components []string) error {
|
|||||||
p := &pipeline.Pipeline{
|
p := &pipeline.Pipeline{
|
||||||
Name: "Prepare beOS daemon",
|
Name: "Prepare beOS daemon",
|
||||||
Modules: []module.Module{
|
Modules: []module.Module{
|
||||||
&daemon.ReplaceOlaresdBinaryModule{
|
&daemon.ReplaceBeOSdBinaryModule{
|
||||||
ManifestModule: manifest.ManifestModule{
|
ManifestModule: manifest.ManifestModule{
|
||||||
Manifest: manifestMap,
|
Manifest: manifestMap,
|
||||||
BaseDir: runtime.GetBaseDir(),
|
BaseDir: runtime.GetBaseDir(),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/beclab/beos/cli/pkg/terminus"
|
"github.com/beclab/beos/cli/pkg/terminus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartOlares() error {
|
func StartBeOS() error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetConsoleLog("start.log", true)
|
arg.SetConsoleLog("start.log", true)
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
@@ -18,9 +18,9 @@ func StartOlares() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := &pipeline.Pipeline{
|
p := &pipeline.Pipeline{
|
||||||
Name: "StartOlares",
|
Name: "StartBeOS",
|
||||||
Modules: []module.Module{
|
Modules: []module.Module{
|
||||||
&terminus.StartOlaresModule{},
|
&terminus.StartBeOSModule{},
|
||||||
},
|
},
|
||||||
Runtime: runtime,
|
Runtime: runtime,
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ func StartOlares() error {
|
|||||||
return p.Start()
|
return p.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func StopOlares(timeout, checkInterval time.Duration) error {
|
func StopBeOS(timeout, checkInterval time.Duration) error {
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetConsoleLog("stop.log", true)
|
arg.SetConsoleLog("stop.log", true)
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
@@ -37,9 +37,9 @@ func StopOlares(timeout, checkInterval time.Duration) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := &pipeline.Pipeline{
|
p := &pipeline.Pipeline{
|
||||||
Name: "StopOlares",
|
Name: "StopBeOS",
|
||||||
Modules: []module.Module{
|
Modules: []module.Module{
|
||||||
&terminus.StopOlaresModule{
|
&terminus.StopBeOSModule{
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
CheckInterval: checkInterval,
|
CheckInterval: checkInterval,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func CliInstallStoragePipeline() error {
|
func CliInstallStoragePipeline() error {
|
||||||
var terminusVersion, _ = phase.GetOlaresVersion()
|
var terminusVersion, _ = phase.GetBeOSVersion()
|
||||||
if terminusVersion != "" {
|
if terminusVersion != "" {
|
||||||
return errors.New("Olares is already installed, please uninstall it first.")
|
return errors.New("beOS Pro is already installed, please uninstall it first.")
|
||||||
}
|
}
|
||||||
|
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetStorage(getStorageConfig())
|
arg.SetStorage(getStorageConfig())
|
||||||
|
|
||||||
runtime, err := common.NewKubeRuntime(*arg)
|
runtime, err := common.NewKubeRuntime(*arg)
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ func UninstallTerminusPipeline() error {
|
|||||||
kubeType := phase.GetKubeType()
|
kubeType := phase.GetKubeType()
|
||||||
|
|
||||||
if version == "" {
|
if version == "" {
|
||||||
version, _ = phase.GetOlaresVersion()
|
version, _ = phase.GetBeOSVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
var arg = common.NewArgument()
|
var arg = common.NewArgument()
|
||||||
arg.SetOlaresVersion(version)
|
arg.SetBeOSVersion(version)
|
||||||
arg.SetConsoleLog("uninstall.log", true)
|
arg.SetConsoleLog("uninstall.log", true)
|
||||||
arg.SetKubeVersion(kubeType)
|
arg.SetKubeVersion(kubeType)
|
||||||
arg.SetStorage(getStorageConfig())
|
arg.SetStorage(getStorageConfig())
|
||||||
@@ -43,7 +43,7 @@ func UninstallTerminusPipeline() error {
|
|||||||
|
|
||||||
var p = cluster.UninstallTerminus(phase, runtime)
|
var p = cluster.UninstallTerminus(phase, runtime)
|
||||||
if err := p.Start(); err != nil {
|
if err := p.Start(); err != nil {
|
||||||
logger.Errorf("uninstall Olares failed: %v", err)
|
logger.Errorf("uninstall beOS Pro failed: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,22 +17,22 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func UpgradeOlaresPipeline() error {
|
func UpgradeBeOSPipeline() error {
|
||||||
currentVersionString, err := phase.GetOlaresVersion()
|
currentVersionString, err := phase.GetBeOSVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to get current Olares version")
|
return errors.Wrap(err, "failed to get current beOS version")
|
||||||
}
|
}
|
||||||
if currentVersionString == "" {
|
if currentVersionString == "" {
|
||||||
return errors.New("Olares is not installed, please install it first")
|
return errors.New("beOS Pro is not installed, please install it first")
|
||||||
}
|
}
|
||||||
currentVersion, err := utils.ParseOlaresVersionString(currentVersionString)
|
currentVersion, err := utils.ParseBeOSVersionString(currentVersionString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing current Olares version: %v", err)
|
return fmt.Errorf("error parsing current beOS version: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
targetVersion, err := utils.ParseOlaresVersionString(version.VERSION)
|
targetVersion, err := utils.ParseBeOSVersionString(version.VERSION)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing target Olares version: %v", err)
|
return fmt.Errorf("error parsing target beOS version: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := upgrade.Check(currentVersion, targetVersion); err != nil {
|
if err := upgrade.Check(currentVersion, targetVersion); err != nil {
|
||||||
@@ -40,7 +40,7 @@ func UpgradeOlaresPipeline() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
arg := common.NewArgument()
|
arg := common.NewArgument()
|
||||||
arg.SetOlaresVersion(viper.GetString(common.FlagVersion))
|
arg.SetBeOSVersion(viper.GetString(common.FlagVersion))
|
||||||
arg.SetConsoleLog("upgrade.log", true)
|
arg.SetConsoleLog("upgrade.log", true)
|
||||||
arg.SetKubeVersion(phase.GetKubeType())
|
arg.SetKubeVersion(phase.GetKubeType())
|
||||||
|
|
||||||
@@ -57,17 +57,17 @@ func UpgradeOlaresPipeline() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := &pipeline.Pipeline{
|
p := &pipeline.Pipeline{
|
||||||
Name: "UpgradeOlares",
|
Name: "UpgradeBeOS",
|
||||||
Modules: []module.Module{upgradeModule},
|
Modules: []module.Module{upgradeModule},
|
||||||
Runtime: runtime,
|
Runtime: runtime,
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Infof("Starting Olares upgrade from %s to %s...", currentVersion, targetVersion)
|
logger.Infof("Starting beOS Pro upgrade from %s to %s...", currentVersion, targetVersion)
|
||||||
if err := p.Start(); err != nil {
|
if err := p.Start(); err != nil {
|
||||||
return errors.Wrap(err, "upgrade failed")
|
return errors.Wrap(err, "upgrade failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("Olares upgrade completed successfully!")
|
logger.Info("beOS Pro upgrade completed successfully!")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OlaresManifest struct {
|
type BeOSManifest struct {
|
||||||
APIVersion string `yaml:"apiVersion"`
|
APIVersion string `yaml:"apiVersion"`
|
||||||
Target string `yaml:"target"`
|
Target string `yaml:"target"`
|
||||||
Output OutputManifest `yaml:"output"`
|
Output OutputManifest `yaml:"output"`
|
||||||
@@ -60,7 +60,7 @@ func NewManager(olaresRepoRoot, distPath, cdnURL string, ignoreMissingImages boo
|
|||||||
|
|
||||||
func (m *Manager) Generate() error {
|
func (m *Manager) Generate() error {
|
||||||
if err := m.scan(); err != nil {
|
if err := m.scan(); err != nil {
|
||||||
return fmt.Errorf("failed to scan Olares repository for images and components: %v", err)
|
return fmt.Errorf("failed to scan beOS repository for images and components: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
manifestPath := filepath.Join(m.distPath, "installation.manifest")
|
manifestPath := filepath.Join(m.distPath, "installation.manifest")
|
||||||
@@ -189,7 +189,7 @@ func (m *Manager) scan() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// shortcut to Olares manifest file
|
// shortcut to beOS Pro manifest file
|
||||||
if strings.EqualFold(info.Name(), "olares.yaml") {
|
if strings.EqualFold(info.Name(), "olares.yaml") {
|
||||||
content, err := os.ReadFile(filePath)
|
content, err := os.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -198,7 +198,7 @@ func (m *Manager) scan() error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
olaresManifest := &OlaresManifest{}
|
olaresManifest := &BeOSManifest{}
|
||||||
err = yaml.Unmarshal(content, olaresManifest)
|
err = yaml.Unmarshal(content, olaresManifest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal olares manifest %s: %v", filePath, err)
|
return fmt.Errorf("failed to unmarshal olares manifest %s: %v", filePath, err)
|
||||||
@@ -357,16 +357,16 @@ func (m *Manager) patchImage(image string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) patchComponent(component BinaryOutput) (BinaryOutput, error) {
|
func (m *Manager) patchComponent(component BinaryOutput) (BinaryOutput, error) {
|
||||||
if component.ID != "olaresd" {
|
if component.ID != "beosd" && component.ID != "olaresd" {
|
||||||
return component, nil
|
return component, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
latestDailyBuildTag, latestDailyBuildCommit, err := m.getLatestDailyBuildTagAndCommit()
|
latestDailyBuildTag, latestDailyBuildCommit, err := m.getLatestDailyBuildTagAndCommit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return BinaryOutput{}, fmt.Errorf("failed to get latest daily build tag (required to replace olaresd version): %v", err)
|
return BinaryOutput{}, fmt.Errorf("failed to get latest daily build tag (required to replace beosd version): %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("patching olaresd version to %s\n", latestDailyBuildTag)
|
fmt.Printf("patching beosd version to %s\n", latestDailyBuildTag)
|
||||||
|
|
||||||
component.Name = strings.ReplaceAll(component.Name, "#__VERSION__", latestDailyBuildTag)
|
component.Name = strings.ReplaceAll(component.Name, "#__VERSION__", latestDailyBuildTag)
|
||||||
component.AMD64 = strings.ReplaceAll(component.AMD64, "#__VERSION__", latestDailyBuildTag)
|
component.AMD64 = strings.ReplaceAll(component.AMD64, "#__VERSION__", latestDailyBuildTag)
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Root = path.Join("/")
|
Root = path.Join("/")
|
||||||
StorageDataDir = path.Join(Root, "osdata")
|
StorageDataDir = path.Join(Root, "osdata")
|
||||||
StorageDataOlaresDir = path.Join(StorageDataDir, common.OlaresDir)
|
StorageDataBeOSDir = path.Join(StorageDataDir, common.BeOSDir)
|
||||||
OlaresRootDir = path.Join(Root, common.OlaresDir)
|
BeOSRootDir = path.Join(Root, common.BeOSDir)
|
||||||
OlaresSharedLibDir = path.Join(OlaresRootDir, "share")
|
BeOSSharedLibDir = path.Join(BeOSRootDir, "share")
|
||||||
OlaresUserDataDir = path.Join(OlaresRootDir, "userdata")
|
BeOSUserDataDir = path.Join(BeOSRootDir, "userdata")
|
||||||
|
|
||||||
RedisRootDir = path.Join(OlaresRootDir, "data", "redis")
|
RedisRootDir = path.Join(BeOSRootDir, "data", "redis")
|
||||||
RedisConfigDir = path.Join(RedisRootDir, "etc")
|
RedisConfigDir = path.Join(RedisRootDir, "etc")
|
||||||
RedisDataDir = path.Join(RedisRootDir, "data")
|
RedisDataDir = path.Join(RedisRootDir, "data")
|
||||||
RedisLogDir = path.Join(RedisRootDir, "log")
|
RedisLogDir = path.Join(RedisRootDir, "log")
|
||||||
@@ -28,14 +28,14 @@ var (
|
|||||||
RedisServerInstalledFile = path.Join(Root, "usr", "local", "bin", "redis-server")
|
RedisServerInstalledFile = path.Join(Root, "usr", "local", "bin", "redis-server")
|
||||||
RedisCliInstalledFile = path.Join(Root, "usr", "local", "bin", "redis-cli")
|
RedisCliInstalledFile = path.Join(Root, "usr", "local", "bin", "redis-cli")
|
||||||
|
|
||||||
JuiceFsFile = path.Join(Root, "usr", "local", "bin", "juicefs")
|
JuiceFsFile = path.Join(Root, "usr", "local", "bin", "juicefs")
|
||||||
JuiceFsDataDir = path.Join(OlaresRootDir, "data", "juicefs")
|
JuiceFsDataDir = path.Join(BeOSRootDir, "data", "juicefs")
|
||||||
JuiceFsCacheDir = path.Join(OlaresRootDir, "jfscache")
|
JuiceFsCacheDir = path.Join(BeOSRootDir, "jfscache")
|
||||||
OlaresJuiceFSRootDir = path.Join(OlaresRootDir, "rootfs")
|
BeOSJuiceFSRootDir = path.Join(BeOSRootDir, "rootfs")
|
||||||
JuiceFsServiceFile = path.Join(Root, "etc", "systemd", "system", templates.JuicefsService.Name())
|
JuiceFsServiceFile = path.Join(Root, "etc", "systemd", "system", templates.JuicefsService.Name())
|
||||||
|
|
||||||
MinioRootUser = "minioadmin"
|
MinioRootUser = "minioadmin"
|
||||||
MinioDataDir = path.Join(OlaresRootDir, "data", "minio", "vol1")
|
MinioDataDir = path.Join(BeOSRootDir, "data", "minio", "vol1")
|
||||||
MinioFile = path.Join(Root, "usr", "local", "bin", "minio")
|
MinioFile = path.Join(Root, "usr", "local", "bin", "minio")
|
||||||
MinioServiceFile = path.Join(Root, "etc", "systemd", "system", "minio.service")
|
MinioServiceFile = path.Join(Root, "etc", "systemd", "system", "minio.service")
|
||||||
MinioConfigFile = path.Join(Root, "etc", "default", "minio")
|
MinioConfigFile = path.Join(Root, "etc", "default", "minio")
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ func (t *EnableJuiceFsService) Execute(runtime connector.Runtime) error {
|
|||||||
"JuiceFsBinPath": JuiceFsFile,
|
"JuiceFsBinPath": JuiceFsFile,
|
||||||
"JuiceFsCachePath": JuiceFsCacheDir,
|
"JuiceFsCachePath": JuiceFsCacheDir,
|
||||||
"JuiceFsMetaDb": redisService,
|
"JuiceFsMetaDb": redisService,
|
||||||
"JuiceFsMountPoint": OlaresJuiceFSRootDir,
|
"JuiceFsMountPoint": BeOSJuiceFSRootDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
juiceFsServiceStr, err := util.Render(juicefsTemplates.JuicefsService, data)
|
juiceFsServiceStr, err := util.Render(juicefsTemplates.JuicefsService, data)
|
||||||
@@ -210,7 +210,7 @@ func (t *CheckJuiceFsState) Execute(runtime connector.Runtime) error {
|
|||||||
|
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("%s summary %s", JuiceFsFile, OlaresJuiceFSRootDir), false, false); err != nil {
|
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("%s summary %s", JuiceFsFile, BeOSJuiceFSRootDir), false, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ func getManagedMinIOAccessFlags(localIp string) (string, error) {
|
|||||||
return "", errors.Wrap(err, "failed to get password of managed MinIO")
|
return "", errors.Wrap(err, "failed to get password of managed MinIO")
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(" --storage minio --bucket http://%s:9000/%s --access-key %s --secret-key %s",
|
return fmt.Sprintf(" --storage minio --bucket http://%s:9000/%s --access-key %s --secret-key %s",
|
||||||
localIp, cc.OlaresDir, MinioRootUser, minioPassword), nil
|
localIp, cc.BeOSDir, MinioRootUser, minioPassword), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRootFSType() string {
|
func GetRootFSType() string {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func (m *RemoveStorageModule) Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeTerminusFiles := &task.RemoteTask{
|
removeTerminusFiles := &task.RemoteTask{
|
||||||
Name: "RemoveOlaresFiles",
|
Name: "RemoveBeOSFiles",
|
||||||
Hosts: m.Runtime.GetHostsByRole(common.Master),
|
Hosts: m.Runtime.GetHostsByRole(common.Master),
|
||||||
Prepare: &prepare.PrepareCollection{
|
Prepare: &prepare.PrepareCollection{
|
||||||
new(common.OnlyFirstMaster),
|
new(common.OnlyFirstMaster),
|
||||||
@@ -239,10 +239,10 @@ type DeleteTerminusDataModule struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *DeleteTerminusDataModule) Init() {
|
func (m *DeleteTerminusDataModule) Init() {
|
||||||
m.Name = "DeleteOlaresData"
|
m.Name = "DeleteBeOSData"
|
||||||
|
|
||||||
deleteTerminusData := &task.RemoteTask{
|
deleteTerminusData := &task.RemoteTask{
|
||||||
Name: "DeleteOlaresData",
|
Name: "DeleteBeOSData",
|
||||||
Hosts: m.Runtime.GetHostsByRole(common.Master),
|
Hosts: m.Runtime.GetHostsByRole(common.Master),
|
||||||
Action: new(DeleteTerminusData),
|
Action: new(DeleteTerminusData),
|
||||||
Parallel: false,
|
Parallel: false,
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ type MkStorageDir struct {
|
|||||||
|
|
||||||
func (t *MkStorageDir) Execute(runtime connector.Runtime) error {
|
func (t *MkStorageDir) Execute(runtime connector.Runtime) error {
|
||||||
if utils.IsExist(StorageDataDir) {
|
if utils.IsExist(StorageDataDir) {
|
||||||
if utils.IsExist(cc.OlaresDir) {
|
if utils.IsExist(cc.BeOSDir) {
|
||||||
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf %s", cc.OlaresDir), false, false)
|
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf %s", cc.BeOSDir), false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("mkdir -p %s", StorageDataOlaresDir), false, false); err != nil {
|
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("mkdir -p %s", StorageDataBeOSDir), false, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("ln -s %s %s", StorageDataOlaresDir, cc.OlaresDir), false, false); err != nil {
|
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("ln -s %s %s", StorageDataBeOSDir, cc.BeOSDir), false, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,9 +229,9 @@ func (t *StopJuiceFS) Execute(runtime connector.Runtime) error {
|
|||||||
|
|
||||||
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf /var/jfsCache %s", JuiceFsCacheDir), false, false)
|
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf /var/jfsCache %s", JuiceFsCacheDir), false, false)
|
||||||
|
|
||||||
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("umount %s", OlaresJuiceFSRootDir), false, false)
|
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("umount %s", BeOSJuiceFSRootDir), false, false)
|
||||||
|
|
||||||
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf %s", OlaresJuiceFSRootDir), false, false)
|
_, _ = runtime.GetRunner().SudoCmd(fmt.Sprintf("rm -rf %s", BeOSJuiceFSRootDir), false, false)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -331,12 +331,12 @@ type DeleteTerminusUserData struct {
|
|||||||
|
|
||||||
func (t *DeleteTerminusUserData) Execute(runtime connector.Runtime) error {
|
func (t *DeleteTerminusUserData) Execute(runtime connector.Runtime) error {
|
||||||
userdataDirs := []string{
|
userdataDirs := []string{
|
||||||
OlaresUserDataDir,
|
BeOSUserDataDir,
|
||||||
JuiceFsCacheDir,
|
JuiceFsCacheDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
if util.IsExist(RedisServiceFile) {
|
if util.IsExist(RedisServiceFile) {
|
||||||
userdataDirs = append(userdataDirs, OlaresJuiceFSRootDir)
|
userdataDirs = append(userdataDirs, BeOSJuiceFSRootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, d := range userdataDirs {
|
for _, d := range userdataDirs {
|
||||||
@@ -357,13 +357,13 @@ type DeleteTerminusData struct {
|
|||||||
func (t *DeleteTerminusData) Execute(runtime connector.Runtime) error {
|
func (t *DeleteTerminusData) Execute(runtime connector.Runtime) error {
|
||||||
var dirs []string
|
var dirs []string
|
||||||
var shareExists bool
|
var shareExists bool
|
||||||
filepath.WalkDir(OlaresRootDir, func(path string, d fs.DirEntry, err error) error {
|
filepath.WalkDir(BeOSRootDir, func(path string, d fs.DirEntry, err error) error {
|
||||||
if path != OlaresRootDir {
|
if path != BeOSRootDir {
|
||||||
if !d.IsDir() {
|
if !d.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(path, OlaresSharedLibDir) {
|
if strings.HasPrefix(path, BeOSSharedLibDir) {
|
||||||
shareExists = true
|
shareExists = true
|
||||||
} else {
|
} else {
|
||||||
dirs = append(dirs, path)
|
dirs = append(dirs, path)
|
||||||
@@ -382,8 +382,8 @@ func (t *DeleteTerminusData) Execute(runtime connector.Runtime) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !shareExists {
|
if !shareExists {
|
||||||
if err := util.RemoveDir(OlaresRootDir); err != nil {
|
if err := util.RemoveDir(BeOSRootDir); err != nil {
|
||||||
logger.Errorf("remove %s failed %v", OlaresRootDir, err)
|
logger.Errorf("remove %s failed %v", BeOSRootDir, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ func (t *CreateSharedLibDir) Execute(runtime connector.Runtime) error {
|
|||||||
if runtime.GetSystemInfo().IsDarwin() {
|
if runtime.GetSystemInfo().IsDarwin() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("mkdir -p %s && chown 1000:1000 %s", OlaresSharedLibDir, OlaresSharedLibDir), false, false); err != nil {
|
if _, err := runtime.GetRunner().SudoCmd(fmt.Sprintf("mkdir -p %s && chown 1000:1000 %s", BeOSSharedLibDir, BeOSSharedLibDir), false, false); err != nil {
|
||||||
return errors.Wrap(errors.WithStack(err), "failed to create shared lib dir")
|
return errors.Wrap(errors.WithStack(err), "failed to create shared lib dir")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ func (s *GetUserInfo) Execute(runtime connector.Runtime) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Infof("using Olares Local Name: %s", s.KubeConf.Arg.User.UserName)
|
logger.Infof("using beOS Pro Local Name: %s", s.KubeConf.Arg.User.UserName)
|
||||||
s.KubeConf.Arg.User.Email, err = s.getUserEmail()
|
s.KubeConf.Arg.User.Email, err = s.getUserEmail()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.Infof("using Olares ID: %s", s.KubeConf.Arg.User.Email)
|
logger.Infof("using beOS ID: %s", s.KubeConf.Arg.User.Email)
|
||||||
s.KubeConf.Arg.User.Password, s.KubeConf.Arg.User.EncryptedPassword, err = s.getUserPassword()
|
s.KubeConf.Arg.User.Password, s.KubeConf.Arg.User.EncryptedPassword, err = s.getUserPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -106,7 +106,7 @@ func (s *GetUserInfo) getUserName() (string, error) {
|
|||||||
return "", errors.Wrap(err, "failed to get terminal input reader")
|
return "", errors.Wrap(err, "failed to get terminal input reader")
|
||||||
}
|
}
|
||||||
LOOP:
|
LOOP:
|
||||||
fmt.Printf("\nEnter the Olares ID (which you registered in the LarePass app): ")
|
fmt.Printf("\nEnter your beOS ID: ")
|
||||||
userName, err = reader.ReadString('\n')
|
userName, err = reader.ReadString('\n')
|
||||||
if err != nil && err.Error() != "EOF" {
|
if err != nil && err.Error() != "EOF" {
|
||||||
return "", errors.Wrap(errors.WithStack(err), "read username failed")
|
return "", errors.Wrap(errors.WithStack(err), "read username failed")
|
||||||
@@ -135,7 +135,7 @@ func (s *GetUserInfo) getUserEmail() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *GetUserInfo) getUserPassword() (string, string, error) {
|
func (s *GetUserInfo) getUserPassword() (string, string, error) {
|
||||||
// currently only used in the installation flow by LarePass -> Olaresd,
|
// currently only used by the companion-app -> beOSd installation flow,
|
||||||
// when this env var is passed in, it is already encrypted
|
// when this env var is passed in, it is already encrypted
|
||||||
// make this one priority over the password set in the arg specailly
|
// make this one priority over the password set in the arg specailly
|
||||||
// to ensure the larepass installation flow works as expected
|
// to ensure the larepass installation flow works as expected
|
||||||
|
|||||||
@@ -123,10 +123,10 @@ func (u *PrepareAppValues) Execute(runtime connector.Runtime) error {
|
|||||||
"username": u.KubeConf.Arg.User.UserName,
|
"username": u.KubeConf.Arg.User.UserName,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"gpu": gpuType,
|
"gpu": gpuType,
|
||||||
"fs_type": fsType,
|
"fs_type": fsType,
|
||||||
"os": appValues,
|
"os": appValues,
|
||||||
common.HelmValuesKeyOlaresRootFSPath: storage.OlaresRootDir,
|
common.HelmValuesKeyBeOSRootFSPath: storage.BeOSRootDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
u.ModuleCache.Set(common.CacheAppValues, values)
|
u.ModuleCache.Set(common.CacheAppValues, values)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func (t *InstallBFL) Execute(runtime connector.Runtime) error {
|
|||||||
"appKey": key,
|
"appKey": key,
|
||||||
"appSecret": secret,
|
"appSecret": secret,
|
||||||
}
|
}
|
||||||
vals[common.HelmValuesKeyOlaresRootFSPath] = storage.OlaresRootDir
|
vals[common.HelmValuesKeyBeOSRootFSPath] = storage.BeOSRootDir
|
||||||
|
|
||||||
if err := utils.UpgradeCharts(ctx, actionConfig, settings, launchName, launchPath, "", ns, vals, false); err != nil {
|
if err := utils.UpgradeCharts(ctx, actionConfig, settings, launchName, launchPath, "", ns, vals, false); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -259,14 +259,14 @@ func serviceExists(serviceName string) bool {
|
|||||||
return util.IsExist(path.Join(systemdUnitDir, serviceName))
|
return util.IsExist(path.Join(systemdUnitDir, serviceName))
|
||||||
}
|
}
|
||||||
|
|
||||||
type StopOlaresModule struct {
|
type StopBeOSModule struct {
|
||||||
common.KubeModule
|
common.KubeModule
|
||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
CheckInterval time.Duration
|
CheckInterval time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *StopOlaresModule) Init() {
|
func (m *StopBeOSModule) Init() {
|
||||||
m.Name = "StopOlares"
|
m.Name = "StopBeOS"
|
||||||
|
|
||||||
newStopServiceTask := func(serviceName string) task.Interface {
|
newStopServiceTask := func(serviceName string) task.Interface {
|
||||||
return &task.LocalTask{
|
return &task.LocalTask{
|
||||||
@@ -324,21 +324,21 @@ func (m *StopOlaresModule) Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(m.Tasks) == 0 {
|
if len(m.Tasks) == 0 {
|
||||||
logger.Info("found no components of Olares, please install Olares first")
|
logger.Info("found no components of beOS Pro, please install beOS Pro first")
|
||||||
logger.Info("exiting ...")
|
logger.Info("exiting ...")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
} else if !k3sServiceExists && !kubeletServiceExists {
|
} else if !k3sServiceExists && !kubeletServiceExists {
|
||||||
logger.Warn("kubernetes service can not be found, it seems that Olares has not been installed yet")
|
logger.Warn("kubernetes service can not be found, it seems that beOS Pro has not been installed yet")
|
||||||
logger.Warn("will try to stop any other base components that we can find")
|
logger.Warn("will try to stop any other base components that we can find")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type StartOlaresModule struct {
|
type StartBeOSModule struct {
|
||||||
common.KubeModule
|
common.KubeModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *StartOlaresModule) Init() {
|
func (m *StartBeOSModule) Init() {
|
||||||
m.Name = "StartOlares"
|
m.Name = "StartBeOS"
|
||||||
|
|
||||||
newStartServiceTask := func(serviceName string) task.Interface {
|
newStartServiceTask := func(serviceName string) task.Interface {
|
||||||
return &task.LocalTask{
|
return &task.LocalTask{
|
||||||
@@ -376,13 +376,13 @@ func (m *StartOlaresModule) Init() {
|
|||||||
m.Tasks = append(m.Tasks, newStartServiceTask(kubeletServiceName))
|
m.Tasks = append(m.Tasks, newStartServiceTask(kubeletServiceName))
|
||||||
}
|
}
|
||||||
if len(m.Tasks) == 0 {
|
if len(m.Tasks) == 0 {
|
||||||
logger.Info("found no components of Olares, please install Olares first")
|
logger.Info("found no components of beOS Pro, please install beOS Pro first")
|
||||||
logger.Info("exiting ...")
|
logger.Info("exiting ...")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
} else if k3sServiceExists || kubeletServiceExists {
|
} else if k3sServiceExists || kubeletServiceExists {
|
||||||
m.Tasks = append(m.Tasks, &task.LocalTask{
|
m.Tasks = append(m.Tasks, &task.LocalTask{
|
||||||
|
|
||||||
// when starting an already stopped Olares, which is the normal use case
|
// when starting an already stopped beOS Pro, which is the normal use case
|
||||||
// it's very likely for this program to outrun kubelet
|
// it's very likely for this program to outrun kubelet
|
||||||
// and retrieve a pod list from kube-apiserver that is a "snapshot" of the cluster state
|
// and retrieve a pod list from kube-apiserver that is a "snapshot" of the cluster state
|
||||||
// when the kubernetes components was killed, before. i.e. the data will say all the pods are running while they're actually not
|
// when the kubernetes components was killed, before. i.e. the data will say all the pods are running while they're actually not
|
||||||
@@ -399,7 +399,7 @@ func (m *StartOlaresModule) Init() {
|
|||||||
Retry: 60,
|
Retry: 60,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.Warn("kubernetes service can not be found, it seems that Olares has not been installed yet")
|
logger.Warn("kubernetes service can not be found, it seems that beOS Pro has not been installed yet")
|
||||||
logger.Warn("will try to start any other base components that we can find")
|
logger.Warn("will try to start any other base components that we can find")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +414,7 @@ func (m *ChangeIPModule) Init() {
|
|||||||
|
|
||||||
prepared, _ := m.PipelineCache.GetMustBool(common.CachePreparedState)
|
prepared, _ := m.PipelineCache.GetMustBool(common.CachePreparedState)
|
||||||
if !prepared {
|
if !prepared {
|
||||||
logger.Info("the Olares OS is not prepared, will only try to update /etc/hosts")
|
logger.Info("the beOS Pro is not prepared, will only try to update /etc/hosts")
|
||||||
}
|
}
|
||||||
m.Tasks = []task.Interface{
|
m.Tasks = []task.Interface{
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
@@ -429,7 +429,7 @@ func (m *ChangeIPModule) Init() {
|
|||||||
|
|
||||||
installed, _ := m.PipelineCache.GetMustBool(common.CacheInstalledState)
|
installed, _ := m.PipelineCache.GetMustBool(common.CacheInstalledState)
|
||||||
if !installed && prepared {
|
if !installed && prepared {
|
||||||
logger.Info("the Olares OS is not installed, will only try to update prepared base components")
|
logger.Info("the beOS Pro is not installed, will only try to update prepared base components")
|
||||||
}
|
}
|
||||||
|
|
||||||
if installed {
|
if installed {
|
||||||
@@ -744,7 +744,7 @@ func (m *ChangeHostIPModule) Init() {
|
|||||||
|
|
||||||
m.Tasks = append(m.Tasks,
|
m.Tasks = append(m.Tasks,
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
Name: "CheckOlaresStateInHost",
|
Name: "CheckBeOSStateInHost",
|
||||||
Action: new(CheckTerminusStateInHost),
|
Action: new(CheckTerminusStateInHost),
|
||||||
},
|
},
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (s *GetNATGatewayIP) Execute(runtime connector.Runtime) error {
|
|||||||
} else {
|
} else {
|
||||||
input = hostIP
|
input = hostIP
|
||||||
}
|
}
|
||||||
case s.KubeConf.Arg.IsOlaresInContainer:
|
case s.KubeConf.Arg.IsBeOSInContainer:
|
||||||
if hostIP == "" {
|
if hostIP == "" {
|
||||||
return errors.Errorf("host ip not found")
|
return errors.Errorf("host ip not found")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ func (t *InstallOsSystem) Execute(runtime connector.Runtime) error {
|
|||||||
"is_cloud_version": cloudValue(t.KubeConf.Arg.IsCloudInstance),
|
"is_cloud_version": cloudValue(t.KubeConf.Arg.IsCloudInstance),
|
||||||
"sync_secret": t.KubeConf.Arg.Storage.StorageSyncSecret,
|
"sync_secret": t.KubeConf.Arg.Storage.StorageSyncSecret,
|
||||||
},
|
},
|
||||||
"gpu": getGpuType(t.KubeConf.Arg.GPU.Enable),
|
"gpu": getGpuType(t.KubeConf.Arg.GPU.Enable),
|
||||||
"s3_bucket": t.KubeConf.Arg.Storage.StorageBucket,
|
"s3_bucket": t.KubeConf.Arg.Storage.StorageBucket,
|
||||||
"fs_type": storage.GetRootFSType(),
|
"fs_type": storage.GetRootFSType(),
|
||||||
common.HelmValuesKeyOlaresRootFSPath: storage.OlaresRootDir,
|
common.HelmValuesKeyBeOSRootFSPath: storage.BeOSRootDir,
|
||||||
"sharedlib": storage.OlaresSharedLibDir,
|
"sharedlib": storage.BeOSSharedLibDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
var platformPath = path.Join(runtime.GetInstallerDir(), "wizard", "config", "os-platform")
|
var platformPath = path.Join(runtime.GetInstallerDir(), "wizard", "config", "os-platform")
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetOlaresVersion struct {
|
type GetBeOSVersion struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *GetOlaresVersion) Execute() (string, error) {
|
func (t *GetBeOSVersion) Execute() (string, error) {
|
||||||
var kubectlpath, err = util.GetCommand(common.CommandKubectl)
|
var kubectlpath, err = util.GetCommand(common.CommandKubectl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("kubectl not found, beOS Pro might not be installed")
|
return "", fmt.Errorf("kubectl not found, beOS Pro might not be installed")
|
||||||
@@ -159,7 +159,7 @@ type Download struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Download) Execute(runtime connector.Runtime) error {
|
func (t *Download) Execute(runtime connector.Runtime) error {
|
||||||
if t.UrlOverride == "" && t.KubeConf.Arg.OlaresVersion == "" {
|
if t.UrlOverride == "" && t.KubeConf.Arg.BeOSVersion == "" {
|
||||||
return errors.New("unknown version to download")
|
return errors.New("unknown version to download")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ type PrepareFinished struct {
|
|||||||
|
|
||||||
func (t *PrepareFinished) Execute(runtime connector.Runtime) error {
|
func (t *PrepareFinished) Execute(runtime connector.Runtime) error {
|
||||||
var preparedFile = filepath.Join(runtime.GetBaseDir(), common.TerminusStateFilePrepared)
|
var preparedFile = filepath.Join(runtime.GetBaseDir(), common.TerminusStateFilePrepared)
|
||||||
return util.WriteFile(preparedFile, []byte(t.KubeConf.Arg.OlaresVersion), cc.FileMode0644)
|
return util.WriteFile(preparedFile, []byte(t.KubeConf.Arg.BeOSVersion), cc.FileMode0644)
|
||||||
// if _, err := runtime.GetRunner().Cmd(fmt.Sprintf("touch %s", preparedFile), false, true); err != nil {
|
// if _, err := runtime.GetRunner().Cmd(fmt.Sprintf("touch %s", preparedFile), false, true); err != nil {
|
||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
@@ -247,8 +247,8 @@ type WriteReleaseFile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *WriteReleaseFile) Execute(runtime connector.Runtime) error {
|
func (t *WriteReleaseFile) Execute(runtime connector.Runtime) error {
|
||||||
if util.IsExist(common.OlaresReleaseFile) {
|
if util.IsExist(common.BeOSReleaseFile) {
|
||||||
logger.Debugf("found existing release file: %s, overriding ...", common.OlaresReleaseFile)
|
logger.Debugf("found existing release file: %s, overriding ...", common.BeOSReleaseFile)
|
||||||
}
|
}
|
||||||
return t.KubeConf.Arg.SaveReleaseInfo(t.WithoutName)
|
return t.KubeConf.Arg.SaveReleaseInfo(t.WithoutName)
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ type RemoveReleaseFile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *RemoveReleaseFile) Execute(runtime connector.Runtime) error {
|
func (t *RemoveReleaseFile) Execute(runtime connector.Runtime) error {
|
||||||
err := os.Remove(common.OlaresReleaseFile)
|
err := os.Remove(common.BeOSReleaseFile)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ type InstallFinished struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *InstallFinished) Execute(runtime connector.Runtime) error {
|
func (t *InstallFinished) Execute(runtime connector.Runtime) error {
|
||||||
var content = fmt.Sprintf("%s %s", t.KubeConf.Arg.OlaresVersion, t.KubeConf.Arg.Kubetype)
|
var content = fmt.Sprintf("%s %s", t.KubeConf.Arg.BeOSVersion, t.KubeConf.Arg.Kubetype)
|
||||||
var phaseState = path.Join(runtime.GetBaseDir(), common.TerminusStateFileInstalled)
|
var phaseState = path.Join(runtime.GetBaseDir(), common.TerminusStateFileInstalled)
|
||||||
if err := util.WriteFile(phaseState, []byte(content), cc.FileMode0644); err != nil {
|
if err := util.WriteFile(phaseState, []byte(content), cc.FileMode0644); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -898,9 +898,9 @@ type GetMasterInfo struct {
|
|||||||
type MasterInfo struct {
|
type MasterInfo struct {
|
||||||
JuiceFSEnabled bool
|
JuiceFSEnabled bool
|
||||||
KubernetesInstalled bool
|
KubernetesInstalled bool
|
||||||
OlaresInstalled bool
|
BeOSInstalled bool
|
||||||
KubernetesType string
|
KubernetesType string
|
||||||
OlaresVersion string
|
BeOSVersion string
|
||||||
MasterNodeName string
|
MasterNodeName string
|
||||||
AllNodes []string
|
AllNodes []string
|
||||||
}
|
}
|
||||||
@@ -913,7 +913,7 @@ func (t *GetMasterInfo) Execute(runtime connector.Runtime) (err error) {
|
|||||||
}
|
}
|
||||||
if t.Print {
|
if t.Print {
|
||||||
logger.Infof("Got master info:\nBeOSVersion: %s\nJuiceFSEnabled: %t\nKubernetesType: %s\nMasterNodeName: %s\nAllNodes: %s\n",
|
logger.Infof("Got master info:\nBeOSVersion: %s\nJuiceFSEnabled: %t\nKubernetesType: %s\nMasterNodeName: %s\nAllNodes: %s\n",
|
||||||
masterInfo.OlaresVersion, masterInfo.JuiceFSEnabled, masterInfo.KubernetesType, masterInfo.MasterNodeName, strings.Join(masterInfo.AllNodes, ","))
|
masterInfo.BeOSVersion, masterInfo.JuiceFSEnabled, masterInfo.KubernetesType, masterInfo.MasterNodeName, strings.Join(masterInfo.AllNodes, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
t.PipelineCache.Set(common.MasterInfo, masterInfo)
|
t.PipelineCache.Set(common.MasterInfo, masterInfo)
|
||||||
@@ -925,7 +925,7 @@ func (t *GetMasterInfo) Execute(runtime connector.Runtime) (err error) {
|
|||||||
if !exist {
|
if !exist {
|
||||||
masterInfo.JuiceFSEnabled = false
|
masterInfo.JuiceFSEnabled = false
|
||||||
} else {
|
} else {
|
||||||
juiceFSCheckCMD := fmt.Sprintf("%s info %s", storage.JuiceFsFile, storage.OlaresJuiceFSRootDir)
|
juiceFSCheckCMD := fmt.Sprintf("%s info %s", storage.JuiceFsFile, storage.BeOSJuiceFSRootDir)
|
||||||
output, err := runtime.GetRunner().SudoCmd(juiceFSCheckCMD, false, false)
|
output, err := runtime.GetRunner().SudoCmd(juiceFSCheckCMD, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to check JuiceFS status")
|
return errors.Wrap(err, "failed to check JuiceFS status")
|
||||||
@@ -966,13 +966,13 @@ func (t *GetMasterInfo) Execute(runtime connector.Runtime) (err error) {
|
|||||||
output, err = runtime.GetRunner().SudoCmd(olaresVersionCMD, false, false)
|
output, err = runtime.GetRunner().SudoCmd(olaresVersionCMD, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "the server doesn't have a resource type") {
|
if strings.Contains(err.Error(), "the server doesn't have a resource type") {
|
||||||
masterInfo.OlaresInstalled = false
|
masterInfo.BeOSInstalled = false
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.Wrap(err, "failed to get beOS Pro version (is it installed?)")
|
return errors.Wrap(err, "failed to get beOS Pro version (is it installed?)")
|
||||||
}
|
}
|
||||||
masterInfo.OlaresInstalled = true
|
masterInfo.BeOSInstalled = true
|
||||||
masterInfo.OlaresVersion = strings.TrimSpace(output)
|
masterInfo.BeOSVersion = strings.TrimSpace(output)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1004,7 +1004,7 @@ func (a *AddNodePrecheck) Execute(runtime connector.Runtime) error {
|
|||||||
if !masterInfo.KubernetesInstalled {
|
if !masterInfo.KubernetesInstalled {
|
||||||
errs = append(errs, errors.New("[Kubernetes] the master node has not installed Kubernetes"))
|
errs = append(errs, errors.New("[Kubernetes] the master node has not installed Kubernetes"))
|
||||||
}
|
}
|
||||||
if !masterInfo.OlaresInstalled {
|
if !masterInfo.BeOSInstalled {
|
||||||
errs = append(errs, errors.New("[beOS Pro] the master node has not installed beOS Pro"))
|
errs = append(errs, errors.New("[beOS Pro] the master node has not installed beOS Pro"))
|
||||||
}
|
}
|
||||||
for _, node := range masterInfo.AllNodes {
|
for _, node := range masterInfo.AllNodes {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func (t *WelcomeMessage) Execute(runtime connector.Runtime) error {
|
|||||||
logger.InfoInstallationProgress("Installation wizard is complete")
|
logger.InfoInstallationProgress("Installation wizard is complete")
|
||||||
logger.InfoInstallationProgress("All done")
|
logger.InfoInstallationProgress("All done")
|
||||||
fmt.Printf("\n\n\n\n------------------------------------------------\n\n")
|
fmt.Printf("\n\n\n\n------------------------------------------------\n\n")
|
||||||
logger.Info("Olares is running locally at:")
|
logger.Info("beOS Pro is running locally at:")
|
||||||
logger.Infof("http://%s:%d", localIP, port)
|
logger.Infof("http://%s:%d", localIP, port)
|
||||||
if len(filteredPublicIPs) > 0 {
|
if len(filteredPublicIPs) > 0 {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
@@ -86,7 +86,7 @@ type WelcomeModule struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *WelcomeModule) Init() {
|
func (m *WelcomeModule) Init() {
|
||||||
logger.InfoInstallationProgress("Starting Olares ...")
|
logger.InfoInstallationProgress("Starting beOS Pro ...")
|
||||||
m.Name = "Welcome"
|
m.Name = "Welcome"
|
||||||
|
|
||||||
waitServicesReady := &task.LocalTask{
|
waitServicesReady := &task.LocalTask{
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func (u upgrader_1_12_3_20251127) NeedRestart() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// put GPU driver upgrade step at the very end right before updating the version
|
// put GPU driver upgrade step at the very end right before updating the version
|
||||||
func (u upgrader_1_12_3_20251127) UpdateOlaresVersion() []task.Interface {
|
func (u upgrader_1_12_3_20251127) UpdateBeOSVersion() []task.Interface {
|
||||||
var tasks []task.Interface
|
var tasks []task.Interface
|
||||||
tasks = append(tasks,
|
tasks = append(tasks,
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
@@ -26,7 +26,7 @@ func (u upgrader_1_12_3_20251127) UpdateOlaresVersion() []task.Interface {
|
|||||||
Action: new(upgradeGPUDriverIfNeeded),
|
Action: new(upgradeGPUDriverIfNeeded),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
tasks = append(tasks, u.upgraderBase.UpdateOlaresVersion()...)
|
tasks = append(tasks, u.upgraderBase.UpdateBeOSVersion()...)
|
||||||
tasks = append(tasks,
|
tasks = append(tasks,
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
Name: "RebootIfNeeded",
|
Name: "RebootIfNeeded",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (u upgrader_1_12_3_20251217) NeedRestart() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u upgrader_1_12_3_20251217) UpdateOlaresVersion() []task.Interface {
|
func (u upgrader_1_12_3_20251217) UpdateBeOSVersion() []task.Interface {
|
||||||
var tasks []task.Interface
|
var tasks []task.Interface
|
||||||
tasks = append(tasks,
|
tasks = append(tasks,
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
@@ -50,7 +50,7 @@ func (u upgrader_1_12_3_20251217) UpdateOlaresVersion() []task.Interface {
|
|||||||
Action: new(upgradeGPUDriverIfNeeded),
|
Action: new(upgradeGPUDriverIfNeeded),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
tasks = append(tasks, u.upgraderBase.UpdateOlaresVersion()...)
|
tasks = append(tasks, u.upgraderBase.UpdateBeOSVersion()...)
|
||||||
tasks = append(tasks,
|
tasks = append(tasks,
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
Name: "RebootIfNeeded",
|
Name: "RebootIfNeeded",
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ func (u upgrader_1_12_4) UpgradeSystemComponents() []task.Interface {
|
|||||||
return append(pre, u.upgraderBase.UpgradeSystemComponents()...)
|
return append(pre, u.upgraderBase.UpgradeSystemComponents()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u upgrader_1_12_4) UpdateOlaresVersion() []task.Interface {
|
func (u upgrader_1_12_4) UpdateBeOSVersion() []task.Interface {
|
||||||
var tasks []task.Interface
|
var tasks []task.Interface
|
||||||
tasks = append(tasks,
|
tasks = append(tasks,
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
@@ -77,7 +77,7 @@ func (u upgrader_1_12_4) UpdateOlaresVersion() []task.Interface {
|
|||||||
Action: new(upgradeGPUDriverIfNeeded),
|
Action: new(upgradeGPUDriverIfNeeded),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
tasks = append(tasks, u.upgraderBase.UpdateOlaresVersion()...)
|
tasks = append(tasks, u.upgraderBase.UpdateBeOSVersion()...)
|
||||||
tasks = append(tasks,
|
tasks = append(tasks,
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
Name: "RebootIfNeeded",
|
Name: "RebootIfNeeded",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
iamv1alpha2 "github.com/beclab/api/iam/v1alpha2"
|
||||||
"github.com/beclab/beos/cli/pkg/common"
|
"github.com/beclab/beos/cli/pkg/common"
|
||||||
"github.com/beclab/beos/cli/pkg/core/connector"
|
"github.com/beclab/beos/cli/pkg/core/connector"
|
||||||
"github.com/beclab/beos/cli/pkg/core/logger"
|
"github.com/beclab/beos/cli/pkg/core/logger"
|
||||||
@@ -14,7 +15,6 @@ import (
|
|||||||
"github.com/beclab/beos/cli/pkg/gpu"
|
"github.com/beclab/beos/cli/pkg/gpu"
|
||||||
"github.com/beclab/beos/cli/pkg/terminus"
|
"github.com/beclab/beos/cli/pkg/terminus"
|
||||||
"github.com/beclab/beos/cli/pkg/utils"
|
"github.com/beclab/beos/cli/pkg/utils"
|
||||||
iamv1alpha2 "github.com/beclab/api/iam/v1alpha2"
|
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
kruntime "k8s.io/apimachinery/pkg/runtime"
|
kruntime "k8s.io/apimachinery/pkg/runtime"
|
||||||
@@ -143,11 +143,11 @@ func (u upgraderBase) UpgradeSystemComponents() []task.Interface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u upgraderBase) UpdateOlaresVersion() []task.Interface {
|
func (u upgraderBase) UpdateBeOSVersion() []task.Interface {
|
||||||
return []task.Interface{
|
return []task.Interface{
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
Name: "UpdateOlaresVersion",
|
Name: "UpdateBeOSVersion",
|
||||||
Action: new(updateOlaresVersion),
|
Action: new(updateBeOSVersion),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,11 +386,11 @@ func (u *upgradeSystemComponents) Execute(runtime connector.Runtime) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type updateOlaresVersion struct {
|
type updateBeOSVersion struct {
|
||||||
common.KubeAction
|
common.KubeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *updateOlaresVersion) Execute(runtime connector.Runtime) error {
|
func (u *updateBeOSVersion) Execute(runtime connector.Runtime) error {
|
||||||
config, err := ctrl.GetConfig()
|
config, err := ctrl.GetConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get rest config: %s", err)
|
return fmt.Errorf("failed to get rest config: %s", err)
|
||||||
@@ -403,7 +403,7 @@ func (u *updateOlaresVersion) Execute(runtime connector.Runtime) error {
|
|||||||
defer cancelSettings()
|
defer cancelSettings()
|
||||||
settingsChartPath := path.Join(runtime.GetInstallerDir(), "wizard", "config", "settings")
|
settingsChartPath := path.Join(runtime.GetInstallerDir(), "wizard", "config", "settings")
|
||||||
|
|
||||||
vals := map[string]interface{}{"version": u.KubeConf.Arg.OlaresVersion}
|
vals := map[string]interface{}{"version": u.KubeConf.Arg.BeOSVersion}
|
||||||
if err := utils.UpgradeCharts(ctx, actionConfig, settings, common.ChartNameSettings, settingsChartPath, "", common.NamespaceDefault, vals, true); err != nil {
|
if err := utils.UpgradeCharts(ctx, actionConfig, settings, common.ChartNameSettings, settingsChartPath, "", common.NamespaceDefault, vals, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type upgrader interface {
|
|||||||
UpgradeUserComponents() []task.Interface
|
UpgradeUserComponents() []task.Interface
|
||||||
UpdateReleaseFile() []task.Interface
|
UpdateReleaseFile() []task.Interface
|
||||||
UpgradeSystemComponents() []task.Interface
|
UpgradeSystemComponents() []task.Interface
|
||||||
UpdateOlaresVersion() []task.Interface
|
UpdateBeOSVersion() []task.Interface
|
||||||
PostUpgrade() []task.Interface
|
PostUpgrade() []task.Interface
|
||||||
AddedBreakingChange() bool
|
AddedBreakingChange() bool
|
||||||
NeedRestart() bool
|
NeedRestart() bool
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type Module struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Module) Init() {
|
func (m *Module) Init() {
|
||||||
m.Name = "UpgradeOlares"
|
m.Name = "UpgradeBeOS"
|
||||||
|
|
||||||
u := getUpgraderByVersion(m.TargetVersion)
|
u := getUpgraderByVersion(m.TargetVersion)
|
||||||
m.Tasks = append(m.Tasks, u.PrepareForUpgrade()...)
|
m.Tasks = append(m.Tasks, u.PrepareForUpgrade()...)
|
||||||
@@ -26,7 +26,7 @@ func (m *Module) Init() {
|
|||||||
m.Tasks = append(m.Tasks, u.UpgradeSystemComponents()...)
|
m.Tasks = append(m.Tasks, u.UpgradeSystemComponents()...)
|
||||||
m.Tasks = append(m.Tasks, u.UpgradeUserComponents()...)
|
m.Tasks = append(m.Tasks, u.UpgradeUserComponents()...)
|
||||||
m.Tasks = append(m.Tasks, u.UpdateReleaseFile()...)
|
m.Tasks = append(m.Tasks, u.UpdateReleaseFile()...)
|
||||||
m.Tasks = append(m.Tasks, u.UpdateOlaresVersion()...)
|
m.Tasks = append(m.Tasks, u.UpdateBeOSVersion()...)
|
||||||
m.Tasks = append(m.Tasks, u.PostUpgrade()...)
|
m.Tasks = append(m.Tasks, u.PostUpgrade()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ func Check(base *semver.Version, target *semver.Version) error {
|
|||||||
return fmt.Errorf("base version is nil")
|
return fmt.Errorf("base version is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
cliVersion, err := utils.ParseOlaresVersionString(version.VERSION)
|
cliVersion, err := utils.ParseBeOSVersionString(version.VERSION)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid olares-cli version :\"%s\"", version.VERSION)
|
return fmt.Errorf("invalid beos-cli version :\"%s\"", version.VERSION)
|
||||||
}
|
}
|
||||||
|
|
||||||
if target != nil {
|
if target != nil {
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ const (
|
|||||||
"report": [
|
"report": [
|
||||||
{
|
{
|
||||||
"lv": [
|
"lv": [
|
||||||
{"lv_name":"data", "vg_name":"olares-vg", "lv_attr":"-wi-ao----", "lv_size":"1.76t", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""},
|
{"lv_name":"data", "vg_name":"beos-vg", "lv_attr":"-wi-ao----", "lv_size":"1.76t", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""},
|
||||||
{"lv_name":"root", "vg_name":"olares-vg", "lv_attr":"-wi-ao----", "lv_size":"100.00g", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""},
|
{"lv_name":"root", "vg_name":"beos-vg", "lv_attr":"-wi-ao----", "lv_size":"100.00g", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""},
|
||||||
{"lv_name":"swap", "vg_name":"olares-vg", "lv_attr":"-wi-ao----", "lv_size":"1.00g", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""}
|
{"lv_name":"swap", "vg_name":"beos-vg", "lv_attr":"-wi-ao----", "lv_size":"1.00g", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -67,7 +67,7 @@ func CommandLVS() *command[LvsResult] {
|
|||||||
"report": [
|
"report": [
|
||||||
{
|
{
|
||||||
"vg": [
|
"vg": [
|
||||||
{"vg_name":"olares-vg", "pv_count":"1", "lv_count":"3", "snap_count":"0", "vg_attr":"wz--n-", "vg_size":"1.86t", "vg_free":"0 "}
|
{"vg_name":"beos-vg", "pv_count":"1", "lv_count":"3", "snap_count":"0", "vg_attr":"wz--n-", "vg_size":"1.86t", "vg_free":"0 "}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -110,7 +110,7 @@ func CommandVGS() *command[VgsResult] {
|
|||||||
"report": [
|
"report": [
|
||||||
{
|
{
|
||||||
"pv": [
|
"pv": [
|
||||||
{"pv_name":"/dev/nvme0n1p2", "vg_name":"olares-vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"1.86t", "pv_free":"0 "}
|
{"pv_name":"/dev/nvme0n1p2", "vg_name":"beos-vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"1.86t", "pv_free":"0 "}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ func GenerateEncryptedPassword(length int) (string, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func EncryptPassword(plainText string) string {
|
func EncryptPassword(plainText string) string {
|
||||||
return utils.MD5(plainText + "@Olares2025")
|
return utils.MD5(plainText + "@beOSPro2025")
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveAnsiCodes(input string) string {
|
func RemoveAnsiCodes(input string) string {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package utils
|
|||||||
|
|
||||||
import "github.com/Masterminds/semver/v3"
|
import "github.com/Masterminds/semver/v3"
|
||||||
|
|
||||||
func ParseOlaresVersionString(versionString string) (*semver.Version, error) {
|
func ParseBeOSVersionString(versionString string) (*semver.Version, error) {
|
||||||
// todo: maybe some other custom processing only for olares
|
// todo: maybe some other custom processing only for olares
|
||||||
return semver.NewVersion(versionString)
|
return semver.NewVersion(versionString)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ This package mostly exists to maintain parity with the structure of other web5 S
|
|||||||
|
|
||||||
### Key Generation
|
### Key Generation
|
||||||
|
|
||||||
the `dsa` package provides [algorithm IDs](https://github.com/beclab/Olares/cli/pkg/web5/blob/5d50ce8f24e4b47b0a8626724e8a571e9b5c847f/crypto/dsa/dsa.go#L11-L14) that can be passed to the `GenerateKey` function e.g.
|
the `dsa` package provides [algorithm IDs](https://github.com/beclab/beOS Pro/cli/pkg/web5/blob/5d50ce8f24e4b47b0a8626724e8a571e9b5c847f/crypto/dsa/dsa.go#L11-L14) that can be passed to the `GenerateKey` function e.g.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package main
|
package main
|
||||||
@@ -42,7 +42,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/crypto/dsa"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/crypto/dsa"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -64,7 +64,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/crypto/dsa"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/crypto/dsa"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -95,7 +95,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/crypto/dsa"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/crypto/dsa"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -81,7 +81,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -110,8 +110,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/dsa"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/dsa"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -148,8 +148,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/dsa"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/dsa"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/dids"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/dids"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -180,8 +180,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/did"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/did"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -213,7 +213,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/did"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/did"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/jws"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/jws"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -56,8 +56,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/jws"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/jws"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -86,8 +86,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/jws"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/jws"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -116,8 +116,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/jws"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/jws"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ func initDB() {
|
|||||||
|
|
||||||
// CheckJWSResult represents the result of checking a JWS
|
// CheckJWSResult represents the result of checking a JWS
|
||||||
type CheckJWSResult struct {
|
type CheckJWSResult struct {
|
||||||
OlaresID string `json:"olares_id"`
|
BeOSID string `json:"olares_id"`
|
||||||
Body interface{} `json:"body"`
|
Body interface{} `json:"body"`
|
||||||
KID string `json:"kid"`
|
KID string `json:"kid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolveDID resolves a DID either from cache or from the DID gate
|
// resolveDID resolves a DID either from cache or from the DID gate
|
||||||
func ResolveOlaresName(gateUrl, olares_id string) (*didcore.ResolutionResult, error) {
|
func ResolveBeOSName(gateUrl, olares_id string) (*didcore.ResolutionResult, error) {
|
||||||
name := strings.Replace(olares_id, "@", ".", -1)
|
name := strings.Replace(olares_id, "@", ".", -1)
|
||||||
// Try to get from cache first
|
// Try to get from cache first
|
||||||
cached, err := getDB().Get([]byte(name), nil)
|
cached, err := getDB().Get([]byte(name), nil)
|
||||||
@@ -197,7 +197,7 @@ func CheckJWS(gateUrl, jws string, duration int64) (*CheckJWSResult, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve DID
|
// Resolve DID
|
||||||
resolutionResult, err := ResolveOlaresName(gateUrl, name)
|
resolutionResult, err := ResolveBeOSName(gateUrl, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to resolve DID: %w", err)
|
return nil, fmt.Errorf("failed to resolve DID: %w", err)
|
||||||
}
|
}
|
||||||
@@ -230,9 +230,9 @@ func CheckJWS(gateUrl, jws string, duration int64) (*CheckJWSResult, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := CheckJWSResult{
|
result := CheckJWSResult{
|
||||||
OlaresID: name,
|
BeOSID: name,
|
||||||
Body: payload,
|
Body: payload,
|
||||||
KID: kid,
|
KID: kid,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result, nil
|
return &result, nil
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/didjwk"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/didjwk"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/jwt"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/jwt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -48,8 +48,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/dids"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/dids"
|
||||||
"github.com/beclab/Olares/cli/pkg/web5/jwt"
|
"github.com/beclab/beOS Pro/cli/pkg/web5/jwt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -128,16 +128,16 @@ func (i *InstallTerminusModule) Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type UninstallOlaresModule struct {
|
type UninstallBeOSModule struct {
|
||||||
common.KubeModule
|
common.KubeModule
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UninstallOlaresModule) Init() {
|
func (u *UninstallBeOSModule) Init() {
|
||||||
u.Name = "UninstallBeOS"
|
u.Name = "UninstallBeOS"
|
||||||
u.Tasks = []task.Interface{
|
u.Tasks = []task.Interface{
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
Name: "UninstallBeOS",
|
Name: "UninstallBeOS",
|
||||||
Action: &UninstallOlares{},
|
Action: &UninstallBeOS{},
|
||||||
},
|
},
|
||||||
&task.LocalTask{
|
&task.LocalTask{
|
||||||
Name: "RemoveFirewallRule",
|
Name: "RemoveFirewallRule",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ const (
|
|||||||
ubuntuTool = "ubuntu.exe"
|
ubuntuTool = "ubuntu.exe"
|
||||||
distro = "Ubuntu"
|
distro = "Ubuntu"
|
||||||
|
|
||||||
OLARES_WINDOWS_FIREWALL_RULE_NAME = "OlaresRule"
|
OLARES_WINDOWS_FIREWALL_RULE_NAME = "BeOSRule"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DownloadAppxPackage struct {
|
type DownloadAppxPackage struct {
|
||||||
@@ -37,7 +37,7 @@ type DownloadAppxPackage struct {
|
|||||||
|
|
||||||
func (d *DownloadAppxPackage) Execute(runtime connector.Runtime) error {
|
func (d *DownloadAppxPackage) Execute(runtime connector.Runtime) error {
|
||||||
var systemInfo = runtime.GetSystemInfo()
|
var systemInfo = runtime.GetSystemInfo()
|
||||||
var cdnService = getCDNService(d.KubeConf.Arg.OlaresCDNService)
|
var cdnService = getCDNService(d.KubeConf.Arg.BeOSCDNService)
|
||||||
|
|
||||||
appx := files.NewKubeBinary("wsl", systemInfo.GetOsArch(), systemInfo.GetOsType(), systemInfo.GetOsVersion(), systemInfo.GetOsPlatformFamily(), "2204", fmt.Sprintf("%s\\%s\\%s\\%s", systemInfo.GetHomeDir(), cc.DefaultBaseDir, "pkg", "components"), cdnService)
|
appx := files.NewKubeBinary("wsl", systemInfo.GetOsArch(), systemInfo.GetOsType(), systemInfo.GetOsVersion(), systemInfo.GetOsPlatformFamily(), "2204", fmt.Sprintf("%s\\%s\\%s\\%s", systemInfo.GetHomeDir(), cc.DefaultBaseDir, "pkg", "components"), cdnService)
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ type DownloadWSLInstallPackage struct {
|
|||||||
|
|
||||||
func (d *DownloadWSLInstallPackage) Execute(runtime connector.Runtime) error {
|
func (d *DownloadWSLInstallPackage) Execute(runtime connector.Runtime) error {
|
||||||
var systemInfo = runtime.GetSystemInfo()
|
var systemInfo = runtime.GetSystemInfo()
|
||||||
var cdnService = getCDNService(d.KubeConf.Arg.OlaresCDNService)
|
var cdnService = getCDNService(d.KubeConf.Arg.BeOSCDNService)
|
||||||
var osArch = systemInfo.GetOsArch()
|
var osArch = systemInfo.GetOsArch()
|
||||||
var osType = systemInfo.GetOsType()
|
var osType = systemInfo.GetOsType()
|
||||||
var osVersion = systemInfo.GetOsVersion()
|
var osVersion = systemInfo.GetOsVersion()
|
||||||
@@ -437,7 +437,7 @@ func (c *ConfigWindowsFirewallRule) Execute(runtime connector.Runtime) error {
|
|||||||
scanner := bufio.NewScanner(os.Stdin)
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
fmt.Print("\nAccessing Olares requires setting up firewall rules, specifically adding TCP inbound rules for ports 80, 443, and 30180.\nDo you want to set up the firewall rules? (yes/no): ")
|
fmt.Print("\nAccessing beOS Pro requires setting up firewall rules, specifically adding TCP inbound rules for ports 80, 443, and 30180.\nDo you want to set up the firewall rules? (yes/no): ")
|
||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
confirmation := scanner.Text()
|
confirmation := scanner.Text()
|
||||||
confirmation = strings.TrimSpace(confirmation)
|
confirmation = strings.TrimSpace(confirmation)
|
||||||
@@ -457,7 +457,7 @@ func (c *ConfigWindowsFirewallRule) Execute(runtime connector.Runtime) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !setFirewallRule {
|
if !setFirewallRule {
|
||||||
fmt.Printf("\nFirewall settings have been skipped. \nIf you want to access the Olares application, please go to the Windows Defender Firewall rules and add an inbound rule for TCP protocol with port numbers 80, 443, and 30180.\n\n\n")
|
fmt.Printf("\nFirewall settings have been skipped. \nIf you want to access the beOS Pro application, please go to the Windows Defender Firewall rules and add an inbound rule for TCP protocol with port numbers 80, 443, and 30180.\n\n\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ func (i *InstallTerminus) Execute(runtime connector.Runtime) error {
|
|||||||
fmt.Sprintf("export %s=%s", common.ENV_PREINSTALL, os.Getenv(common.ENV_PREINSTALL)),
|
fmt.Sprintf("export %s=%s", common.ENV_PREINSTALL, os.Getenv(common.ENV_PREINSTALL)),
|
||||||
fmt.Sprintf("export %s=%s", common.ENV_HOST_IP, systemInfo.GetLocalIp()),
|
fmt.Sprintf("export %s=%s", common.ENV_HOST_IP, systemInfo.GetLocalIp()),
|
||||||
fmt.Sprintf("export %s=%s", common.ENV_DISABLE_HOST_IP_PROMPT, os.Getenv(common.ENV_DISABLE_HOST_IP_PROMPT)),
|
fmt.Sprintf("export %s=%s", common.ENV_DISABLE_HOST_IP_PROMPT, os.Getenv(common.ENV_DISABLE_HOST_IP_PROMPT)),
|
||||||
fmt.Sprintf("export %s=%s", common.ENV_OLARES_CDN_SERVICE, i.KubeConf.Arg.OlaresCDNService),
|
fmt.Sprintf("export %s=%s", common.ENV_OLARES_CDN_SERVICE, i.KubeConf.Arg.BeOSCDNService),
|
||||||
}
|
}
|
||||||
|
|
||||||
var bashUrl = fmt.Sprintf("https://%s", cc.DefaultBashUrl)
|
var bashUrl = fmt.Sprintf("https://%s", cc.DefaultBashUrl)
|
||||||
@@ -504,13 +504,13 @@ func (i *InstallTerminus) Execute(runtime connector.Runtime) error {
|
|||||||
bashUrl = fmt.Sprintf("https://%s", defaultDomainName)
|
bashUrl = fmt.Sprintf("https://%s", defaultDomainName)
|
||||||
}
|
}
|
||||||
|
|
||||||
var cdnService = i.KubeConf.Arg.OlaresCDNService
|
var cdnService = i.KubeConf.Arg.BeOSCDNService
|
||||||
if cdnService == "" {
|
if cdnService == "" {
|
||||||
cdnService = cc.DefaultOlaresCDNService
|
cdnService = cc.DefaultBeOSCDNService
|
||||||
}
|
}
|
||||||
var installScript = fmt.Sprintf("curl -fsSL %s | bash -", bashUrl)
|
var installScript = fmt.Sprintf("curl -fsSL %s | bash -", bashUrl)
|
||||||
if i.KubeConf.Arg.OlaresVersion != "" {
|
if i.KubeConf.Arg.BeOSVersion != "" {
|
||||||
var installFile = fmt.Sprintf("install-wizard-v%s.tar.gz", i.KubeConf.Arg.OlaresVersion)
|
var installFile = fmt.Sprintf("install-wizard-v%s.tar.gz", i.KubeConf.Arg.BeOSVersion)
|
||||||
installScript = fmt.Sprintf("curl -fsSLO %s/%s && tar -xf %s -C ./ ./install.sh && rm -rf %s && bash ./install.sh",
|
installScript = fmt.Sprintf("curl -fsSLO %s/%s && tar -xf %s -C ./ ./install.sh && rm -rf %s && bash ./install.sh",
|
||||||
cdnService, installFile, installFile, installFile)
|
cdnService, installFile, installFile, installFile)
|
||||||
}
|
}
|
||||||
@@ -523,7 +523,7 @@ func (i *InstallTerminus) Execute(runtime connector.Runtime) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := cmd.Exec(); err != nil {
|
if _, err := cmd.Exec(); err != nil {
|
||||||
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("install Olares %s failed", distro))
|
return errors.Wrap(errors.WithStack(err), fmt.Sprintf("install beOS Pro %s failed", distro))
|
||||||
}
|
}
|
||||||
|
|
||||||
exec.Command("cmd", "/C", "wsl", "-d", distro, "--exec", "dbus-launch", "true").Run()
|
exec.Command("cmd", "/C", "wsl", "-d", distro, "--exec", "dbus-launch", "true").Run()
|
||||||
@@ -541,11 +541,11 @@ func convertPath(windowsPath string) string {
|
|||||||
return linuxPath
|
return linuxPath
|
||||||
}
|
}
|
||||||
|
|
||||||
type UninstallOlares struct {
|
type UninstallBeOS struct {
|
||||||
common.KubeAction
|
common.KubeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UninstallOlares) Execute(runtime connector.Runtime) error {
|
func (u *UninstallBeOS) Execute(runtime connector.Runtime) error {
|
||||||
var cmd = &utils.DefaultCommandExecutor{
|
var cmd = &utils.DefaultCommandExecutor{
|
||||||
Commands: []string{"--unregister", "Ubuntu"},
|
Commands: []string{"--unregister", "Ubuntu"},
|
||||||
}
|
}
|
||||||
@@ -602,7 +602,7 @@ func (g *GetDiskPartition) Execute(runtime connector.Runtime) error {
|
|||||||
if len(partitions) == 0 {
|
if len(partitions) == 0 {
|
||||||
return fmt.Errorf("Unable to retrieve disk space information")
|
return fmt.Errorf("Unable to retrieve disk space information")
|
||||||
}
|
}
|
||||||
fmt.Printf("\nInstalling Olares will create a WSL Ubuntu Distro and occupy at least 80 GB of disk space. \nPlease select the drive where you want to install it. \nAvailable drives and free space:\n")
|
fmt.Printf("\nInstalling beOS Pro will create a WSL Ubuntu Distro and occupy at least 80 GB of disk space. \nPlease select the drive where you want to install it. \nAvailable drives and free space:\n")
|
||||||
for _, v := range partitions {
|
for _, v := range partitions {
|
||||||
var tmp = strings.Split(v, "_")
|
var tmp = strings.Split(v, "_")
|
||||||
fmt.Printf("%s Free Disk: %s\n", tmp[0], tmp[1])
|
fmt.Printf("%s Free Disk: %s\n", tmp[0], tmp[1])
|
||||||
@@ -657,7 +657,7 @@ func (g *GetDiskPartition) checkEnter(enterPath string, partitions []string) boo
|
|||||||
func getCDNService(cdnServiceFromEnv string) string {
|
func getCDNService(cdnServiceFromEnv string) string {
|
||||||
cdnService := strings.TrimSuffix(cdnServiceFromEnv, "/")
|
cdnService := strings.TrimSuffix(cdnServiceFromEnv, "/")
|
||||||
if cdnService == "" {
|
if cdnService == "" {
|
||||||
cdnService = cc.DefaultOlaresCDNService
|
cdnService = cc.DefaultBeOSCDNService
|
||||||
}
|
}
|
||||||
return cdnService
|
return cdnService
|
||||||
}
|
}
|
||||||
@@ -667,11 +667,11 @@ func showUbuntuErrorMsg(msg string, err error) error {
|
|||||||
fmt.Printf(`
|
fmt.Printf(`
|
||||||
Stop Installation !!!!!!!
|
Stop Installation !!!!!!!
|
||||||
|
|
||||||
Installing Windows Olares will use the Ubuntu Distro. It has been detected that there is already an existing Ubuntu Distro in the system.
|
Installing Windows beOS Pro will use the Ubuntu Distro. It has been detected that there is already an existing Ubuntu Distro in the system.
|
||||||
You can use the 'wsl -l --all' command to view the list of WSL Distros.
|
You can use the 'wsl -l --all' command to view the list of WSL Distros.
|
||||||
To proceed with the installation of Olares, you need to unregister the existing Ubuntu Distro. If your Ubuntu Distro contains important information, please back it up first, then unregister the Ubuntu Distro.
|
To proceed with the installation of beOS Pro, you need to unregister the existing Ubuntu Distro. If your Ubuntu Distro contains important information, please back it up first, then unregister the Ubuntu Distro.
|
||||||
Uninstallation command: 'wsl --unregister Ubuntu'
|
Uninstallation command: 'wsl --unregister Ubuntu'
|
||||||
After the unregister Ubuntu Distro is complete, please reinstall Olares.
|
After the unregister Ubuntu Distro is complete, please reinstall beOS Pro.
|
||||||
|
|
||||||
Error message: %v
|
Error message: %v
|
||||||
`, err)
|
`, err)
|
||||||
|
|||||||
@@ -26,52 +26,52 @@ func NewClient(state ClientState, sender Sender) *Client {
|
|||||||
func (c *Client) StartAuthRequest(params StartAuthRequestParams) (*StartAuthRequestResponse, error) {
|
func (c *Client) StartAuthRequest(params StartAuthRequestParams) (*StartAuthRequestResponse, error) {
|
||||||
// Build request parameters
|
// Build request parameters
|
||||||
requestParams := []interface{}{params}
|
requestParams := []interface{}{params}
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
response, err := c.call("startAuthRequest", requestParams)
|
response, err := c.call("startAuthRequest", requestParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse response
|
// Parse response
|
||||||
var result StartAuthRequestResponse
|
var result StartAuthRequestResponse
|
||||||
if err := c.parseResponse(response.Result, &result); err != nil {
|
if err := c.parseResponse(response.Result, &result); err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse StartAuthRequest response: %v", err)
|
return nil, fmt.Errorf("failed to parse StartAuthRequest response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CompleteAuthRequest(params CompleteAuthRequestParams) (*CompleteAuthRequestResponse, error) {
|
func (c *Client) CompleteAuthRequest(params CompleteAuthRequestParams) (*CompleteAuthRequestResponse, error) {
|
||||||
// Build request parameters
|
// Build request parameters
|
||||||
requestParams := []interface{}{params}
|
requestParams := []interface{}{params}
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
response, err := c.call("completeAuthRequest", requestParams)
|
response, err := c.call("completeAuthRequest", requestParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse response
|
// Parse response
|
||||||
var result CompleteAuthRequestResponse
|
var result CompleteAuthRequestResponse
|
||||||
if err := c.parseResponse(response.Result, &result); err != nil {
|
if err := c.parseResponse(response.Result, &result); err != nil {
|
||||||
return nil, fmt.Errorf("failed to parse CompleteAuthRequest response: %v", err)
|
return nil, fmt.Errorf("failed to parse CompleteAuthRequest response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic RPC call method
|
// Generic RPC call method
|
||||||
func (c *Client) call(method string, params []interface{}) (*Response, error) {
|
func (c *Client) call(method string, params []interface{}) (*Response, error) {
|
||||||
session := c.State.GetSession()
|
session := c.State.GetSession()
|
||||||
|
|
||||||
// Build request
|
// Build request
|
||||||
req := &Request{
|
req := &Request{
|
||||||
Method: method,
|
Method: method,
|
||||||
Params: params,
|
Params: params,
|
||||||
Device: c.State.GetDevice(),
|
Device: c.State.GetDevice(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// If session exists, add authentication info
|
// If session exists, add authentication info
|
||||||
if session != nil {
|
if session != nil {
|
||||||
auth, err := c.authenticateRequest(req, session)
|
auth, err := c.authenticateRequest(req, session)
|
||||||
@@ -79,19 +79,19 @@ func (c *Client) call(method string, params []interface{}) (*Response, error) {
|
|||||||
return nil, fmt.Errorf("failed to authenticate request: %v", err)
|
return nil, fmt.Errorf("failed to authenticate request: %v", err)
|
||||||
}
|
}
|
||||||
req.Auth = auth
|
req.Auth = auth
|
||||||
|
|
||||||
// Temporary debug: print full request JSON
|
// Temporary debug: print full request JSON
|
||||||
if reqJSON, err := json.Marshal(req); err == nil {
|
if reqJSON, err := json.Marshal(req); err == nil {
|
||||||
log.Printf("Full request JSON: %s", string(reqJSON))
|
log.Printf("Full request JSON: %s", string(reqJSON))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
response, err := c.Sender.Send(req)
|
response, err := c.Sender.Send(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to send request: %v", err)
|
return nil, fmt.Errorf("failed to send request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check response error
|
// Check response error
|
||||||
if response.Error != nil {
|
if response.Error != nil {
|
||||||
return nil, NewAuthError(
|
return nil, NewAuthError(
|
||||||
@@ -100,14 +100,14 @@ func (c *Client) call(method string, params []interface{}) (*Response, error) {
|
|||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If session exists, verify response
|
// If session exists, verify response
|
||||||
if session != nil {
|
if session != nil {
|
||||||
if err := c.verifyResponse(response, session); err != nil {
|
if err := c.verifyResponse(response, session); err != nil {
|
||||||
return nil, fmt.Errorf("failed to verify response: %v", err)
|
return nil, fmt.Errorf("failed to verify response: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,18 +116,18 @@ func (c *Client) authenticateRequest(req *Request, session *Session) (*RequestAu
|
|||||||
if session.Key == nil {
|
if session.Key == nil {
|
||||||
return nil, fmt.Errorf("session key is nil")
|
return nil, fmt.Errorf("session key is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Build timestamp
|
// 1. Build timestamp
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
// 2. Serialize request data (ref: session.ts line 158: data = req.params)
|
// 2. Serialize request data (ref: session.ts line 158: data = req.params)
|
||||||
data := req.Params // Use entire params array directly, not just first element
|
data := req.Params // Use entire params array directly, not just first element
|
||||||
|
|
||||||
dataJSON, err := json.Marshal(data)
|
dataJSON, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to marshal request data: %v", err)
|
return nil, fmt.Errorf("failed to marshal request data: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Build signature message (ref: session.ts line 179)
|
// 3. Build signature message (ref: session.ts line 179)
|
||||||
// Format: ${session}_${time.toISOString()}_${marshal(data)}
|
// Format: ${session}_${time.toISOString()}_${marshal(data)}
|
||||||
// Use same format as ISOTime.MarshalJSON to ensure consistency
|
// Use same format as ISOTime.MarshalJSON to ensure consistency
|
||||||
@@ -137,22 +137,22 @@ func (c *Client) authenticateRequest(req *Request, session *Session) (*RequestAu
|
|||||||
utcTime.Hour(), utcTime.Minute(), utcTime.Second(),
|
utcTime.Hour(), utcTime.Minute(), utcTime.Second(),
|
||||||
utcTime.Nanosecond()/1000000)
|
utcTime.Nanosecond()/1000000)
|
||||||
message := fmt.Sprintf("%s_%s_%s", session.ID, timeStr, string(dataJSON))
|
message := fmt.Sprintf("%s_%s_%s", session.ID, timeStr, string(dataJSON))
|
||||||
|
|
||||||
// 4. Use HMAC-SHA256 signing (ref: HMACParams in crypto.ts)
|
// 4. Use HMAC-SHA256 signing (ref: HMACParams in crypto.ts)
|
||||||
mac := hmac.New(sha256.New, session.Key)
|
mac := hmac.New(sha256.New, session.Key)
|
||||||
mac.Write([]byte(message))
|
mac.Write([]byte(message))
|
||||||
signature := mac.Sum(nil)
|
signature := mac.Sum(nil)
|
||||||
|
|
||||||
log.Printf("Session signing: sessionId=%s, message_len=%d", session.ID, len(message))
|
log.Printf("Session signing: sessionId=%s, message_len=%d", session.ID, len(message))
|
||||||
log.Printf("Signing message: %s", message)
|
log.Printf("Signing message: %s", message)
|
||||||
log.Printf("Data JSON: %s", string(dataJSON))
|
log.Printf("Data JSON: %s", string(dataJSON))
|
||||||
log.Printf("Session key for signing: %x", session.Key)
|
log.Printf("Session key for signing: %x", session.Key)
|
||||||
log.Printf("Signature (hex): %x", signature)
|
log.Printf("Signature (hex): %x", signature)
|
||||||
|
|
||||||
return &RequestAuth{
|
return &RequestAuth{
|
||||||
Session: session.ID,
|
Session: session.ID,
|
||||||
Time: ISOTime(now), // Convert to ISOTime type
|
Time: ISOTime(now), // Convert to ISOTime type
|
||||||
Signature: Base64Bytes(signature), // Convert to Base64Bytes type
|
Signature: Base64Bytes(signature), // Convert to Base64Bytes type
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,10 +171,10 @@ func (c *Client) parseResponse(result interface{}, target interface{}) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal result: %v", err)
|
return fmt.Errorf("failed to marshal result: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(jsonData, target); err != nil {
|
if err := json.Unmarshal(jsonData, target); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal to target: %v", err)
|
return fmt.Errorf("failed to unmarshal to target: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,48 +29,48 @@ func NewHTTPSender(baseURL string) *HTTPSender {
|
|||||||
func (h *HTTPSender) Send(req *Request) (*Response, error) {
|
func (h *HTTPSender) Send(req *Request) (*Response, error) {
|
||||||
// Build request URL
|
// Build request URL
|
||||||
url := fmt.Sprintf("%s/api/rpc", h.BaseURL)
|
url := fmt.Sprintf("%s/api/rpc", h.BaseURL)
|
||||||
|
|
||||||
// Serialize request
|
// Serialize request
|
||||||
reqBody, err := json.Marshal(req)
|
reqBody, err := json.Marshal(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to marshal request: %w", err)
|
return nil, fmt.Errorf("failed to marshal request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create HTTP request
|
// Create HTTP request
|
||||||
httpReq, err := http.NewRequest("POST", url, bytes.NewReader(reqBody))
|
httpReq, err := http.NewRequest("POST", url, bytes.NewReader(reqBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
|
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set request headers
|
// Set request headers
|
||||||
httpReq.Header.Set("Content-Type", "application/json")
|
httpReq.Header.Set("Content-Type", "application/json")
|
||||||
httpReq.Header.Set("Accept", "application/json")
|
httpReq.Header.Set("Accept", "application/json")
|
||||||
|
|
||||||
// Authentication info already included in JSON request body's auth field, no extra HTTP headers needed
|
// Authentication info already included in JSON request body's auth field, no extra HTTP headers needed
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
httpResp, err := h.Client.Do(httpReq)
|
httpResp, err := h.Client.Do(httpReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("HTTP request failed: %w", err)
|
return nil, fmt.Errorf("HTTP request failed: %w", err)
|
||||||
}
|
}
|
||||||
defer httpResp.Body.Close()
|
defer httpResp.Body.Close()
|
||||||
|
|
||||||
// Read response
|
// Read response
|
||||||
respBody, err := io.ReadAll(httpResp.Body)
|
respBody, err := io.ReadAll(httpResp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read response body: %w", err)
|
return nil, fmt.Errorf("failed to read response body: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check HTTP status code
|
// Check HTTP status code
|
||||||
if httpResp.StatusCode != 200 {
|
if httpResp.StatusCode != 200 {
|
||||||
return nil, fmt.Errorf("HTTP error %d: %s", httpResp.StatusCode, string(respBody))
|
return nil, fmt.Errorf("HTTP error %d: %s", httpResp.StatusCode, string(respBody))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse response
|
// Parse response
|
||||||
var response Response
|
var response Response
|
||||||
if err := json.Unmarshal(respBody, &response); err != nil {
|
if err := json.Unmarshal(respBody, &response); err != nil {
|
||||||
return nil, fmt.Errorf("failed to unmarshal response: %w", err)
|
return nil, fmt.Errorf("failed to unmarshal response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &response, nil
|
return &response, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,41 +17,41 @@ import (
|
|||||||
// LoginTerminus implements Terminus login functionality (ref: BindTerminusBusiness.ts loginTerminus)
|
// LoginTerminus implements Terminus login functionality (ref: BindTerminusBusiness.ts loginTerminus)
|
||||||
func LoginTerminus(bflUrl, terminusName, localName, password string, needTwoFactor bool) (*Token, error) {
|
func LoginTerminus(bflUrl, terminusName, localName, password string, needTwoFactor bool) (*Token, error) {
|
||||||
log.Printf("Starting loginTerminus for user: %s", terminusName)
|
log.Printf("Starting loginTerminus for user: %s", terminusName)
|
||||||
|
|
||||||
// 1. Call onFirstFactor to get initial token (ref: loginTerminus line 364-372)
|
// 1. Call onFirstFactor to get initial token (ref: loginTerminus line 364-372)
|
||||||
token, err := OnFirstFactor(bflUrl, terminusName, localName, password, true, needTwoFactor)
|
token, err := OnFirstFactor(bflUrl, terminusName, localName, password, true, needTwoFactor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("first factor authentication failed: %v", err)
|
return nil, fmt.Errorf("first factor authentication failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("First factor completed, session_id: %s, FA2 required: %t", token.SessionID, token.FA2 || needTwoFactor)
|
log.Printf("First factor completed, session_id: %s, FA2 required: %t", token.SessionID, token.FA2 || needTwoFactor)
|
||||||
|
|
||||||
// 2. If second factor authentication is required (ref: loginTerminus line 379-446)
|
// 2. If second factor authentication is required (ref: loginTerminus line 379-446)
|
||||||
if token.FA2 || needTwoFactor {
|
if token.FA2 || needTwoFactor {
|
||||||
log.Printf("Second factor authentication required")
|
log.Printf("Second factor authentication required")
|
||||||
|
|
||||||
// Get TOTP value
|
// Get TOTP value
|
||||||
totpValue, err := getTOTPFromMFA()
|
totpValue, err := getTOTPFromMFA()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get TOTP: %v", err)
|
return nil, fmt.Errorf("failed to get TOTP: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Generated TOTP: %s", totpValue)
|
log.Printf("Generated TOTP: %s", totpValue)
|
||||||
|
|
||||||
// Perform second factor authentication
|
// Perform second factor authentication
|
||||||
secondToken, err := performSecondFactor(bflUrl, terminusName, totpValue)
|
secondToken, err := performSecondFactor(bflUrl, terminusName, totpValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("second factor authentication failed: %v", err)
|
return nil, fmt.Errorf("second factor authentication failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update token information
|
// Update token information
|
||||||
token.AccessToken = secondToken.AccessToken
|
token.AccessToken = secondToken.AccessToken
|
||||||
token.RefreshToken = secondToken.RefreshToken
|
token.RefreshToken = secondToken.RefreshToken
|
||||||
token.SessionID = secondToken.SessionID
|
token.SessionID = secondToken.SessionID
|
||||||
|
|
||||||
log.Printf("Second factor completed, updated session_id: %s", token.SessionID)
|
log.Printf("Second factor completed, updated session_id: %s", token.SessionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("LoginTerminus completed successfully")
|
log.Printf("LoginTerminus completed successfully")
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
@@ -63,19 +63,19 @@ func getTOTPFromMFA() (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("MFA token not found: %v", err)
|
return "", fmt.Errorf("MFA token not found: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Using MFA token for TOTP generation: %s", mfa)
|
log.Printf("Using MFA token for TOTP generation: %s", mfa)
|
||||||
|
|
||||||
// Generate TOTP (ref: TypeScript hotp function)
|
// Generate TOTP (ref: TypeScript hotp function)
|
||||||
currentTime := time.Now().Unix()
|
currentTime := time.Now().Unix()
|
||||||
interval := int64(30) // 30 second interval
|
interval := int64(30) // 30 second interval
|
||||||
counter := currentTime / interval
|
counter := currentTime / interval
|
||||||
|
|
||||||
totp, err := generateHOTP(mfa, counter)
|
totp, err := generateHOTP(mfa, counter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to generate TOTP: %v", err)
|
return "", fmt.Errorf("failed to generate TOTP: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return totp, nil
|
return totp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,107 +83,107 @@ func getTOTPFromMFA() (string, error) {
|
|||||||
func generateHOTP(secret string, counter int64) (string, error) {
|
func generateHOTP(secret string, counter int64) (string, error) {
|
||||||
// Process base32 string: remove spaces, convert to uppercase, handle padding
|
// Process base32 string: remove spaces, convert to uppercase, handle padding
|
||||||
cleanSecret := strings.ToUpper(strings.ReplaceAll(secret, " ", ""))
|
cleanSecret := strings.ToUpper(strings.ReplaceAll(secret, " ", ""))
|
||||||
|
|
||||||
// Add padding characters if needed
|
// Add padding characters if needed
|
||||||
padding := len(cleanSecret) % 8
|
padding := len(cleanSecret) % 8
|
||||||
if padding != 0 {
|
if padding != 0 {
|
||||||
cleanSecret += strings.Repeat("=", 8-padding)
|
cleanSecret += strings.Repeat("=", 8-padding)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode base32 encoded secret to bytes
|
// Decode base32 encoded secret to bytes
|
||||||
secretBytes, err := base32.StdEncoding.DecodeString(cleanSecret)
|
secretBytes, err := base32.StdEncoding.DecodeString(cleanSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to decode base32 secret: %v", err)
|
return "", fmt.Errorf("failed to decode base32 secret: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert counter to 8-byte big-endian
|
// Convert counter to 8-byte big-endian
|
||||||
counterBytes := make([]byte, 8)
|
counterBytes := make([]byte, 8)
|
||||||
for i := 7; i >= 0; i-- {
|
for i := 7; i >= 0; i-- {
|
||||||
counterBytes[i] = byte(counter & 0xff)
|
counterBytes[i] = byte(counter & 0xff)
|
||||||
counter >>= 8
|
counter >>= 8
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use HMAC-SHA1 to calculate hash (consistent with TypeScript version)
|
// Use HMAC-SHA1 to calculate hash (consistent with TypeScript version)
|
||||||
h := hmac.New(sha1.New, secretBytes)
|
h := hmac.New(sha1.New, secretBytes)
|
||||||
h.Write(counterBytes)
|
h.Write(counterBytes)
|
||||||
hash := h.Sum(nil)
|
hash := h.Sum(nil)
|
||||||
|
|
||||||
// Dynamic truncation (consistent with TypeScript getToken function)
|
// Dynamic truncation (consistent with TypeScript getToken function)
|
||||||
offset := hash[len(hash)-1] & 0xf
|
offset := hash[len(hash)-1] & 0xf
|
||||||
code := ((int(hash[offset]) & 0x7f) << 24) |
|
code := ((int(hash[offset]) & 0x7f) << 24) |
|
||||||
((int(hash[offset+1]) & 0xff) << 16) |
|
((int(hash[offset+1]) & 0xff) << 16) |
|
||||||
((int(hash[offset+2]) & 0xff) << 8) |
|
((int(hash[offset+2]) & 0xff) << 8) |
|
||||||
(int(hash[offset+3]) & 0xff)
|
(int(hash[offset+3]) & 0xff)
|
||||||
|
|
||||||
// Generate 6-digit number
|
// Generate 6-digit number
|
||||||
otp := code % int(math.Pow10(6))
|
otp := code % int(math.Pow10(6))
|
||||||
|
|
||||||
return fmt.Sprintf("%06d", otp), nil
|
return fmt.Sprintf("%06d", otp), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// performSecondFactor performs second factor authentication (ref: loginTerminus line 419-446)
|
// performSecondFactor performs second factor authentication (ref: loginTerminus line 419-446)
|
||||||
func performSecondFactor(baseURL, terminusName, totpValue string) (*Token, error) {
|
func performSecondFactor(baseURL, terminusName, totpValue string) (*Token, error) {
|
||||||
log.Printf("Performing second factor authentication")
|
log.Printf("Performing second factor authentication")
|
||||||
|
|
||||||
// Build target URL
|
// Build target URL
|
||||||
targetURL := fmt.Sprintf("https://desktop.%s/", strings.ReplaceAll(terminusName, "@", "."))
|
targetURL := fmt.Sprintf("https://desktop.%s/", strings.ReplaceAll(terminusName, "@", "."))
|
||||||
|
|
||||||
// Build request data
|
// Build request data
|
||||||
reqData := map[string]interface{}{
|
reqData := map[string]interface{}{
|
||||||
"targetUrl": targetURL,
|
"targetUrl": targetURL,
|
||||||
"token": totpValue,
|
"token": totpValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonData, err := json.Marshal(reqData)
|
jsonData, err := json.Marshal(reqData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to marshal request: %v", err)
|
return nil, fmt.Errorf("failed to marshal request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send HTTP request
|
// Send HTTP request
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 10 * time.Second,
|
Timeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/api/secondfactor/totp", baseURL)
|
url := fmt.Sprintf("%s/api/secondfactor/totp", baseURL)
|
||||||
req, err := http.NewRequest("POST", url, strings.NewReader(string(jsonData)))
|
req, err := http.NewRequest("POST", url, strings.NewReader(string(jsonData)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create request: %v", err)
|
return nil, fmt.Errorf("failed to create request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("Access-Control-Allow-Origin", "*")
|
req.Header.Set("Access-Control-Allow-Origin", "*")
|
||||||
req.Header.Set("X-Unauth-Error", "Non-Redirect")
|
req.Header.Set("X-Unauth-Error", "Non-Redirect")
|
||||||
|
|
||||||
log.Printf("Sending second factor request to: %s", url)
|
log.Printf("Sending second factor request to: %s", url)
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("request failed: %v", err)
|
return nil, fmt.Errorf("request failed: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read response: %v", err)
|
return nil, fmt.Errorf("failed to read response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return nil, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(body))
|
return nil, fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
var response struct {
|
var response struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Data Token `json:"data"`
|
Data Token `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(body, &response); err != nil {
|
if err := json.Unmarshal(body, &response); err != nil {
|
||||||
return nil, fmt.Errorf("failed to unmarshal response: %v", err)
|
return nil, fmt.Errorf("failed to unmarshal response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.Status != "OK" {
|
if response.Status != "OK" {
|
||||||
return nil, fmt.Errorf("second factor authentication failed: %s", response.Status)
|
return nil, fmt.Errorf("second factor authentication failed: %s", response.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Second factor authentication successful")
|
log.Printf("Second factor authentication successful")
|
||||||
return &response.Data, nil
|
return &response.Data, nil
|
||||||
}
|
}
|
||||||
@@ -191,69 +191,69 @@ func performSecondFactor(baseURL, terminusName, totpValue string) (*Token, error
|
|||||||
// ResetPassword implements password reset functionality (ref: account.ts reset_password)
|
// ResetPassword implements password reset functionality (ref: account.ts reset_password)
|
||||||
func ResetPassword(baseURL, localName, currentPassword, newPassword, accessToken string) error {
|
func ResetPassword(baseURL, localName, currentPassword, newPassword, accessToken string) error {
|
||||||
log.Printf("Starting reset password for user: %s", localName)
|
log.Printf("Starting reset password for user: %s", localName)
|
||||||
|
|
||||||
// Process passwords (salted MD5)
|
// Process passwords (salted MD5)
|
||||||
processedCurrentPassword := passwordAddSort(currentPassword)
|
processedCurrentPassword := passwordAddSort(currentPassword)
|
||||||
processedNewPassword := passwordAddSort(newPassword)
|
processedNewPassword := passwordAddSort(newPassword)
|
||||||
|
|
||||||
// Build request data (ref: account.ts line 138-141)
|
// Build request data (ref: account.ts line 138-141)
|
||||||
reqData := map[string]interface{}{
|
reqData := map[string]interface{}{
|
||||||
"current_password": processedCurrentPassword,
|
"current_password": processedCurrentPassword,
|
||||||
"password": processedNewPassword,
|
"password": processedNewPassword,
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonData, err := json.Marshal(reqData)
|
jsonData, err := json.Marshal(reqData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to marshal request: %v", err)
|
return fmt.Errorf("failed to marshal request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create HTTP client (ref: account.ts line 128-135)
|
// Create HTTP client (ref: account.ts line 128-135)
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 10 * time.Second,
|
Timeout: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build request URL (ref: account.ts line 136-137)
|
// Build request URL (ref: account.ts line 136-137)
|
||||||
url := fmt.Sprintf("%s/bfl/iam/v1alpha1/users/%s/password", baseURL, localName)
|
url := fmt.Sprintf("%s/bfl/iam/v1alpha1/users/%s/password", baseURL, localName)
|
||||||
req, err := http.NewRequest("PUT", url, strings.NewReader(string(jsonData)))
|
req, err := http.NewRequest("PUT", url, strings.NewReader(string(jsonData)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create request: %v", err)
|
return fmt.Errorf("failed to create request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set request headers (ref: account.ts line 131-134)
|
// Set request headers (ref: account.ts line 131-134)
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("X-Authorization", accessToken)
|
req.Header.Set("X-Authorization", accessToken)
|
||||||
|
|
||||||
log.Printf("Sending reset password request to: %s", url)
|
log.Printf("Sending reset password request to: %s", url)
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("request failed: %v", err)
|
return fmt.Errorf("request failed: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
// Read response
|
// Read response
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read response: %v", err)
|
return fmt.Errorf("failed to read response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check HTTP status code (ref: account.ts line 144-146)
|
// Check HTTP status code (ref: account.ts line 144-146)
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(body))
|
return fmt.Errorf("HTTP error %d: %s", resp.StatusCode, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse response
|
// Parse response
|
||||||
var response struct {
|
var response struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(body, &response); err != nil {
|
if err := json.Unmarshal(body, &response); err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal response: %v", err)
|
return fmt.Errorf("failed to unmarshal response: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check response status (ref: account.ts line 148-155)
|
// Check response status (ref: account.ts line 148-155)
|
||||||
if response.Code != 0 {
|
if response.Code != 0 {
|
||||||
if response.Message != "" {
|
if response.Message != "" {
|
||||||
@@ -261,7 +261,7 @@ func ResetPassword(baseURL, localName, currentPassword, newPassword, accessToken
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("password reset failed: network error")
|
return fmt.Errorf("password reset failed: network error")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Password reset completed successfully")
|
log.Printf("Password reset completed successfully")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user