Public archive for the Return to Ritherdon project. https://www.nicolaellisandritherdon.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.1 KiB

#!/bin/bash
# Create account so user can log-in to the website. Assumes you're using
# SQLilte3 as the database.
# Moves to the location of the script (regardless of where the script
# was called from).
cd "$(dirname "$0")"
DATABASE="ritherdon-archive.db"
read -p "Username: " USERNAME
read -p "Display Name: " DISPLAY_NAME
read -sp "Password: " USER_PASSWORD
echo
read -sp "Confirm Password: " PASSWORD_TEST
echo
if [[ $USERNAME == "" ]]
|| [[ $DISPLAY_NAME == "" ]]
|| [[ $USER_PASSWORD == "" ]]; then
echo "[ERROR] Empty string used."
else
if [[ $USER_PASSWORD == $PASSWORD_TEST ]]; then
echo "[SUCCESS] Password verified."
if [ -e "../$DATABASE" ]; then
echo "[INFO] Database found. Adding user to it..."
SQL="INSERT INTO user (username,display_name,password,created_at,updated_at) \
VALUES (\"$USERNAME\",\"$DISPLAY_NAME\",\"$USER_PASSWORD\",(datetime(\"now\")),NULL);"
cd ../
sqlite3 $DATABASE "$SQL"
else
echo "[ERROR] Cannot find database. Make sure you've ran make build."
exit
fi
else
echo "[ERROR] Passwords do not match."
fi
fi