mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-09 23:17:55 +02:00
Support customizing HISHTORY_PATH for people who want to install hishtory in an alternate location to fix #54
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/ddworken/hishtory/shared"
|
||||
@ -21,10 +22,13 @@ const (
|
||||
KdfUserID = "user_id"
|
||||
KdfEncryptionKey = "encryption_key"
|
||||
CONFIG_PATH = ".hishtory.config"
|
||||
HISHTORY_PATH = ".hishtory"
|
||||
DB_PATH = ".hishtory.db"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultHishtoryPath = ".hishtory"
|
||||
)
|
||||
|
||||
type HistoryEntry struct {
|
||||
LocalUsername string `json:"local_username" gorm:"uniqueIndex:compositeindex"`
|
||||
Hostname string `json:"hostname" gorm:"uniqueIndex:compositeindex"`
|
||||
@ -163,3 +167,11 @@ func EntryEquals(entry1, entry2 HistoryEntry) bool {
|
||||
entry1.StartTime.Format(time.RFC3339) == entry2.StartTime.Format(time.RFC3339) &&
|
||||
entry1.EndTime.Format(time.RFC3339) == entry2.EndTime.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
func GetHishtoryPath() string {
|
||||
hishtoryPath := os.Getenv("HISHTORY_PATH")
|
||||
if hishtoryPath != "" {
|
||||
return hishtoryPath
|
||||
}
|
||||
return defaultHishtoryPath
|
||||
}
|
||||
|
Reference in New Issue
Block a user