import data model

This commit is contained in:
Valentin 2024-02-25 01:55:30 +01:00
parent abb8aba813
commit c5a18dd39b
1 changed files with 38 additions and 7 deletions

View File

@ -19,6 +19,15 @@ get_username() {
fi
}
get_ip() {
if [[ -z "$ip" ]]; then
ip=$(hostname -I)
if [[ "${ip: -1}" == " " ]]; then
ip="${ip%?}"
fi
fi
}
echo -e "${PURPLE}${BOLD}Deployment Debian + Caddy + Directus + Nuxt${RESET}"
if [ "$EUID" -ne 0 ]; then
@ -201,10 +210,9 @@ fi
echo -e "${PURPLE}${BOLD}Enter the domain name of the website${RESET}"
read domain_name
ip=$(hostname -I)
if [[ "${ip: -1}" == " " ]]; then
ip="${ip%?}"
fi
get_ip
cms_folder="cms_${domain_name}"
echo -e "${PURPLE}${BOLD}Configure the ${domain_name} DNS ZONE as the following${RESET}"
echo -e "${PURPLE}Domain : ${domain_name} | Type : A | Target : ${ip}${RESET}"
echo -e "${PURPLE}Domain : cms.${domain_name} | Type : A | Target : ${ip}${RESET}"
@ -234,7 +242,6 @@ if [[ "$answer" == "y" ]]; then
echo -e "${PURPLE}${BOLD}Enter the Directus admin password : ${RESET}"
read -s directus_admin_password
cms_folder="cms_${domain_name}"
env_file="${cms_folder}/.env"
port=8055
@ -275,11 +282,11 @@ if [[ "$answer" == "y" ]]; then
user_role_uuid=$(echo $(mariadb -u directus -p${db_directus_password} \
-e "SELECT id FROM directus.directus_roles WHERE name='User'") | awk '{print $2}')
website_password=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
su -c "cd /home/${username}/${cms_folder} &&\
npx directus users create --email \"${directus_admin_email}\" \
--password \"${directus_admin_password}\" --role \"${admin_role_uuid}\" &&\
npx directus users create --email \"website@${domain_name}\" --password 'website' --role \"${website_role_uuid}\"" $username
npx directus users create --email \"website@${domain_name}\" --password \"${website_password}\" --role \"${website_role_uuid}\"" $username
website_token=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
mariadb -u directus -p${db_directus_password} -e "UPDATE directus.directus_roles SET icon='robot' WHERE name='Website'";
@ -294,7 +301,31 @@ if [[ "$answer" == "y" ]]; then
caddy reload -c $caddyfile
fi
#
# DIRECTUS IMPORTS
#
echo -e "${PURPLE}${BOLD}Import Directus data model and content ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
get_username
get_ip
echo -e "${PURPLE}${BOLD}Import local Directus data model${RESET}"
echo -e "${PURPLE}npx directus schema snapshot ./snapshot.yaml${RESET}"
echo -e "${PURPLE}scp ${username}@${ip}:/home/${username}/snapshot.yaml /path/to/snapshot.yaml${RESET}"
echo -e "${PURPLE}${BOLD}Press any key when done${RESET}"
read
su -c "cd /home/${username}/${cms_folder} &&\
npx directus schema apply --dry-run --yes ../snapshot.yaml" $username
fi
# TODO
# REMOVE EXPECT AT THE END IF IT IS INSTALLED
# CREATE AN ASSETS FOLDER WITH THE DIRECTUS ENV
# ZABBIX
# URBACKUP
# DIRECTUS EMAIL
# DIRECTUS REDIS
# LOGING DE TOUT