www-data installe node et directus
This commit is contained in:
parent
24728c990f
commit
59b0533026
56
install.sh
56
install.sh
|
@ -190,17 +190,22 @@ fi
|
||||||
echo -e "${PURPLE}${BOLD}Install Node ? (y/N) ${RESET}"
|
echo -e "${PURPLE}${BOLD}Install Node ? (y/N) ${RESET}"
|
||||||
read answer
|
read answer
|
||||||
if [[ "$answer" == "y" ]]; then
|
if [[ "$answer" == "y" ]]; then
|
||||||
get_username
|
touch /var/www/.bashrc
|
||||||
su -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash &&\
|
chown www-data:www-data /var/www/.bashrc
|
||||||
|
mkdir /var/www/.nvm
|
||||||
|
chown www-data:www-data /var/www/.nvm
|
||||||
|
mkdir /var/www/.npm
|
||||||
|
chown www-data:www-data /var/www/.npm
|
||||||
|
|
||||||
|
su -s /bin/bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash &&\
|
||||||
export NVM_DIR="$HOME/.nvm" &&\
|
export NVM_DIR="$HOME/.nvm" &&\
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&\
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&\
|
||||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" &&\
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" &&\
|
||||||
nvm install v18' $username
|
nvm install v18' www-data
|
||||||
ln -sf /home/$username/.nvm/versions/node/v18.19.1/bin/node /usr/bin/node
|
ln -sf /var/www/.nvm/versions/node/v18.19.1/bin/node /usr/bin/node
|
||||||
ln -sf /home/$username/.nvm/versions/node/v18.19.1/bin/npm /usr/bin/npm
|
ln -sf /var/www/.nvm/versions/node/v18.19.1/bin/npm /usr/bin/npm
|
||||||
ln -sf /home/$username/.nvm/versions/node/v18.19.1/bin/npx /usr/bin/npx
|
ln -sf /var/www/.nvm/versions/node/v18.19.1/bin/npx /usr/bin/npx
|
||||||
mkdir /var/www/.npm
|
|
||||||
chown -R www-data:www-data /var/www/.npm
|
|
||||||
echo -e "${PURPLE}${BOLD}Node installed${RESET}";
|
echo -e "${PURPLE}${BOLD}Node installed${RESET}";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -211,7 +216,6 @@ 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
|
||||||
get_ip
|
get_ip
|
||||||
cms_folder="cms_${domain_name}"
|
|
||||||
|
|
||||||
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 "${BLUE}Domain : ${domain_name} | Type : A | Target : ${ip}${RESET}"
|
echo -e "${BLUE}Domain : ${domain_name} | Type : A | Target : ${ip}${RESET}"
|
||||||
|
@ -220,6 +224,11 @@ echo -e "${BLUE}Domain : www.${domain_name} | Type : A | Target : ${ip}${RESET}"
|
||||||
echo -e "${PURPLE}${BOLD}Press any key when done${RESET}"
|
echo -e "${PURPLE}${BOLD}Press any key when done${RESET}"
|
||||||
read
|
read
|
||||||
|
|
||||||
|
repo_directory="/var/www/repositories"
|
||||||
|
mkdir $repo_directory
|
||||||
|
chown www-data:www-data $repo_directory
|
||||||
|
cms_directory="${repo_directory}/cms_${domain_name}"
|
||||||
|
|
||||||
#
|
#
|
||||||
# DIRECTUS
|
# DIRECTUS
|
||||||
#
|
#
|
||||||
|
@ -228,7 +237,6 @@ echo -e "${PURPLE}${BOLD}Install Directus ? (y/N) ${RESET}"
|
||||||
read answer
|
read answer
|
||||||
if [[ "$answer" == "y" ]]; then
|
if [[ "$answer" == "y" ]]; then
|
||||||
install_pkg tmux
|
install_pkg tmux
|
||||||
get_username
|
|
||||||
|
|
||||||
if [[ -z "$db_directus_password" ]]; then
|
if [[ -z "$db_directus_password" ]]; then
|
||||||
echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}"
|
echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}"
|
||||||
|
@ -242,15 +250,16 @@ 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
|
||||||
|
|
||||||
env_file="${cms_folder}/.env"
|
env_file="${cms_directory}/.env"
|
||||||
port=8055
|
port=8055
|
||||||
|
|
||||||
key=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
|
key=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
|
||||||
secret=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
|
secret=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
|
||||||
|
|
||||||
su -c "cd &&\
|
echo "set -g default-shell /bin/sh" >> /etc/tmux.conf
|
||||||
mkdir ${cms_folder} &&\
|
|
||||||
mkdir ${cms_folder}/uploads &&\
|
su -s /bin/bash -c "mkdir ${cms_directory} &&\
|
||||||
|
mkdir ${cms_directory}/uploads &&\
|
||||||
echo \"HOST='${ip}'\" >> ${env_file} &&\
|
echo \"HOST='${ip}'\" >> ${env_file} &&\
|
||||||
echo \"PORT=${port}\" >> ${env_file} &&\
|
echo \"PORT=${port}\" >> ${env_file} &&\
|
||||||
echo \"PUBLIC_URL='https://cms.${domain_name}'\" >> ${env_file} &&\
|
echo \"PUBLIC_URL='https://cms.${domain_name}'\" >> ${env_file} &&\
|
||||||
|
@ -263,18 +272,12 @@ if [[ "$answer" == "y" ]]; then
|
||||||
echo \"SECRET='${secret}'\" >> ${env_file} &&\
|
echo \"SECRET='${secret}'\" >> ${env_file} &&\
|
||||||
echo \"KEY='${key}'\" >> ${env_file} &&\
|
echo \"KEY='${key}'\" >> ${env_file} &&\
|
||||||
echo \"CORS_ENABLED='true'\" >> ${env_file} &&\
|
echo \"CORS_ENABLED='true'\" >> ${env_file} &&\
|
||||||
echo \"CORS_ORIGIN='true'\" >> ${env_file}" $username
|
echo \"CORS_ORIGIN='true'\" >> ${env_file} &&\
|
||||||
|
cd ${cms_directory} &&\
|
||||||
echo "set -g default-shell /bin/sh" >> /etc/tmux.conf
|
|
||||||
chown www-data:www-data /home/$username/$cms_folder
|
|
||||||
|
|
||||||
su -s /bin/bash -c "cd /home/${username}/${cms_folder} &&\
|
|
||||||
npm init -y &&\
|
npm init -y &&\
|
||||||
npx directus bootstrap --skipAdminInit &&\
|
npx directus bootstrap --skipAdminInit &&\
|
||||||
tmux new-session -d -s directus &&\
|
tmux new-session -d -s directus &&\
|
||||||
tmux send-keys -t directus \"cd /home/${username}/${cms_folder} && npx directus start\" C-m" www-data
|
tmux send-keys -t directus \"cd ${cms_directory} && npx directus start\" C-m &&\
|
||||||
|
|
||||||
su -s /bin/bash -c "cd /home/${username}/${cms_folder} &&\
|
|
||||||
npx directus roles create --role Administrator --admin true &&\
|
npx directus roles create --role Administrator --admin true &&\
|
||||||
npx directus roles create --role Website &&\
|
npx directus roles create --role Website &&\
|
||||||
npx directus roles create --role User" www-data
|
npx directus roles create --role User" www-data
|
||||||
|
@ -288,7 +291,7 @@ if [[ "$answer" == "y" ]]; then
|
||||||
|
|
||||||
website_password=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
|
website_password=$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')
|
||||||
|
|
||||||
su -s /bin/bash -c "cd /home/${username}/${cms_folder} &&\
|
su -s /bin/bash -c "cd ${cms_directory} &&\
|
||||||
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_password}\" --role \"${website_role_uuid}\"" www-data
|
npx directus users create --email \"website@${domain_name}\" --password \"${website_password}\" --role \"${website_role_uuid}\"" www-data
|
||||||
|
@ -308,6 +311,7 @@ if [[ "$answer" == "y" ]]; then
|
||||||
echo -e "${PURPLE}${BOLD}Import Directus data model ? (y/N) ${RESET}"
|
echo -e "${PURPLE}${BOLD}Import Directus data model ? (y/N) ${RESET}"
|
||||||
read answer
|
read answer
|
||||||
if [[ "$answer" == "y" ]]; then
|
if [[ "$answer" == "y" ]]; then
|
||||||
|
get_username
|
||||||
|
|
||||||
echo -e "${PURPLE}${BOLD}Import local Directus data model${RESET}"
|
echo -e "${PURPLE}${BOLD}Import local Directus data model${RESET}"
|
||||||
echo -e "${BLUE}npx directus schema snapshot ./snapshot.yaml${RESET}"
|
echo -e "${BLUE}npx directus schema snapshot ./snapshot.yaml${RESET}"
|
||||||
|
@ -315,8 +319,8 @@ if [[ "$answer" == "y" ]]; then
|
||||||
echo -e "${PURPLE}${BOLD}Press any key when done${RESET}"
|
echo -e "${PURPLE}${BOLD}Press any key when done${RESET}"
|
||||||
read
|
read
|
||||||
|
|
||||||
su -s /bin/bash -c "cd /home/${username}/${cms_folder} &&\
|
su -s /bin/bash -c "cd ${cms_directory} &&\
|
||||||
npx directus schema apply --yes ../snapshot.yaml" www-data
|
npx directus schema apply --yes /home/${username}/snapshot.yaml" www-data
|
||||||
|
|
||||||
echo -e "${PURPLE}${BOLD}You can now add some content${RESET}"
|
echo -e "${PURPLE}${BOLD}You can now add some content${RESET}"
|
||||||
echo -e "${ORANGE}${BOLD}Do not forget to set the permissions${RESET}"
|
echo -e "${ORANGE}${BOLD}Do not forget to set the permissions${RESET}"
|
||||||
|
|
Loading…
Reference in New Issue