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