Skip to content

Commit

Permalink
Add template path check in MergeTemplate function
Browse files Browse the repository at this point in the history
  • Loading branch information
nitezs committed Mar 18, 2024
1 parent c486fe6 commit 613b47c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/sh
cd /app
if [ ! -d "/app/templates" ]; then
mkdir /app/templates
fi
if [ -z "$(ls -A /app/templates)" ]; then
cp -r /app/templates-origin/* /app/templates
fi
/app/sub2sing-box server
sub2sing-box server
6 changes: 6 additions & 0 deletions pkg/util/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"net/http"
"os"
"path/filepath"
"regexp"
"strings"

Expand Down Expand Up @@ -97,6 +98,11 @@ func Convert(subscriptions []string, proxies []string, template string, delete s
}

func MergeTemplate(proxies []model.Proxy, template string) (string, error) {
if !strings.Contains(template, string(filepath.Separator)) {
if _, err := os.Stat(template); os.IsNotExist(err) {
template = filepath.Join("templates", template)
}
}
config, err := ReadTemplate(template)
proxyTags := make([]string, 0)
if err != nil {
Expand Down

0 comments on commit 613b47c

Please sign in to comment.