From cf7e240e8aadf3951439c387a925b512f8ae9b5f Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Thu, 25 May 2023 00:52:51 +0400 Subject: [PATCH] Let's add the creds to override.conf, actually. And it is safe to run systemd-creds setup, since it doesn't rewrite an existing key. --- tools/gen-salt.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/gen-salt.sh b/tools/gen-salt.sh index 733b2c1..e7d0884 100755 --- a/tools/gen-salt.sh +++ b/tools/gen-salt.sh @@ -5,11 +5,20 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi +# It will create a new encription key if it doesn't exists. +systemd-creds setup + if [[ $1 ]]; then char_num=$1; else char_num=64; fi +service_override=$(pkg-config systemd --variable=systemdsystemconfdir)/dwelling-upload.service.d/override.conf + +if [ ! -f $service_override ]; then + echo "[Service]" > $service_override; +fi + cat /dev/urandom | tr -dc 'a-zA-Z0-9!@#$%^&*' | fold -w $char_num | head -n 1 \ - | systemd-creds encrypt -qp --name=salt - - 2> /dev/null \ No newline at end of file + | systemd-creds encrypt -qp --name=salt - - 2> /dev/null >> $service_override; \ No newline at end of file