security/adduser.sh

17 lines
342 B
Bash
Raw Normal View History

2024-03-21 20:20:24 +00:00
#!/bin/bash
if [ -z "$1" ]; then
echo "please specify a username"
exit 1
fi
password=$(echo $RANDOM$RANDOM$RANDOM | md5sum | awk '{print $1}')
echo "Username: $1"
echo "Password: $password"
password=$(echo -n $password | sha256sum | awk '{print $1}')
sqlite3 db/data.db << EOF
INSERT INTO users VALUES ('$1','$password','notset')
EOF