diff options
author | xengineering <me@xengineering.eu> | 2023-04-13 20:16:19 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-04-13 20:21:58 +0200 |
commit | d82eae7034e0de30b5d61294cdb78c3ad8c1bbda (patch) | |
tree | f44cb92dd6a797545cf9891af00a86516f596ec6 | |
parent | 4ed4b195e9e78d22f9eae0925403de645b5bc30a (diff) | |
download | ceres-d82eae7034e0de30b5d61294cdb78c3ad8c1bbda.tar ceres-d82eae7034e0de30b5d61294cdb78c3ad8c1bbda.tar.zst ceres-d82eae7034e0de30b5d61294cdb78c3ad8c1bbda.zip |
Automate /var/lib/ceres creation
That way only the system user setup and ownership change has to be done
by the packager / installer.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | main.go | 6 |
3 files changed, 13 insertions, 5 deletions
@@ -24,6 +24,8 @@ install: all install -Dm 644 data/templates/head.html $(DESTDIR)$(PREFIX)/share/ceres/templates/head.html install -Dm 644 data/templates/recipe_confirm_deletion.html $(DESTDIR)$(PREFIX)/share/ceres/templates/recipe_confirm_deletion.html install -Dm 644 data/templates/recipe.html $(DESTDIR)$(PREFIX)/share/ceres/templates/recipe.html + + install -dm 700 $(DESTDIR)/var/lib/ceres debug: go run *.go -c config/debug.json @@ -55,14 +55,14 @@ Make target for installation. Use it for example with a fakeroot: tree fakeroot ``` -Please add a service unit for the init system of your distribution. Furthermore -create the data directory where all recipes will be stored and set appropriate -permissions: +Please add a startup script or service unit for the init system of your +distribution. Furthermore create a system user to run the server and grant him +ownership to the data directory specified in the configuration file (default is +`/var/lib/ceres`): ``` - mkdir /var/lib/ceres + useradd --system ceres chown ceres:ceres /var/lib/ceres - chmod 700 /var/lib/ceres ``` If you want to install Ceres to your system, it is recommended to first do the @@ -2,6 +2,8 @@ package main import ( "log" + "os" + "path/filepath" "text/template" ) @@ -11,6 +13,10 @@ var templates *template.Template func main() { log.Printf("Started Ceres recipe server.\n") config = GetRuntimeConfig() + err := os.Mkdir(filepath.Join(config.Data, "recipes"), 0750) + if err != nil && !os.IsExist(err) { + log.Fatal(err) + } templates = setupTemplates() runServer() } |