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
|
||||
|
||||
PURPLE='\033[35m'
|
||||
ORANGE='\033[33m'
|
||||
BOLD='\033[1m'
|
||||
RESET='\033[0m'
|
||||
|
||||
@ -40,7 +41,7 @@ if [[ "$answer" == "y" ]]; then
|
||||
exit 1
|
||||
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
|
||||
echo
|
||||
useradd -m "$username"
|
||||
@ -109,7 +110,7 @@ echo -e "${PURPLE}${BOLD}Install MariaDB ? (y/N) ${RESET}"
|
||||
read answer
|
||||
if [[ "$answer" == "y" ]]; then
|
||||
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}"
|
||||
read -s db_root_password
|
||||
echo
|
||||
@ -148,7 +149,7 @@ fi
|
||||
echo -e "${PURPLE}${BOLD}Setup Directus database ? (y/N) ${RESET}"
|
||||
read answer
|
||||
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}"
|
||||
read -s db_directus_password
|
||||
echo
|
||||
@ -227,7 +228,7 @@ if [[ "$answer" == "y" ]]; then
|
||||
echo
|
||||
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}"
|
||||
read directus_admin_email
|
||||
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
|
||||
|
||||
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} \
|
||||
-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} \
|
||||
-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} &&\
|
||||
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"
|
||||
echo "cms.${domain_name} {" >> $caddyfile
|
||||
|
Loading…
x
Reference in New Issue
Block a user