Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add argument for custom path to static web page #41

Merged
merged 1 commit into from
Sep 22, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Description=CasaOS Gateway

[Service]
ExecStartPre=/usr/bin/casaos-gateway -v
ExecStart=/usr/bin/casaos-gateway
ExecStart=/usr/bin/casaos-gateway -w /usr/share/casaos/www
PIDFile=/var/run/casaos/gateway.pid
Restart=always
Type=notify
Expand Down
2 changes: 0 additions & 2 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const (
ConfigKeyLogSaveName = "gateway.LogSaveName"
ConfigKeyLogFileExt = "gateway.LogFileExt"
ConfigKeyGatewayPort = "gateway.Port"
ConfigKeyWWWPath = "gateway.WWWPath"
ConfigKeyRuntimePath = "common.RuntimePath"

GatewayName = "gateway"
Expand All @@ -29,7 +28,6 @@ func LoadConfig() (*viper.Viper, error) {
config.SetDefault(ConfigKeyLogSaveName, GatewayName)
config.SetDefault(ConfigKeyLogFileExt, "log")

config.SetDefault(ConfigKeyWWWPath, filepath.Join(constants.DefaultDataPath, "www"))
config.SetDefault(ConfigKeyRuntimePath, constants.DefaultRuntimePath) // See https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s13.html

config.SetConfigName(GatewayName)
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (

func init() {
versionFlag := flag.Bool("v", false, "version")
wwwPathFlag := flag.String("w", filepath.Join(constants.DefaultDataPath, "www"), "www path")
flag.Parse()

if *versionFlag {
Expand Down Expand Up @@ -101,9 +102,8 @@ func init() {
panic(err)
}

wwwPath := config.GetString(common.ConfigKeyWWWPath)
if err := _state.SetWWWPath(wwwPath); err != nil {
logger.Error("Failed to set www path", zap.Any("error", err), zap.Any(common.ConfigKeyWWWPath, wwwPath))
if err := _state.SetWWWPath(*wwwPathFlag); err != nil {
logger.Error("Failed to set www path", zap.Any("error", err), zap.String("wwwpath", *wwwPathFlag))
panic(err)
}

Expand Down