From 3f5716291b749f7c63945f1341aac0f4d262ee9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20B=C3=A9dard-Couture?= Date: Fri, 8 Mar 2024 23:05:00 -0500 Subject: [PATCH] Add token/password generation function --- misc/install.func | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/misc/install.func b/misc/install.func index 3deb63d1..7b5855a3 100644 --- a/misc/install.func +++ b/misc/install.func @@ -197,3 +197,17 @@ EOF echo "bash -c \"\$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/${app}.sh)\"" >/usr/bin/update chmod +x /usr/bin/update } + +# This function generates a token. The length of the token needs to be passed as the first parameter, otherwise defaults to 30 +generate_token() { + token_len=30 + + #check if first parameter was passed and it's an integer + if [ $# -ge 1 ] && [ ! -z "$1" ] && [[ $1 =~ ^[-+]?[0-9]+$ ]]; then + token_len=$1 + fi + + #For some reason, the /dev/urandom approach does not work inside an install script + #tr -dc A-Za-z0-9