Skip to content

Commit

Permalink
Merge remote-tracking branch 'nextzen/version-1.1.0-temp2' into versi…
Browse files Browse the repository at this point in the history
…on-1.1.0
  • Loading branch information
KaySar12 committed Oct 17, 2024
2 parents 3127ec6 + 6367fa6 commit f72a6d9
Show file tree
Hide file tree
Showing 28 changed files with 462 additions and 59 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ contact_links:
about: 提出针对本项目安装部署、使用及其他方面的相关问题 / Raise questions about the installation, deployment, use and other aspects of the project.
- name: 对 1Panel 项目有其他问题
url: https://bbs.fit2cloud.com/c/1p/7
about: 如果你对 1Panel 有其他想要提问的,我们欢迎到我们的官方社区进行提问。
about: 如果你对 1Panel 有其他想要提问的,我们欢迎到我们的官方社区进行提问。
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*.dll
*.so
*.dylib
build/1panel

build/nextweb
deploy/nextweb
# Mac
.DS_Store
*/.DS_Store
Expand Down Expand Up @@ -43,8 +43,6 @@ backend/xpack

.history/
dist/
1pctl
1panel.service
install.sh
quick_start.sh
cmd/server/fileList.txt
Expand Down
14 changes: 9 additions & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# - export NODE_OPTIONS="--max-old-space-size=8192"
- export NODE_OPTIONS="--max-old-space-size=8192"
# - make build_web
- chmod +x ./script.sh
- ./script.sh
- sed -i 's@ORIGINAL_VERSION=.*@ORIGINAL_VERSION=v{{ .Version }}@g' 1pctl
- go mod tidy

builds:
- main: ./cmd/server/main.go
binary: 1panel
binary: nextweb
flags:
- -tags=xpack
- -trimpath
Expand All @@ -32,11 +31,11 @@ builds:

