Add password generator to signup template

This commit is contained in:
Arya 2023-01-23 14:12:05 +05:30
parent b6c0ac8e6b
commit ce9fb00a46
Signed by: arya
GPG Key ID: 842D12BDA50DF120

View File

@ -2,18 +2,19 @@
# Path: /var/publapi/users/{{username}}.sh # Path: /var/publapi/users/{{username}}.sh
# This file is generated by PublAPI. Do not edit this file. # This file is generated by PublAPI. Do not edit this file.
echo "E-Mail of {{username}} is {{email}}." echo "E-Mail of {{username}} is {{email}}."
pass="$(tr -dc A-Za-z0-9 </dev/urandom | head -c 64)"
useradd -Um -s /bin/bash {{username}} useradd -Um -s /bin/bash {{username}}
chmod 711 /home/{{username}} chmod 711 /home/{{username}}
printf "%s\n%s" "${pass}" "${pass}" | passwd {{username}} printf "%s\n%s" "${pass}" "${pass}" | passwd {{username}}
echo "${pass}" > /home/{{username}}/pass
chmod 600 /home/{{username}}/pass
chown {{username}}:username /home/username/pass
usermod -aG users {{username}} usermod -aG users {{username}}
mkdir /home/{{username}}/.ssh mkdir /home/{{username}}/.ssh
echo "{{sshkey}}" > /home/{{username}}/.ssh/authorized_keys echo "{{sshkey}}" > /home/{{username}}/.ssh/authorized_keys
chmod 700 /home/{{username}}/.ssh chmod 700 /home/{{username}}/.ssh
chmod 600 /home/{{username}}/.ssh/authorized_keys chmod 600 /home/{{username}}/.ssh/authorized_keys
chown -R {{username}}:username /home/username/.ssh chown -R {{username}}:username /home/username/.ssh
echo "${pass}" > /home/{{username}}/pass
chmod 600 /home/{{username}}/pass
chown {{username}}:username /home/username/pass
sed -i 's/REPLACEME/{{username}}/g' /home/username/{meta-info.env,Caddyfile} sed -i 's/REPLACEME/{{username}}/g' /home/username/{meta-info.env,Caddyfile}
sed -i 's/EMAIL=/EMAIL={{email}}/' /home/{{username}}/meta-info.env sed -i 's/EMAIL=/EMAIL={{email}}/' /home/{{username}}/meta-info.env
loginctl enable-linger {{username}} loginctl enable-linger {{username}}