directus tmux et caddy 16
This commit is contained in:
parent
685bc207bb
commit
3c23283881
25
install.sh
25
install.sh
@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PURPLE='\033[35m'
|
PURPLE='\033[35m'
|
||||||
|
ORANGE='\033[33m'
|
||||||
BOLD='\033[1m'
|
BOLD='\033[1m'
|
||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ if [[ "$answer" == "y" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${PURPLE}${BOLD}Generate and store the password somewhere safe${RESET}"
|
echo -e "${ORANGE}${BOLD}Generate and store the password somewhere safe${RESET}"
|
||||||
read -s -p "Enter password: " password
|
read -s -p "Enter password: " password
|
||||||
echo
|
echo
|
||||||
useradd -m "$username"
|
useradd -m "$username"
|
||||||
@ -109,7 +110,7 @@ echo -e "${PURPLE}${BOLD}Install MariaDB ? (y/N) ${RESET}"
|
|||||||
read answer
|
read answer
|
||||||
if [[ "$answer" == "y" ]]; then
|
if [[ "$answer" == "y" ]]; then
|
||||||
apt install -y mariadb-server
|
apt install -y mariadb-server
|
||||||
echo -e "${PURPLE}${BOLD}Generate and store the password somewhere safe${RESET}"
|
echo -e "${ORANGE}${BOLD}Generate and store the password somewhere safe${RESET}"
|
||||||
echo -e "${PURPLE}${BOLD}Enter the MariaDB root password : ${RESET}"
|
echo -e "${PURPLE}${BOLD}Enter the MariaDB root password : ${RESET}"
|
||||||
read -s db_root_password
|
read -s db_root_password
|
||||||
echo
|
echo
|
||||||
@ -148,7 +149,7 @@ fi
|
|||||||
echo -e "${PURPLE}${BOLD}Setup Directus database ? (y/N) ${RESET}"
|
echo -e "${PURPLE}${BOLD}Setup Directus database ? (y/N) ${RESET}"
|
||||||
read answer
|
read answer
|
||||||
if [[ "$answer" == "y" ]]; then
|
if [[ "$answer" == "y" ]]; then
|
||||||
echo -e "${PURPLE}${BOLD}Generate and store the password somewhere safe${RESET}"
|
echo -e "${ORANGE}${BOLD}Generate and store the password somewhere safe${RESET}"
|
||||||
echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}"
|
echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}"
|
||||||
read -s db_directus_password
|
read -s db_directus_password
|
||||||
echo
|
echo
|
||||||
@ -227,7 +228,7 @@ if [[ "$answer" == "y" ]]; then
|
|||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${PURPLE}${BOLD}Generate and store the credentials somewhere safe${RESET}"
|
echo -e "${ORANGE}${BOLD}Generate and store the credentials somewhere safe${RESET}"
|
||||||
echo -e "${PURPLE}${BOLD}Enter the Directus admin email : ${RESET}"
|
echo -e "${PURPLE}${BOLD}Enter the Directus admin email : ${RESET}"
|
||||||
read directus_admin_email
|
read directus_admin_email
|
||||||
echo -e "${PURPLE}${BOLD}Enter the Directus admin password : ${RESET}"
|
echo -e "${PURPLE}${BOLD}Enter the Directus admin password : ${RESET}"
|
||||||
@ -268,16 +269,24 @@ if [[ "$answer" == "y" ]]; then
|
|||||||
npx directus roles create --role User" $username
|
npx directus roles create --role User" $username
|
||||||
|
|
||||||
admin_role_uuid=$(echo $(mariadb -u directus -p${db_directus_password} \
|
admin_role_uuid=$(echo $(mariadb -u directus -p${db_directus_password} \
|
||||||
-e "select id from directus.directus_roles where name='Administrator'") | awk '{print $2}')
|
-e "SELECT id FROM directus.directus_roles WHERE name='Administrator'") | awk '{print $2}')
|
||||||
website_role_uuid=$(echo $(mariadb -u directus -p${db_directus_password} \
|
website_role_uuid=$(echo $(mariadb -u directus -p${db_directus_password} \
|
||||||
-e "select id from directus.directus_roles where name='Website'") | awk '{print $2}')
|
-e "SELECT id FROM directus.directus_roles WHERE name='Website'") | awk '{print $2}')
|
||||||
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}')
|
||||||
|
|
||||||
|
|
||||||
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}\"" $username
|
--password \"${directus_admin_password}\" --role \"${admin_role_uuid}\" &&\
|
||||||
|
npx directus users create --email 'website' --password 'website' --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'";
|
||||||
|
mariadb -u directus -p${db_directus_password} -e "UPDATE directus.directus_roles SET app_access='0' WHERE name='Website'";
|
||||||
|
mariadb -u directus -p${db_directus_password} -e "UPDATE directus.directus_users SET token='${website_token}' WHERE email='website'";
|
||||||
|
mariadb -u directus -p${db_directus_password} -e "UPDATE directus.directus_users SET password='NULL' WHERE email='website'";
|
||||||
|
mariadb -u directus -p${db_directus_password} -e "UPDATE directus.directus_users SET email='NULL' WHERE email='website'";
|
||||||
|
|
||||||
caddyfile="/etc/caddy/Caddyfile"
|
caddyfile="/etc/caddy/Caddyfile"
|
||||||
echo "cms.${domain_name} {" >> $caddyfile
|
echo "cms.${domain_name} {" >> $caddyfile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user