archives:
- format: tar.gz
name_template: "1panel-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}"
name_template: "nextweb-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{- if .Arm }}v{{ .Arm }}{{ end }}"
wrap_in_directory: true
files:
- 1pctl
- 1panel.service
- nextweb.service
- install.sh
- README.md
- LICENSE
Expand All @@ -52,6 +51,11 @@ release:
- glob: dist/*.tar.gz
- glob: dist/checksums.txt
name_template: "Release {{.Tag}}"
gitea_urls:
api: https://git.nextzenos.com/api/v1
download: https://git.nextzenos.com
# set to true if you use a self-signed certificate
skip_tls_verify: false
# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"ansible.python.interpreterPath": "/opt/homebrew/bin/python3",
"makefile.configureOnOpen": true
"makefile.configureOnOpen": true,
"cSpell.words": [
"gitea"
]
}
48 changes: 34 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
GOCMD=go
DOCKERCMD=docker
GOBUILD=$(GOCMD) build
DOCKERBUILD=$(DOCKERCMD) build
DOCKERPUSH=$(DOCKERCMD) push
DOCKERIMAGE=$(DOCKERCMD) image
GOCLEAN=$(GOCMD) clean
GOARCH=$(shell go env GOARCH)
GOOS=$(shell go env GOOS )

BASE_PAH := $(shell pwd)
BUILD_PATH = $(BASE_PAH)/build
WEB_PATH=$(BASE_PAH)/frontend
SERVER_PATH=$(BASE_PAH)/backend
MAIN= $(BASE_PAH)/cmd/server/main.go
APP_NAME=NextWeb
ASSERT_PATH= $(BASE_PAH)/cmd/server/web/assets
GOOS=$(shell go env GOOS)

BASE_PATH := $(shell pwd)
BUILD_PATH = $(BASE_PATH)/build
DEPLOY_PATH = $(BASE_PATH)/deploy
WEB_PATH=$(BASE_PATH)/frontend
SERVER_PATH=$(BASE_PATH)/backend
MAIN= $(BASE_PATH)/cmd/server/main.go
APP_NAME=nextweb
APP_VERSION=V1.1.0-beta
IMAGE_TAG=1.1
DOCKER_USERNAME=kaysar12
ASSERT_PATH= $(BASE_PATH)/cmd/server/web/assets

clean_assets:
rm -rf $(ASSERT_PATH)
Expand All @@ -19,16 +27,28 @@ upx_bin:
upx $(BUILD_PATH)/$(APP_NAME)

build_frontend:
cd $(WEB_PATH) && npm install && npm run build:pro
export NODE_OPTIONS="--max-old-space-size=8192" \
&& cd $(WEB_PATH) && npm install && npm run build:pro

build_backend:
cd $(SERVER_PATH) \
&& GOOS=$(GOOS) GOARCH=$(GOARCH) $(GOBUILD) -ldflags '-s -w' -gcflags=all="-N -l" -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)

# build_backend_on_darwin:
# cd $(SERVER_PATH) \
# && GOOS=linux GOARCH=amd64 $(GOBUILD) -trimpath -ldflags '-s -w' -o $(BUILD_PATH)/$(APP_NAME) $(MAIN)

build_all: build_frontend build_backend

build_on_local: clean_assets build_frontend build_backend upx_bin

build_image:
if [ ! -f "$(BUILD_PATH)/$(APP_NAME)" ]; then \
echo "Error: $(APP_NAME) does not exist in $(BUILD_PATH)"; \
exit 1; \
fi
cp $(BUILD_PATH)/$(APP_NAME) $(DEPLOY_PATH) && \
cd $(DEPLOY_PATH) && \
$(DOCKERBUILD) --build-arg PANELVER=$(APP_VERSION) -t ${DOCKER_USERNAME}/$(APP_NAME):$(IMAGE_TAG) .
remove_image:
$(DOCKERIMAGE) rm ${DOCKER_USERNAME}/$(APP_NAME):$(IMAGE_TAG)
push_image:
$(DOCKERPUSH) ${DOCKER_USERNAME}/$(APP_NAME):$(IMAGE_TAG)


2 changes: 1 addition & 1 deletion backend/app/api/v1/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (b *BaseApi) SearchApp(c *gin.Context) {
// @Success 200
// @Security ApiKeyAuth
// @Router /apps/sync [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"Application store synchronization","formatEN":"App store synchronization"}
func (b *BaseApi) SyncApp(c *gin.Context) {
go appService.SyncAppListFromLocal()
res, err := appService.GetAppUpdate()
Expand Down
2 changes: 1 addition & 1 deletion backend/app/service/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (u *DeviceService) Update(key, value string) error {
return err
}
go func() {
_, err := cmd.Exec("systemctl restart 1panel.service")
_, err := cmd.Exec("systemctl restart nextweb.service")
if err != nil {
global.LOG.Errorf("restart system for new time zone failed, err: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion backend/app/service/device_clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (u *DeviceService) Clean(req []dto.Clean) {

if restart {
go func() {
_, err := cmd.Exec("systemctl restart 1panel.service")
_, err := cmd.Exec("systemctl restart nextweb.service")
if err != nil {
global.LOG.Errorf("restart system port failed, err: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions backend/app/service/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (u *SettingService) UpdateBindInfo(req dto.BindInfo) error {
}
go func() {
time.Sleep(1 * time.Second)
_, err := cmd.Exec("systemctl restart 1panel.service")
_, err := cmd.Exec("systemctl restart nextweb.service")
if err != nil {
global.LOG.Errorf("restart system with new bind info failed, err: %v", err)
}
Expand Down Expand Up @@ -209,7 +209,7 @@ func (u *SettingService) UpdatePort(port uint) error {
}
go func() {
time.Sleep(1 * time.Second)
_, err := cmd.Exec("systemctl restart 1panel.service")
_, err := cmd.Exec("systemctl restart nextweb.service")
if err != nil {
global.LOG.Errorf("restart system port failed, err: %v", err)
}
Expand All @@ -232,7 +232,7 @@ func (u *SettingService) UpdateSSL(c *gin.Context, req dto.SSLUpdate) error {
c.SetCookie(constant.SessionName, sID, 0, "", "", false, true)

go func() {
_, err := cmd.Exec("systemctl restart 1panel.service")
_, err := cmd.Exec("systemctl restart nextweb.service")
if err != nil {
global.LOG.Errorf("restart system failed, err: %v", err)
}
Expand Down Expand Up @@ -327,7 +327,7 @@ func (u *SettingService) UpdateSSL(c *gin.Context, req dto.SSLUpdate) error {
c.SetCookie(constant.SessionName, sID, 0, "", "", true, true)
go func() {
time.Sleep(1 * time.Second)
_, err := cmd.Exec("systemctl restart 1panel.service")
_, err := cmd.Exec("systemctl restart nextweb.service")
if err != nil {
global.LOG.Errorf("restart system failed, err: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions backend/app/service/snapshot_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func snapPanel(snap snapHelper, targetDir string) {
status = err.Error()
}

if err := common.CopyFile("/etc/systemd/system/1panel.service", targetDir); err != nil {
if err := common.CopyFile("/etc/systemd/system/nextweb.service", targetDir); err != nil {
status = err.Error()
}
snap.Status.Panel = status
Expand Down Expand Up @@ -142,7 +142,7 @@ func snapPanelData(snap snapHelper, localDir, targetDir string) {
_ = snapshotRepo.UpdateStatus(snap.Status.ID, map[string]interface{}{"panel_data": constant.Running})
status := constant.StatusDone
dataDir := path.Join(global.CONF.System.BaseDir, "1panel")
exclusionRules := "./tmp;./log;./cache;./db/1Panel.db-*;"
exclusionRules := "./tmp;./log;./cache;./db/NextWeb.db-*;"
if strings.Contains(localDir, dataDir) {
exclusionRules += ("." + strings.ReplaceAll(localDir, dataDir, "") + ";")
}
Expand Down
4 changes: 2 additions & 2 deletions backend/app/service/snapshot_recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (u *SnapshotService) HandleSnapshotRecover(snap model.Snapshot, isRecover b
req.IsNew = true
}
if req.IsNew || snap.InterruptStep == "1PanelService" {
if err := recoverPanel(path.Join(snapFileDir, "1panel/1panel.service"), "/etc/systemd/system"); err != nil {
if err := recoverPanel(path.Join(snapFileDir, "1panel/nextweb.service"), "/etc/systemd/system"); err != nil {
updateRecoverStatus(snap.ID, isRecover, "1PanelService", constant.StatusFailed, err.Error())
return
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func (u *SnapshotService) HandleSnapshotRecover(snap model.Snapshot, isRecover b
global.LOG.Debugf("remove the file %s after the operation is successful", path.Dir(snapFileDir))
_ = os.RemoveAll(path.Dir(snapFileDir))
}
_, _ = cmd.Exec("systemctl daemon-reload && systemctl restart 1panel.service")
_, _ = cmd.Exec("systemctl daemon-reload && systemctl restart nextweb.service")
}

func backupBeforeRecover(snap model.Snapshot) error {
Expand Down
16 changes: 8 additions & 8 deletions backend/app/service/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error {
return
}

if err := common.CopyFile(path.Join(tmpDir, "1panel.service"), "/etc/systemd/system"); err != nil {
global.LOG.Errorf("upgrade 1panel.service failed, err: %v", err)
if err := common.CopyFile(path.Join(tmpDir, "nextweb.service"), "/etc/systemd/system"); err != nil {
global.LOG.Errorf("upgrade nextweb.service failed, err: %v", err)
u.handleRollback(originalDir, 3)
return
}
Expand All @@ -160,7 +160,7 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error {
_ = settingRepo.Update("SystemVersion", req.Version)
_ = settingRepo.Update("SystemStatus", "Free")
checkPointOfWal()
_, _ = cmd.ExecWithTimeOut("systemctl daemon-reload && systemctl restart 1panel.service", 1*time.Minute)
_, _ = cmd.ExecWithTimeOut("systemctl daemon-reload && systemctl restart nextweb.service", 1*time.Minute)
}()
return nil
}
Expand All @@ -172,11 +172,11 @@ func (u *UpgradeService) handleBackup(fileOp files.FileOp, originalDir string) e
if err := fileOp.Copy("/usr/local/bin/1pctl", originalDir); err != nil {
return err
}
if err := fileOp.Copy("/etc/systemd/system/1panel.service", originalDir); err != nil {
if err := fileOp.Copy("/etc/systemd/system/nextweb.service", originalDir); err != nil {
return err
}
checkPointOfWal()
if err := handleTar(path.Join(global.CONF.System.BaseDir, "1panel/db"), originalDir, "db.tar.gz", "db/1Panel.db-*", ""); err != nil {
if err := handleTar(path.Join(global.CONF.System.BaseDir, "1panel/db"), originalDir, "db.tar.gz", "db/NextWeb.db-*", ""); err != nil {
return err
}
return nil
Expand All @@ -186,8 +186,8 @@ func (u *UpgradeService) handleRollback(originalDir string, errStep int) {
_ = settingRepo.Update("SystemStatus", "Free")

checkPointOfWal()
if _, err := os.Stat(path.Join(originalDir, "1Panel.db")); err == nil {
if err := common.CopyFile(path.Join(originalDir, "1Panel.db"), global.CONF.System.DbPath); err != nil {
if _, err := os.Stat(path.Join(originalDir, "NextWeb.db")); err == nil {
if err := common.CopyFile(path.Join(originalDir, "NextWeb.db"), global.CONF.System.DbPath); err != nil {
global.LOG.Errorf("rollback 1panel db failed, err: %v", err)
}
}
Expand All @@ -208,7 +208,7 @@ func (u *UpgradeService) handleRollback(originalDir string, errStep int) {
if errStep == 2 {
return
}
if err := common.CopyFile(path.Join(originalDir, "1panel.service"), "/etc/systemd/system"); err != nil {
if err := common.CopyFile(path.Join(originalDir, "nextweb.service"), "/etc/systemd/system"); err != nil {
global.LOG.Errorf("rollback 1panel failed, err: %v", err)
}
}
Expand Down
6 changes: 3 additions & 3 deletions backend/init/viper/viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func Init() {
if config.System.Mode != "" {
mode = config.System.Mode
}
if mode == "dev" && fileOp.Stat("/opt/1panel/conf/app.yaml") {
if mode == "dev" && fileOp.Stat("/opt/nextweb/conf/app.yaml") {
v.SetConfigName("app")
v.AddConfigPath(path.Join("/opt/1panel/conf"))
v.AddConfigPath(path.Join("/opt/nextweb/conf"))
if err := v.ReadInConfig(); err != nil {
panic(fmt.Errorf("Fatal error config file: %s \n", err))
}
Expand All @@ -61,7 +61,7 @@ func Init() {
if err := v.Unmarshal(&serverConfig); err != nil {
panic(err)
}
if mode == "dev" && fileOp.Stat("/opt/1panel/conf/app.yaml") {
if mode == "dev" && fileOp.Stat("/opt/nextweb/conf/app.yaml") {
if serverConfig.System.BaseDir != "" {
baseDir = serverConfig.System.BaseDir
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/server/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ var restoreCmd = &cobra.Command{
return err
}
fmt.Println("(2/4) 1panel 脚本回滚成功")
if err := common.CopyFile(path.Join(tmpPath, "1panel.service"), "/etc/systemd/system"); err != nil {
if err := common.CopyFile(path.Join(tmpPath, "nextweb.service"), "/etc/systemd/system"); err != nil {
return err
}
fmt.Println("(3/4) 1panel 服务回滚成功")
checkPointOfWal()
if _, err := os.Stat(path.Join(tmpPath, "1Panel.db")); err == nil {
if err := common.CopyFile(path.Join(tmpPath, "1Panel.db"), path.Join(baseDir, "1panel/db")); err != nil {
if _, err := os.Stat(path.Join(tmpPath, "NextWeb.db")); err == nil {
if err := common.CopyFile(path.Join(tmpPath, "NextWeb.db"), path.Join(baseDir, "1panel/db")); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func loadDBConn() (*gorm.DB, error) {
baseDir = baseDir[:strings.LastIndex(baseDir, "/")]
}

db, err := gorm.Open(sqlite.Open(baseDir+"/1panel/db/1Panel.db"), &gorm.Config{})
db, err := gorm.Open(sqlite.Open(baseDir+"/nextweb/db/NextWeb.db"), &gorm.Config{})
if err != nil {
return nil, fmt.Errorf("init my db conn failed, err: %v \n", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/server/conf/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
system:
db_file: 1Panel.db
db_file: NextWeb.db
base_dir: /opt
mode: dev
repo_url: https://resource.fit2cloud.com/1panel/package
Expand All @@ -12,6 +12,6 @@ system:
log:
level: debug
time_zone: Asia/Shanghai
log_name: 1Panel
log_name: NextWeb
log_suffix: .log
max_backup: 10
Binary file added cmd/server/web/favicon1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f72a6d9

Please sign in to comment.