diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000000..7347a7fbb903 --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 07367b3dab65..57cfd9913f15 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -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 有其他想要提问的,我们欢迎到我们的官方社区进行提问。 \ No newline at end of file + about: 如果你对 1Panel 有其他想要提问的,我们欢迎到我们的官方社区进行提问。 diff --git a/.gitignore b/.gitignore index 1622b7861cc9..9ace1216e787 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ *.dll *.so *.dylib -build/1panel - +build/nextweb +deploy/nextweb # Mac .DS_Store */.DS_Store @@ -43,8 +43,6 @@ backend/xpack .history/ dist/ -1pctl -1panel.service install.sh quick_start.sh cmd/server/fileList.txt diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 386dc022b5ba..8b1879b46855 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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 @@ -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 @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json index 077ce1d14761..701d10941e19 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "ansible.python.interpreterPath": "/opt/homebrew/bin/python3", - "makefile.configureOnOpen": true + "makefile.configureOnOpen": true, + "cSpell.words": [ + "gitea" + ] } \ No newline at end of file diff --git a/Makefile b/Makefile index 9eb7862df812..3fd857623f22 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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) + + diff --git a/backend/app/api/v1/app.go b/backend/app/api/v1/app.go index 2518fe2b39c4..454178db1a1a 100644 --- a/backend/app/api/v1/app.go +++ b/backend/app/api/v1/app.go @@ -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() diff --git a/backend/app/service/device.go b/backend/app/service/device.go index 8fcf8a8d7031..d7f4ef97cf6f 100644 --- a/backend/app/service/device.go +++ b/backend/app/service/device.go @@ -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) } diff --git a/backend/app/service/device_clean.go b/backend/app/service/device_clean.go index f6dfd53a43b0..99bf2d571fe8 100644 --- a/backend/app/service/device_clean.go +++ b/backend/app/service/device_clean.go @@ -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) } diff --git a/backend/app/service/setting.go b/backend/app/service/setting.go index 0bbf3b68bb24..e0669c922d89 100644 --- a/backend/app/service/setting.go +++ b/backend/app/service/setting.go @@ -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) } @@ -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) } @@ -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) } @@ -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) } diff --git a/backend/app/service/snapshot_create.go b/backend/app/service/snapshot_create.go index 82d9763a05c9..d15e2f3fffbf 100644 --- a/backend/app/service/snapshot_create.go +++ b/backend/app/service/snapshot_create.go @@ -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 @@ -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, "") + ";") } diff --git a/backend/app/service/snapshot_recover.go b/backend/app/service/snapshot_recover.go index 6b707340e794..2e355beb3f8c 100644 --- a/backend/app/service/snapshot_recover.go +++ b/backend/app/service/snapshot_recover.go @@ -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 } @@ -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 { diff --git a/backend/app/service/upgrade.go b/backend/app/service/upgrade.go index b2d2fdad9746..aae12daaefeb 100644 --- a/backend/app/service/upgrade.go +++ b/backend/app/service/upgrade.go @@ -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 } @@ -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 } @@ -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 @@ -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) } } @@ -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) } } diff --git a/backend/init/viper/viper.go b/backend/init/viper/viper.go index eca95523e962..c39dae106d99 100644 --- a/backend/init/viper/viper.go +++ b/backend/init/viper/viper.go @@ -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)) } @@ -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 } diff --git a/cmd/server/cmd/restore.go b/cmd/server/cmd/restore.go index ba04c0fae437..f2f7a4638a23 100644 --- a/cmd/server/cmd/restore.go +++ b/cmd/server/cmd/restore.go @@ -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 } } diff --git a/cmd/server/cmd/root.go b/cmd/server/cmd/root.go index b6243279ab69..2a995cb1e27e 100644 --- a/cmd/server/cmd/root.go +++ b/cmd/server/cmd/root.go @@ -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) } diff --git a/cmd/server/conf/app.yaml b/cmd/server/conf/app.yaml index 0da0e516358a..bb2113defec3 100644 --- a/cmd/server/conf/app.yaml +++ b/cmd/server/conf/app.yaml @@ -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 @@ -12,6 +12,6 @@ system: log: level: debug time_zone: Asia/Shanghai - log_name: 1Panel + log_name: NextWeb log_suffix: .log max_backup: 10 diff --git a/cmd/server/web/favicon1.png b/cmd/server/web/favicon1.png new file mode 100644 index 000000000000..6f82a12d56b6 Binary files /dev/null and b/cmd/server/web/favicon1.png differ diff --git a/deploy/1pctl b/deploy/1pctl new file mode 100644 index 000000000000..6d0fd9acaf26 --- /dev/null +++ b/deploy/1pctl @@ -0,0 +1,222 @@ +#!/bin/bash +action=$1 +target=$2 +args=$@ + +BASE_DIR=/opt +ORIGINAL_PORT=9999 +ORIGINAL_VERSION=v1.1.0-beta +ORIGINAL_ENTRANCE=entrance +ORIGINAL_USERNAME=username +ORIGINAL_PASSWORD=password + +function usage() { + echo "NextWeb Control script" + echo + echo "Usage: " + echo " ./1pctl [COMMAND] [ARGS...]" + echo " ./1pctl --help" + echo + echo "Commands: " + echo " status View nextweb service running status" + echo " start Start the nextweb service" + echo " stop Stop nextweb service" + echo " restart Restart nextweb service" + echo " uninstall Uninstalled nextweb service" + echo " user-info Get nextweb user information" + echo " listen-ip Switch nextweb monitoring IP" + echo " version View nextweb version information" + echo " update Modify nextweb system information" + echo " reset Reset nextweb system information" + echo " restore Restore nextweb service and data" +} +function status() { + systemctl status nextweb.service +} +function start() { + systemctl start nextweb.service + status +} +function stop() { + systemctl stop nextweb.service + status +} +function restart() { + systemctl restart nextweb.service + status +} +function uninstall() { + read -p "Uninstalling will be completely cleared NextWEB Service and data directory, whether to continue [y/n] : " yn + if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then + echo -e "================== Start unload NextWEB Linux Server operation and maintenance management panel ==================" + echo -e "" + echo -e "1)Stop the NextWEB service process..." + systemctl stop nextweb.service + systemctl disable nextweb.service >/dev/null 2>&1 + else + exit 0 + fi + + echo -e "2) Delete nextweb service and data directory..." + rm -rf $BASE_DIR/nextweb /usr/local/bin/{1pctl,nextweb} /etc/systemd/system/nextweb.service + + echo -e "3) Re -load the service configuration file..." + systemctl daemon-reload + systemctl reset-failed + + echo -e "" + echo -e "================================== Uninstall ==================================" +} +function user-info() { + nextweb user-info +} +function listen-ip() { + nextweb listen-ip +} +function listen_ipv4() { + nextweb listen-ip ipv4 + restart +} +function listen_ipv6() { + nextweb listen-ip ipv6 + restart +} +function restore() { + read -p "NextWEB Will return to the previous stable version, whether to continue [y/n] : " yn + if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then + echo -e "" + nextweb restore + systemctl daemon-reload + restart + echo -e "" + nextweb version + else + exit 0 + fi +} +function version() { + nextweb version +} +function reset() { + nextweb reset +} +function reset_domain() { + nextweb reset domain +} +function reset_entrance() { + nextweb reset entrance +} +function reset_https() { + nextweb reset https + restart +} +function reset_ips() { + nextweb reset ips +} +function reset_mfa() { + nextweb reset mfa +} +function update() { + nextweb update +} +function update_username() { + nextweb update username +} +function update_password() { + nextweb update password +} +function update_port() { + nextweb update port +} + +function main() { + case "${action}" in + status) + status + ;; + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + restore) + restore + ;; + uninstall) + uninstall + ;; + user-info) + user-info + ;; + listen-ip) + case "${target}" in + ipv4) + listen_ipv4 + ;; + ipv6) + listen_ipv6 + ;; + *) + listen-ip + ;; + esac + ;; + version) + version + ;; + reset) + case "${target}" in + domain) + reset_domain + ;; + entrance) + reset_entrance + ;; + https) + reset_https + ;; + ips) + reset_ips + ;; + mfa) + reset_mfa + ;; + *) + reset + ;; + esac + ;; + update) + case "${target}" in + username) + update_username + ;; + password) + update_password + ;; + port) + update_port + ;; + *) + update + ;; + esac + ;; + help) + usage + ;; + --help) + usage + ;; + "") + usage + ;; + *) + echo "Without support parameters, please use Help or -Help parameters to get help" + esac +} +main diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 000000000000..1f7fb5287664 --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,65 @@ +# Use ubuntu 22.04 as a basic image +FROM ubuntu:22.04 + +# Set environment variables to avoid interactive configuration +ARG DEBIAN_FRONTEND=noninteractive + +# Set the time zone as Asia/Shanghai +ENV TZ=Asia/Ho_Chi_Minh + +# Install the required software package and clean up the APT cache +RUN apt-get update && apt-get install -y \ + wget \ + tar \ + unzip \ + zip \ + curl \ + git \ + sudo \ + gnupg \ + sqlite3 \ + tzdata \ + && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" > /etc/apt/sources.list.d/docker.list && \ + apt-get update && apt-get install -y docker-ce-cli && \ + curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \ + ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose && \ + chmod +x /usr/local/bin/docker-compose && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +# Set the working directory as/app +WORKDIR /app + +# Copy the necessary files +COPY ./install.sh . +COPY ./update_app_version.sh . +COPY ./nextweb.service . +COPY ./1pctl . +RUN [ ! -f "./build/nextweb" ] && echo "nextweb does not exist" || echo "nextweb found" +COPY ./nextweb . + +# Definition version parameter +ARG PANELVER=$PANELVER + +# Set environment variables +ENV PANELVER=$PANELVER + +# Download and install 1panel +RUN chmod +x /app/install.sh && \ + chmod +x /app/update_app_version.sh && \ + bash /app/install.sh && \ + cp /app/nextweb.service /etc/systemd/system/nextweb.service && \ + find /app -type f ! -name 'update_app_version.sh' -delete + +# Set the working directory as the root directory +WORKDIR / + +# 10086 +EXPOSE 10086 + +# Create a roll of docker socket +VOLUME /var/run/docker.sock + +# start up +CMD ["/bin/bash", "-c", "/usr/local/bin/nextweb & sleep 3 && kill $(jobs -p) || true && /app/update_app_version.sh && /usr/local/bin/nextweb"] \ No newline at end of file diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml new file mode 100644 index 000000000000..d8682f670232 --- /dev/null +++ b/deploy/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3" +services: + nextweb: + container_name: nextweb + restart: always + ports: + - 10086:10086 + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /var/lib/docker/volumes:/var/lib/docker/volumes + - /opt:/opt + - /root:/root + environment: + - TZ=Asia/Ho_Chi_Minh + image: nextweb:latest + labels: + createdBy: "Apps" + diff --git a/deploy/nextweb.service b/deploy/nextweb.service new file mode 100644 index 000000000000..713b80093e4c --- /dev/null +++ b/deploy/nextweb.service @@ -0,0 +1,18 @@ +[Unit] +Description=NextWEB, a modern open source linux panel +After=syslog.target network-online.target +Wants=network-online.target + +[Service] +ExecStart=/usr/bin/nextweb +ExecReload=/bin/kill -s HUP $MAINPID +Restart=always +RestartSec=5 +LimitNOFILE=1048576 +LimitNPROC=1048576 +LimitCORE=1048576 +Delegate=yes +KillMode=process + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/deploy/update_app_version.sh b/deploy/update_app_version.sh new file mode 100644 index 000000000000..b184b6839fed --- /dev/null +++ b/deploy/update_app_version.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Update database +update_database() { + if [[ -f /opt/nextweb/db/NextWeb.db ]]; then + # Backup database file + cp /opt/nextweb/db/NextWeb.db /opt/nextweb/db/NextWeb.db.bak + + #Use sqlite3 to execute the update operation + sqlite3 /opt/nextweb/db/NextWeb.db <<EOF +UPDATE settings +SET value = '$PANELVER' +WHERE key = 'SystemVersion'; +.exit +EOF + + echo "The database version has been updated as $PANELVER" + else + echo "Warning: /opt/nextweb/db/NextWeb.db file does not exist" >&2 + exit 0 + fi +} + +# Main function +main() { + update_database +} + +# Call the main function +main \ No newline at end of file diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 1665e8f82c4f..127959a11c24 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1574,7 +1574,7 @@ const message = { ignoreRule: 'Ignore Rule', ignoreHelper: 'This rule will be used to compress and backup the 1Panel data directory during snapshots, please modify with caution.', - ignoreHelper1: 'One item per line, e.g.: \n*.log\n/opt/1panel/cache', + ignoreHelper1: 'One item per line, e.g.: \n*.log\n/opt/nextweb/cache', panelInfo: 'Write 1Panel basic information', panelBin: 'Backup 1Panel system files', daemonJson: 'Backup Docker configuration file', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 170bbc02ebfc..cc2f54d0fd2a 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1389,7 +1389,7 @@ const message = { status: '快照狀態', ignoreRule: '排除規則', ignoreHelper: '快照時將使用該規則對 1Panel 數據目錄進行壓縮備份,請謹慎修改。', - ignoreHelper1: '一行一個,例: \n*.log\n/opt/1panel/cache', + ignoreHelper1: '一行一個,例: \n*.log\n/opt/nextweb/cache', panelInfo: '寫入 1Panel 基礎信息', panelBin: '備份 1Panel 系統文件', daemonJson: '備份 Docker 配置文件', diff --git a/frontend/src/lang/modules/vi.ts b/frontend/src/lang/modules/vi.ts index a02c8fcc061a..0ff788d451a2 100644 --- a/frontend/src/lang/modules/vi.ts +++ b/frontend/src/lang/modules/vi.ts @@ -1383,7 +1383,7 @@ const message = { status: 'Trạng thái ảnh chụp', ignoreRule: 'Bỏ qua quy tắc', ignoreHelper: 'Quy tắc này sẽ được sử dụng để nén và sao lưu thư mục dữ liệu 1Panel trong quá trình ảnh chụp, vui lòng chỉnh sửa cẩn thận.', - ignoreHelper1: 'Một mục trên mỗi dòng, ví dụ: \n*.log\n/opt/1panel/cache', + ignoreHelper1: 'Một mục trên mỗi dòng, ví dụ: \n*.log\n/opt/nextweb/cache', panelInfo: 'Viết thông tin cơ bản về 1Panel', panelBin: 'Sao lưu tệp hệ thống 1Panel', daemonJson: 'Sao lưu tệp cấu hình Docker', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 333d4588f6c6..e89c90c57db8 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1390,7 +1390,7 @@ const message = { deleteHelper: '将删除该快照的所有备份文件,包括第三方备份账号中的文件。', ignoreRule: '排除规则', ignoreHelper: '快照时将使用该规则对 1Panel 数据目录进行压缩备份,请谨慎修改。', - ignoreHelper1: '一行一个,例: \n*.log\n/opt/1panel/cache', + ignoreHelper1: '一行一个,例: \n*.log\n/opt/nextweb/cache', status: '快照状态', panelInfo: '写入 1Panel 基础信息', panelBin: '备份 1Panel 系统文件', diff --git a/script.sh b/script.sh index b6261f199535..c04f6465adda 100755 --- a/script.sh +++ b/script.sh @@ -9,8 +9,8 @@ if [ ! -f "1pctl" ]; then wget https://github.com/1Panel-dev/installer/raw/main/1pctl fi -if [ ! -f "1panel.service" ]; then - wget https://github.com/1Panel-dev/installer/raw/main/1panel.service +if [ ! -f "nextweb.service" ]; then + wget https://github.com/1Panel-dev/installer/raw/main/nextweb.service fi if [ ! -f "install.sh" ]; then