From c09f1fbe4e3d4b432a30438e204c1546039f59b1 Mon Sep 17 00:00:00 2001 From: Philippe Loctaux Date: Thu, 29 Jun 2023 20:40:53 +0200 Subject: [PATCH] documentation: added build and install for alpine, with openrc service --- documentation/alpine-linux.md | 71 +++++++++++++++++++++++++++++++++++ documentation/openrc.sh | 16 ++++++++ 2 files changed, 87 insertions(+) create mode 100644 documentation/alpine-linux.md create mode 100644 documentation/openrc.sh diff --git a/documentation/alpine-linux.md b/documentation/alpine-linux.md new file mode 100644 index 0000000..5823c26 --- /dev/null +++ b/documentation/alpine-linux.md @@ -0,0 +1,71 @@ +# Build ezidam on Alpine Linux + + +## Setup +Install alpine. + +Enable `community` repository in `/etc/apk/repositories` + +Install packages: +```sh +apk add rustup git build-base +``` + +Run `rustup-init` to download the rust compiler. + +## Build +Get code, get in repo + +```sh +rm rust-toolchain.toml +cargo build --release +``` + +## Copy + +Create folders for config, assets, database + +```sh +mkdir -p /etc/ezidam /usr/share/ezidam /var/lib/ezidam +``` + +Copy binary, config, assets +```sh + +cp target/release/ezidam /usr/bin/ezidam +cp crates/ezidam/ezidam.toml /etc/ezidam/ezidam.toml +cp crates/ezidam/static/ crates/ezidam/templates/ /usr/share/ezidam/ -rv +``` + +## Config + +Here's the paths to use in `/etc/ezidam/ezidam.toml`: + +```toml +[default] +template_dir = "/usr/share/ezidam/templates" +static_dir = "/usr/share/ezidam/static" + +[default.databases.ezidam] +url = "/var/lib/ezidam/ezidam.sqlite" +``` +Don't forget the rest of the config! The above is only a snippet! + +## Service + +Copy the script `openrc.sh` as `/etc/init.d/ezidam`, then +```sh +chmod +x /etc/init.d/ezidam +``` + +## Start/Stop/Boot + +- Start: `rc-service ezidam start` +- Stop: `rc-service ezidam stop` + +- Start at boot: `rc-update add ezidam` +- Don't start at boot: `rc-update del ezidam` + +## Logs + +If ezidam is started with the service, logs will be available at `/var/log/ezidam.{log,err}` diff --git a/documentation/openrc.sh b/documentation/openrc.sh new file mode 100644 index 0000000..609b63a --- /dev/null +++ b/documentation/openrc.sh @@ -0,0 +1,16 @@ +#!/sbin/openrc-run + +name="ezidam" +command="/usr/bin/ezidam" +command_args= +command_background=true +pidfile="/run/${RC_SVCNAME}.pid" +output_log="/var/log/${RC_SVCNAME}.log" +error_log="/var/log/${RC_SVCNAME}.err" + +depend() { + need net + use logger +} + +export EZIDAM_CONFIG="/etc/ezidam/ezidam.toml"