mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-07 08:44:07 +01:00
Rename management from Wiretrustee to Netbird (#311)
Rename documentation and goreleaser build names Added a migration function for when the old path exists and the new one doesn't updated the configure.sh to generate the docker-compose with a new path only if no pre-existing volume with old name exists
This commit is contained in:
parent
b623c255b6
commit
7d893c0238
@ -27,10 +27,10 @@ builds:
|
||||
tags:
|
||||
- load_wgnt_from_rsrc
|
||||
|
||||
- id: wiretrustee-mgmt
|
||||
- id: netbird-mgmt
|
||||
dir: management
|
||||
env: [CGO_ENABLED=0]
|
||||
binary: wiretrustee-mgmt
|
||||
binary: netbird-mgmt
|
||||
goos:
|
||||
- linux
|
||||
goarch:
|
||||
@ -227,11 +227,11 @@ dockers:
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=maintainer=wiretrustee@wiretrustee.com"
|
||||
- "--label=maintainer=dev@netbird.io"
|
||||
- image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-amd64
|
||||
- netbird/management:{{ .Version }}-amd64
|
||||
ids:
|
||||
- wiretrustee-mgmt
|
||||
- netbird-mgmt
|
||||
goarch: amd64
|
||||
use: buildx
|
||||
dockerfile: management/Dockerfile
|
||||
@ -242,11 +242,11 @@ dockers:
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=maintainer=wiretrustee@wiretrustee.com"
|
||||
- "--label=maintainer=dev@netbird.io"
|
||||
- image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-arm64v8
|
||||
- netbird/management:{{ .Version }}-arm64v8
|
||||
ids:
|
||||
- wiretrustee-mgmt
|
||||
- netbird-mgmt
|
||||
goarch: arm64
|
||||
use: buildx
|
||||
dockerfile: management/Dockerfile
|
||||
@ -257,11 +257,11 @@ dockers:
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=maintainer=wiretrustee@wiretrustee.com"
|
||||
- "--label=maintainer=dev@netbird.io"
|
||||
- image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-arm
|
||||
- netbird/management:{{ .Version }}-arm
|
||||
ids:
|
||||
- wiretrustee-mgmt
|
||||
- netbird-mgmt
|
||||
goarch: arm
|
||||
goarm: 6
|
||||
use: buildx
|
||||
@ -273,11 +273,11 @@ dockers:
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=maintainer=wiretrustee@wiretrustee.com"
|
||||
- "--label=maintainer=dev@netbird.io"
|
||||
- image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-debug-amd64
|
||||
- netbird/management:{{ .Version }}-debug-amd64
|
||||
ids:
|
||||
- wiretrustee-mgmt
|
||||
- netbird-mgmt
|
||||
goarch: amd64
|
||||
use: buildx
|
||||
dockerfile: management/Dockerfile.debug
|
||||
@ -288,11 +288,11 @@ dockers:
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=maintainer=wiretrustee@wiretrustee.com"
|
||||
- "--label=maintainer=dev@netbird.io"
|
||||
- image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-debug-arm64v8
|
||||
- netbird/management:{{ .Version }}-debug-arm64v8
|
||||
ids:
|
||||
- wiretrustee-mgmt
|
||||
- netbird-mgmt
|
||||
goarch: arm64
|
||||
use: buildx
|
||||
dockerfile: management/Dockerfile.debug
|
||||
@ -303,12 +303,12 @@ dockers:
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=maintainer=wiretrustee@wiretrustee.com"
|
||||
- "--label=maintainer=dev@netbird.io"
|
||||
|
||||
- image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-debug-arm
|
||||
- netbird/management:{{ .Version }}-debug-arm
|
||||
ids:
|
||||
- wiretrustee-mgmt
|
||||
- netbird-mgmt
|
||||
goarch: arm
|
||||
goarm: 6
|
||||
use: buildx
|
||||
@ -320,7 +320,7 @@ dockers:
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
|
||||
- "--label=org.opencontainers.image.version={{.Version}}"
|
||||
- "--label=maintainer=wiretrustee@wiretrustee.com"
|
||||
- "--label=maintainer=dev@netbird.io"
|
||||
docker_manifests:
|
||||
- name_template: wiretrustee/wiretrustee:{{ .Version }}
|
||||
image_templates:
|
||||
@ -346,23 +346,23 @@ docker_manifests:
|
||||
- wiretrustee/signal:{{ .Version }}-arm
|
||||
- wiretrustee/signal:{{ .Version }}-amd64
|
||||
|
||||
- name_template: wiretrustee/management:{{ .Version }}
|
||||
- name_template: netbird/management:{{ .Version }}
|
||||
image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-arm64v8
|
||||
- wiretrustee/management:{{ .Version }}-arm
|
||||
- wiretrustee/management:{{ .Version }}-amd64
|
||||
- netbird/management:{{ .Version }}-arm64v8
|
||||
- netbird/management:{{ .Version }}-arm
|
||||
- netbird/management:{{ .Version }}-amd64
|
||||
|
||||
- name_template: wiretrustee/management:latest
|
||||
- name_template: netbird/management:latest
|
||||
image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-arm64v8
|
||||
- wiretrustee/management:{{ .Version }}-arm
|
||||
- wiretrustee/management:{{ .Version }}-amd64
|
||||
- netbird/management:{{ .Version }}-arm64v8
|
||||
- netbird/management:{{ .Version }}-arm
|
||||
- netbird/management:{{ .Version }}-amd64
|
||||
|
||||
- name_template: wiretrustee/management:debug-latest
|
||||
- name_template: netbird/management:debug-latest
|
||||
image_templates:
|
||||
- wiretrustee/management:{{ .Version }}-debug-arm64v8
|
||||
- wiretrustee/management:{{ .Version }}-debug-arm
|
||||
- wiretrustee/management:{{ .Version }}-debug-amd64
|
||||
- netbird/management:{{ .Version }}-debug-arm64v8
|
||||
- netbird/management:{{ .Version }}-debug-arm
|
||||
- netbird/management:{{ .Version }}-debug-amd64
|
||||
|
||||
brews:
|
||||
-
|
||||
|
@ -22,6 +22,15 @@ then
|
||||
export TURN_PASSWORD=$(openssl rand -base64 32|sed 's/=//g')
|
||||
fi
|
||||
|
||||
# if wiretrustee-mgmt already exists, leave it, else create new mgmt with netbird
|
||||
OLD_PREFIX='wiretrustee-'
|
||||
if docker volume ls | grep -q "${OLD_PREFIX}mgmt"; then
|
||||
VOLUME_PREFIX=$OLD_PREFIX
|
||||
fi
|
||||
|
||||
export MGMT_VOLUMENAME="${$VOLUME_PREFIX}mgmt"
|
||||
export LETSENCRYPT_VOLUMENAME="${$VOLUME_PREFIX}letsencrypt"
|
||||
|
||||
envsubst < docker-compose.yml.tmpl > docker-compose.yml
|
||||
envsubst < management.json.tmpl > management.json
|
||||
envsubst < turnserver.conf.tmpl > turnserver.conf
|
@ -16,7 +16,7 @@ services:
|
||||
- LETSENCRYPT_DOMAIN=$WIRETRUSTEE_DOMAIN
|
||||
- LETSENCRYPT_EMAIL=$WIRETRUSTEE_LETSENCRYPT_EMAIL
|
||||
volumes:
|
||||
- wiretrustee-letsencrypt:/etc/letsencrypt/
|
||||
- $LETSENCRYPT_VOLUMENAME:/etc/letsencrypt/
|
||||
# Signal
|
||||
signal:
|
||||
image: wiretrustee/signal:latest
|
||||
@ -30,14 +30,14 @@ services:
|
||||
# command: ["--letsencrypt-domain", "$WIRETRUSTEE_DOMAIN", "--log-file", "console"]
|
||||
# Management
|
||||
management:
|
||||
image: wiretrustee/management:latest
|
||||
image: netbird/management:latest
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- dashboard
|
||||
volumes:
|
||||
- wiretrustee-mgmt:/var/lib/wiretrustee
|
||||
- wiretrustee-letsencrypt:/etc/letsencrypt:ro
|
||||
- ./management.json:/etc/wiretrustee/management.json
|
||||
- $MGMT_VOLUMENAME:/var/lib/netbird
|
||||
- $LETSENCRYPT_VOLUMENAME:/etc/letsencrypt:ro
|
||||
- ./management.json:/etc/netbird/management.json
|
||||
ports:
|
||||
- 33073:33073 #gRPC port
|
||||
- $WIRETRUSTEE_MGMT_API_PORT:33071 #API port
|
||||
@ -55,6 +55,6 @@ services:
|
||||
# - ./cert.pem:/etc/coturn/certs/cert.pem:ro
|
||||
network_mode: host
|
||||
volumes:
|
||||
wiretrustee-mgmt:
|
||||
$MGMT_VOLUMENAME:
|
||||
wiretrustee-signal:
|
||||
wiretrustee-letsencrypt:
|
||||
$LETSENCRYPT_VOLUMENAME:
|
||||
|
@ -37,7 +37,12 @@ TURN_MIN_PORT=49152
|
||||
# Max port
|
||||
TURN_MAX_PORT=65535
|
||||
|
||||
VOLUME_PREFIX="netbird-"
|
||||
MGMT_VOLUMENAME=""
|
||||
LETSENCRYPT_VOLUMENAME=""
|
||||
|
||||
# exports
|
||||
export VOLUME_PREFIX
|
||||
export WIRETRUSTEE_DOMAIN
|
||||
export WIRETRUSTEE_AUTH0_DOMAIN
|
||||
export WIRETRUSTEE_AUTH0_CLIENT_ID
|
||||
@ -51,3 +56,4 @@ export TURN_USER
|
||||
export TURN_PASSWORD
|
||||
export TURN_MIN_PORT
|
||||
export TURN_MAX_PORT
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM gcr.io/distroless/base
|
||||
ENTRYPOINT [ "/go/bin/wiretrustee-mgmt","management"]
|
||||
ENTRYPOINT [ "/go/bin/netbird-mgmt","management"]
|
||||
CMD ["--log-file", "console"]
|
||||
COPY wiretrustee-mgmt /go/bin/wiretrustee-mgmt
|
||||
COPY netbird-mgmt /go/bin/netbird-mgmt
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM gcr.io/distroless/base:debug
|
||||
ENTRYPOINT [ "/go/bin/wiretrustee-mgmt","management","--log-level","debug"]
|
||||
ENTRYPOINT [ "/go/bin/netbird-mgmt","management","--log-level","debug"]
|
||||
CMD ["--log-file", "console"]
|
||||
COPY wiretrustee-mgmt /go/bin/wiretrustee-mgmt
|
||||
COPY netbird-mgmt /go/bin/netbird-mgmt
|
||||
|
@ -1,25 +1,25 @@
|
||||
# netbird Management Server
|
||||
netbird management server will control and synchronize peers configuration within your wiretrustee account and network.
|
||||
netbird management server will control and synchronize peers configuration within your Netbird account and network.
|
||||
|
||||
## Command Options
|
||||
The CLI accepts the command **management** with the following options:
|
||||
```shell
|
||||
start Wiretrustee Management Server
|
||||
start Netbird Management Server
|
||||
|
||||
Usage:
|
||||
wiretrustee-mgmt management [flags]
|
||||
netbird-mgmt management [flags]
|
||||
|
||||
Flags:
|
||||
--datadir string server data directory location (default "/var/lib/wiretrustee/")
|
||||
--datadir string server data directory location (default "/var/lib/netbird/")
|
||||
-h, --help help for management
|
||||
--letsencrypt-domain string a domain to issue Let's Encrypt certificate for. Enables TLS using Let's Encrypt. Will fetch and renew certificate, and run the server with TLS
|
||||
--port int server port to listen on (default 33073)
|
||||
--cert-file string Location of your SSL certificate. Can be used when you have an existing certificate and don't want a new certificate be generated automatically. If letsencrypt-domain is specified this property has no effect
|
||||
--cert-key string Location of your SSL certificate private key. Can be used when you have an existing certificate and don't want a new certificate be generated automatically. If letsencrypt-domain is specified this property has no effect
|
||||
Global Flags:
|
||||
--config string Wiretrustee config file location to write new config to (default "/etc/wiretrustee/config.json")
|
||||
--config string Netbird config file location to write new config to (default "/etc/netbird/config.json")
|
||||
--log-level string (default "info")
|
||||
--log-file string sets Wiretrustee log path. If console is specified the the log will be output to stdout (default "/var/log/wiretrustee/management.log")
|
||||
--log-file string sets Netbird log path. If console is specified the the log will be output to stdout (default "/var/log/netbird/management.log")
|
||||
```
|
||||
## Run Management service (Docker)
|
||||
|
||||
@ -35,14 +35,14 @@ Replace <YOUR-DOMAIN> with your server's public domain (e.g. mydomain.com or sub
|
||||
|
||||
```bash
|
||||
# create a volume
|
||||
docker volume create wiretrustee-mgmt
|
||||
docker volume create netbird-mgmt
|
||||
# run the docker container
|
||||
docker run -d --name wiretrustee-management \
|
||||
docker run -d --name netbird-management \
|
||||
-p 33073:33073 \
|
||||
-p 443:443 \
|
||||
-v wiretrustee-mgmt:/var/lib/wiretrustee \
|
||||
-v ./config.json:/etc/wiretrustee/config.json \
|
||||
wiretrustee/management:latest \
|
||||
-v netbird-mgmt:/var/lib/netbird \
|
||||
-v ./config.json:/etc/netbird/config.json \
|
||||
netbird/management:latest \
|
||||
--letsencrypt-domain <YOUR-DOMAIN>
|
||||
```
|
||||
> An example of config.json can be found here [management.json](../infrastructure_files/management.json.tmpl)
|
||||
@ -52,18 +52,18 @@ Trigger Let's encrypt certificate generation:
|
||||
curl https://<YOUR-DOMAIN>
|
||||
```
|
||||
|
||||
The certificate will be persisted in the ```datadir/letsencrypt/``` folder (e.g. ```/var/lib/wiretrustee/letsencrypt/```) inside the container.
|
||||
The certificate will be persisted in the ```datadir/letsencrypt/``` folder (e.g. ```/var/lib/netbird/letsencrypt/```) inside the container.
|
||||
|
||||
Make sure that the ```datadir``` is mapped to some folder on a host machine. In case you used the volume command, you can run the following to retrieve the Mountpoint:
|
||||
```shell
|
||||
docker volume inspect wiretrustee-mgmt
|
||||
docker volume inspect netbird-mgmt
|
||||
[
|
||||
{
|
||||
"CreatedAt": "2021-07-25T20:45:28Z",
|
||||
"Driver": "local",
|
||||
"Labels": {},
|
||||
"Mountpoint": "/var/lib/docker/volumes/mgmt/_data",
|
||||
"Name": "wiretrustee-mgmt",
|
||||
"Name": "netbird-mgmt",
|
||||
"Options": {},
|
||||
"Scope": "local"
|
||||
}
|
||||
@ -75,24 +75,24 @@ Consequent restarts of the container will pick up previously generated certifica
|
||||
|
||||
```bash
|
||||
# create a volume
|
||||
docker volume create wiretrustee-mgmt
|
||||
docker volume create netbird-mgmt
|
||||
# run the docker container
|
||||
docker run -d --name wiretrustee-management \
|
||||
docker run -d --name netbird-management \
|
||||
-p 33073:33073 \
|
||||
-v wiretrustee-mgmt:/var/lib/wiretrustee \
|
||||
-v ./config.json:/etc/wiretrustee/config.json \
|
||||
wiretrustee/management:latest
|
||||
-v netbird-mgmt:/var/lib/netbird \
|
||||
-v ./config.json:/etc/netbird/config.json \
|
||||
netbird/management:latest
|
||||
```
|
||||
### Debug tag
|
||||
We also publish a docker image with the debug tag which has the log-level set to default, plus it uses the ```gcr.io/distroless/base:debug``` image that can be used with docker exec in order to run some commands in the Management container.
|
||||
```shell
|
||||
shell $ docker run -d --name wiretrustee-management-debug \
|
||||
shell $ docker run -d --name netbird-management-debug \
|
||||
-p 33073:33073 \
|
||||
-v wiretrustee-mgmt:/var/lib/wiretrustee \
|
||||
-v ./config.json:/etc/wiretrustee/config.json \
|
||||
wiretrustee/management:debug-latest
|
||||
-v netbird-mgmt:/var/lib/netbird \
|
||||
-v ./config.json:/etc/netbird/config.json \
|
||||
netbird/management:debug-latest
|
||||
|
||||
shell $ docker exec -ti wiretrustee-management-debug /bin/sh
|
||||
shell $ docker exec -ti netbird-management-debug /bin/sh
|
||||
container-shell $
|
||||
```
|
||||
## For development purposes:
|
||||
|
@ -5,13 +5,17 @@ import (
|
||||
"crypto/tls"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server"
|
||||
"github.com/netbirdio/netbird/management/server/http"
|
||||
"github.com/netbirdio/netbird/management/server/idp"
|
||||
"github.com/netbirdio/netbird/util"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/netbirdio/netbird/encryption"
|
||||
mgmtProto "github.com/netbirdio/netbird/management/proto"
|
||||
@ -24,6 +28,8 @@ import (
|
||||
|
||||
var (
|
||||
mgmtPort int
|
||||
defaultMgmtDataDir string
|
||||
defaultMgmtConfig string
|
||||
mgmtDataDir string
|
||||
mgmtConfig string
|
||||
mgmtLetsencryptDomain string
|
||||
@ -44,7 +50,7 @@ var (
|
||||
|
||||
mgmtCmd = &cobra.Command{
|
||||
Use: "management",
|
||||
Short: "start Wiretrustee Management Server",
|
||||
Short: "start Netbird Management Server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
flag.Parse()
|
||||
err := util.InitLog(logLevel, logFile)
|
||||
@ -52,9 +58,34 @@ var (
|
||||
log.Fatalf("failed initializing log %v", err)
|
||||
}
|
||||
|
||||
config, err := loadConfig()
|
||||
if mgmtDataDir == "" {
|
||||
oldPath := "/var/lib/wiretrustee"
|
||||
newPath := "/var/lib/netbird"
|
||||
if migrateToNetbird(oldPath, newPath) {
|
||||
if err := cpDir(oldPath, newPath); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actualMgmtConfigPath := mgmtConfig
|
||||
if mgmtConfig == "" {
|
||||
oldPath := "/etc/wiretrustee/management.json"
|
||||
if migrateToNetbird(oldPath, defaultMgmtConfig) {
|
||||
if err := cpDir("/etc/wiretrustee/", "/etc/netbird/"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := cpFile(oldPath, defaultMgmtConfig); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
actualMgmtConfigPath = defaultMgmtConfig
|
||||
}
|
||||
|
||||
config, err := loadMgmtConfig(actualMgmtConfigPath)
|
||||
if err != nil {
|
||||
log.Fatalf("failed reading provided config file: %s: %v", mgmtConfig, err)
|
||||
log.Fatalf("failed reading provided config file: %s: %v", actualMgmtConfigPath, err)
|
||||
}
|
||||
|
||||
if _, err = os.Stat(config.Datadir); os.IsNotExist(err) {
|
||||
@ -147,9 +178,9 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func loadConfig() (*server.Config, error) {
|
||||
func loadMgmtConfig(mgmtConfigPath string) (*server.Config, error) {
|
||||
config := &server.Config{}
|
||||
_, err := util.ReadJson(mgmtConfig, config)
|
||||
_, err := util.ReadJson(mgmtConfigPath, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -184,14 +215,100 @@ func loadTLSConfig(certFile string, certKey string) (*tls.Config, error) {
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func cpFile(src, dst string) error {
|
||||
var err error
|
||||
var srcfd *os.File
|
||||
var dstfd *os.File
|
||||
var srcinfo os.FileInfo
|
||||
|
||||
if srcfd, err = os.Open(src); err != nil {
|
||||
return err
|
||||
}
|
||||
defer srcfd.Close()
|
||||
|
||||
if dstfd, err = os.Create(dst); err != nil {
|
||||
return err
|
||||
}
|
||||
defer dstfd.Close()
|
||||
|
||||
if _, err = io.Copy(dstfd, srcfd); err != nil {
|
||||
return err
|
||||
}
|
||||
if srcinfo, err = os.Stat(src); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Chmod(dst, srcinfo.Mode())
|
||||
}
|
||||
|
||||
func copySymLink(source, dest string) error {
|
||||
link, err := os.Readlink(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Symlink(link, dest)
|
||||
}
|
||||
|
||||
func cpDir(src string, dst string) error {
|
||||
var err error
|
||||
var fds []os.FileInfo
|
||||
var srcinfo os.FileInfo
|
||||
|
||||
if srcinfo, err = os.Stat(src); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = os.MkdirAll(dst, srcinfo.Mode()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if fds, err = ioutil.ReadDir(src); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, fd := range fds {
|
||||
srcfp := path.Join(src, fd.Name())
|
||||
dstfp := path.Join(dst, fd.Name())
|
||||
|
||||
fileInfo, err := os.Stat(srcfp)
|
||||
if err != nil {
|
||||
log.Fatalf("Couldn't get fileInfo; %v", err)
|
||||
}
|
||||
|
||||
switch fileInfo.Mode() & os.ModeType {
|
||||
case os.ModeSymlink:
|
||||
if err = copySymLink(srcfp, dstfp); err != nil {
|
||||
log.Fatalf("Failed to copy from %s to %s; %v", srcfp, dstfp, err)
|
||||
}
|
||||
case os.ModeDir:
|
||||
if err = cpDir(srcfp, dstfp); err != nil {
|
||||
log.Fatalf("Failed to copy from %s to %s; %v", srcfp, dstfp, err)
|
||||
}
|
||||
default:
|
||||
if err = cpFile(srcfp, dstfp); err != nil {
|
||||
log.Fatalf("Failed to copy from %s to %s; %v", srcfp, dstfp, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func migrateToNetbird(oldPath, newPath string) bool {
|
||||
_, old := os.Stat(oldPath)
|
||||
_, new := os.Stat(newPath)
|
||||
|
||||
if os.IsNotExist(old) || os.IsExist(new) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
mgmtCmd.Flags().IntVar(&mgmtPort, "port", 33073, "server port to listen on")
|
||||
mgmtCmd.Flags().StringVar(&mgmtDataDir, "datadir", "/var/lib/wiretrustee/", "server data directory location")
|
||||
mgmtCmd.Flags().StringVar(&mgmtConfig, "config", "/etc/wiretrustee/management.json", "Wiretrustee config file location. Config params specified via command line (e.g. datadir) have a precedence over configuration from this file")
|
||||
mgmtCmd.Flags().StringVar(&mgmtDataDir, "datadir", defaultMgmtDataDir, "server data directory location")
|
||||
mgmtCmd.Flags().StringVar(&mgmtConfig, "config", defaultMgmtConfig, "Netbird config file location. Config params specified via command line (e.g. datadir) have a precedence over configuration from this file")
|
||||
mgmtCmd.Flags().StringVar(&mgmtLetsencryptDomain, "letsencrypt-domain", "", "a domain to issue Let's Encrypt certificate for. Enables TLS using Let's Encrypt. Will fetch and renew certificate, and run the server with TLS")
|
||||
mgmtCmd.Flags().StringVar(&certFile, "cert-file", "", "Location of your SSL certificate. Can be used when you have an existing certificate and don't want a new certificate be generated automatically. If letsencrypt-domain is specified this property has no effect")
|
||||
mgmtCmd.Flags().StringVar(&certKey, "cert-key", "", "Location of your SSL certificate private key. Can be used when you have an existing certificate and don't want a new certificate be generated automatically. If letsencrypt-domain is specified this property has no effect")
|
||||
|
||||
rootCmd.MarkFlagRequired("config") //nolint
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,11 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -21,7 +22,7 @@ var (
|
||||
logFile string
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "wiretrustee-mgmt",
|
||||
Use: "netbird-mgmt",
|
||||
Short: "",
|
||||
Long: "",
|
||||
}
|
||||
@ -34,19 +35,23 @@ var (
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
func init() {
|
||||
|
||||
func init() {
|
||||
stopCh = make(chan int)
|
||||
|
||||
defaultConfigPath = "/etc/wiretrustee/management.json"
|
||||
defaultLogFile = "/var/log/wiretrustee/management.log"
|
||||
defaultMgmtDataDir = "/var/lib/netbird/"
|
||||
defaultConfigPath = "/etc/netbird"
|
||||
defaultMgmtConfig = defaultConfigPath + "/management.json"
|
||||
defaultLogFile = "/var/log/netbird/management.log"
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
defaultConfigPath = os.Getenv("PROGRAMDATA") + "\\Wiretrustee\\" + "management.json"
|
||||
defaultLogFile = os.Getenv("PROGRAMDATA") + "\\Wiretrustee\\" + "management.log"
|
||||
defaultConfigPath = os.Getenv("PROGRAMDATA") + "\\Netbird\\" + "management.json"
|
||||
defaultLogFile = os.Getenv("PROGRAMDATA") + "\\Netbird\\" + "management.log"
|
||||
}
|
||||
rootCmd.PersistentFlags().StringVar(&configPath, "config", defaultConfigPath, "Wiretrustee config file location to write new config to")
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&configPath, "config", defaultConfigPath, "Netbird config file location to write new config to")
|
||||
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "")
|
||||
rootCmd.PersistentFlags().StringVar(&logFile, "log-file", defaultLogFile, "sets Wiretrustee log path. If console is specified the the log will be output to stdout")
|
||||
rootCmd.PersistentFlags().StringVar(&logFile, "log-file", defaultLogFile, "sets Netbird log path. If console is specified the the log will be output to stdout")
|
||||
rootCmd.AddCommand(mgmtCmd)
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/netbirdio/netbird/management/server/idp"
|
||||
"github.com/netbirdio/netbird/util"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type Protocol string
|
||||
@ -89,6 +90,5 @@ type ProviderConfig struct {
|
||||
// validateURL validates input http url
|
||||
func validateURL(httpURL string) bool {
|
||||
_, err := url.ParseRequestURI(httpURL)
|
||||
|
||||
return err == nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user