Use executable dir instead of working dir
parent
1b364826ed
commit
eab858ba6b
|
@ -2,6 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
@ -122,8 +124,13 @@ func (a authSQLite3) updateTimestamp(name string) {
|
|||
}
|
||||
|
||||
func (a *authSQLite3) init() error {
|
||||
var err error
|
||||
a.db, err = sql.Open("sqlite3", "auth.sqlite")
|
||||
executable, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := filepath.Dir(executable) + "/auth.sqlite"
|
||||
a.db, err = sql.Open("sqlite3", path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
const latestSerializeVer = 0x1c
|
||||
|
@ -48,7 +49,13 @@ func loadConfig() error {
|
|||
conf.AuthBackend = defaultAuthBackend
|
||||
conf.BindAddr = defaultBindAddr
|
||||
|
||||
f, err := os.OpenFile("config.json", os.O_RDWR|os.O_CREATE, 0666)
|
||||
executable, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := filepath.Dir(executable) + "/config.json"
|
||||
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0666)
|
||||
if err != nil {
|
||||
conf = oldConf
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue