Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ func extractFromArchive(archive, path string) error {
log.Fatalf("extractFromArchive: Mkdir() failed: %s", err.Error())
}
case tar.TypeReg:
s := strings.Split(header.Name, "/")
dir := ""

for len(s) > 1 {
dir, s = dir+"/"+s[0], s[1:]
if _, err := os.Stat(path + dir); os.IsNotExist(err) {
if err := os.Mkdir(path+dir, 0755); err != nil {
log.Fatalf("extractFromArchive: Mkdir() subdir failed: %s", err.Error())
}
}
}
outFile, err := os.Create(path + "/" + header.Name)
if err != nil {
log.Fatalf("extractFromArchive: Create() failed: %s", err.Error())
Expand Down
19 changes: 10 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"github.com/google/uuid"
"io/ioutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"net"
"net/http"
"os"
Expand All @@ -25,6 +21,11 @@ import (
"time"
"unicode/utf8"

"github.com/google/uuid"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

"github.com/gobuffalo/packr/v2"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -509,6 +510,11 @@ func main() {
ovpnAdmin.mgmtInterfaces[parts[0]] = parts[len(parts)-1]
}

if ovpnAdmin.role == "slave" {
ovpnAdmin.syncDataFromMaster()
go ovpnAdmin.syncWithMaster()
}

ovpnAdmin.mgmtSetTimeFormat()

ovpnAdmin.registerMetrics()
Expand Down Expand Up @@ -536,11 +542,6 @@ func main() {
ovpnAdmin.modules = append(ovpnAdmin.modules, "ccd")
}

if ovpnAdmin.role == "slave" {
ovpnAdmin.syncDataFromMaster()
go ovpnAdmin.syncWithMaster()
}

ovpnAdmin.templates = packr.New("template", "./templates")

staticBox := packr.New("static", "./frontend/static")
Expand Down
2 changes: 1 addition & 1 deletion setup/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ -e "$SERVER_CERT" ]; then
else
if [ ${OVPN_ROLE:-"master"} = "slave" ]; then
echo "Waiting for initial sync data from master"
while [ $(wget -q localhost/api/sync/last/try -O - | wc -m) -lt 1 ]
while [ $(wget -q localhost:${OVPN_LISTEN_PORT:-8080}/api/sync/last/try -O - | wc -m) -lt 1 ]
do
sleep 5
done
Expand Down