import data model
This commit is contained in:
parent
abb8aba813
commit
c5a18dd39b
45
install.sh
45
install.sh
|
@ -19,6 +19,15 @@ get_username() {
|
||||||
fi
|
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}"
|
echo -e "${PURPLE}${BOLD}Deployment Debian + Caddy + Directus + Nuxt${RESET}"
|
||||||
|
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
@ -201,10 +210,9 @@ fi
|
||||||
|
|
||||||
echo -e "${PURPLE}${BOLD}Enter the domain name of the website${RESET}"
|
echo -e "${PURPLE}${BOLD}Enter the domain name of the website${RESET}"
|
||||||
read domain_name
|
read domain_name
|
||||||
ip=$(hostname -I)
|
get_ip
|
||||||
if [[ "${ip: -1}" == " " ]]; then
|
cms_folder="cms_${domain_name}"
|
||||||
ip="${ip%?}"
|
|
||||||
fi
|
|
||||||
echo -e "${PURPLE}${BOLD}Configure the ${domain_name} DNS ZONE as the following${RESET}"
|
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 : ${domain_name} | Type : A | Target : ${ip}${RESET}"
|
||||||
echo -e "${PURPLE}Domain : cms.${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}"
|
echo -e "${PURPLE}${BOLD}Enter the Directus admin password : ${RESET}"
|
||||||
read -s directus_admin_password
|
read -s directus_admin_password
|
||||||
|
|
||||||
cms_folder="cms_${domain_name}"
|
|
||||||
env_file="${cms_folder}/.env"
|
env_file="${cms_folder}/.env"
|
||||||
port=8055
|
port=8055
|
||||||
|
|
||||||
|
@ -275,11 +282,11 @@ if [[ "$answer" == "y" ]]; then
|
||||||
user_role_uuid=$(echo $(mariadb -u directus -p${db_directus_password} \
|
user_role_uuid=$(echo $(mariadb -u directus -p${db_directus_password} \
|
||||||
-e "SELECT id FROM directus.directus_roles WHERE name='User'") | awk '{print $2}')
|
-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} &&\
|
su -c "cd /home/${username}/${cms_folder} &&\
|
||||||
npx directus users create --email \"${directus_admin_email}\" \
|
npx directus users create --email \"${directus_admin_email}\" \
|
||||||
--password \"${directus_admin_password}\" --role \"${admin_role_uuid}\" &&\
|
--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')
|
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'";
|
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
|
caddy reload -c $caddyfile
|
||||||
fi
|
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
|
# TODO
|
||||||
# REMOVE EXPECT AT THE END IF IT IS INSTALLED
|
# REMOVE EXPECT AT THE END IF IT IS INSTALLED
|
||||||
# CREATE AN ASSETS FOLDER WITH THE DIRECTUS ENV
|
# CREATE AN ASSETS FOLDER WITH THE DIRECTUS ENV
|
||||||
|
# ZABBIX
|
||||||
|
# URBACKUP
|
||||||
|
# DIRECTUS EMAIL
|
||||||
|
# DIRECTUS REDIS
|
||||||
# LOGING DE TOUT
|
# LOGING DE TOUT
|
||||||
|
|
Loading…
Reference in New Issue