From 9031f22a8e380616673c3d15b40c1cbe126597d7 Mon Sep 17 00:00:00 2001 From: gmemstr Date: Sun, 3 Dec 2017 16:26:09 -0800 Subject: [PATCH] Beginning work on setup process --- setup.go | 20 ++++++++++++++++++++ webserver.go | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 setup.go diff --git a/setup.go b/setup.go new file mode 100644 index 0000000..b2e453f --- /dev/null +++ b/setup.go @@ -0,0 +1,20 @@ +package main + +import ( + "database/sql" + "fmt" + "io" + "net/http" + "os" + + _ "github.com/mattn/go-sqlite3" +) + +func setup() { + fmt.Println("Initializing the database") + os.MkdirAll("assets/config/", 0755) +} + +func Unzip(file string, dest string) { + +} diff --git a/webserver.go b/webserver.go index 5d3fc2e..0c15df5 100644 --- a/webserver.go +++ b/webserver.go @@ -10,12 +10,21 @@ import ( "fmt" "log" "net/http" + "os" "github.com/gmemstr/pogo/router" ) // Main function that defines routes func main() { + // Check if this is the first time Pogo has been run + // with a lockfile + + if _, err := os.Stat("run.lockfile"); os.IsNotExist(err) { + fmt.Println("This looks like your first time running Pogo,\ngive me a second to set myself up.") + setup() + } + // Start the watch() function in generate_rss.go, which // watches for file changes and regenerates the feed go watch()