mirror of
https://github.com/YunoHost-Apps/hedgedoc_ynh.git
synced 2024-09-03 19:25:52 +02:00
128 lines
4.7 KiB
Bash
128 lines
4.7 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
#=================================================
|
|
|
|
allow_anonymous=false
|
|
allow_anonymous_edits=false
|
|
allow_email_registration=false
|
|
allow_free_url=false
|
|
require_free_url_authentication=false
|
|
|
|
#=================================================
|
|
# STORE SETTINGS FROM MANIFEST
|
|
#=================================================
|
|
|
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Installing dependencies..." --weight=20
|
|
|
|
# Install Nodejs
|
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
|
ynh_use_nodejs
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=2
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
#ynh_setup_source --dest_dir=$install_dir
|
|
mkdir -p $install_dir/backend
|
|
mkdir -p $install_dir/frontend
|
|
git clone --depth 1 https://github.com/hedgedoc/hedgedoc -b develop $install_dir/backend
|
|
git clone --depth 1 https://github.com/hedgedoc/react-client $install_dir/frontend
|
|
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
ynh_add_nginx_config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
yunohost service add $app --description="Collaborative Markdown editor" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#==============================================
|
|
# INSTALL HEDGEDOC
|
|
#==============================================
|
|
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20
|
|
|
|
pushd "$install_dir/backend"
|
|
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install
|
|
popd
|
|
|
|
pushd "$install_dir/frontend"
|
|
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install
|
|
# TODO: Fails out of memory in my tests
|
|
# Production build
|
|
# Not sure if PORT is necessary here
|
|
# PORT=$port_frontend REACT_APP_BACKEND_BASE_URL=http://localhost:$port_backend/ yarn build:production
|
|
popd
|
|
|
|
#=================================================
|
|
# SETUP SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
|
|
|
ynh_add_systemd_config --service="${app}_backend" --template="../conf/backend.service"
|
|
ynh_add_systemd_config --service="${app}_frontend" --template="../conf/frontend.service"
|
|
|
|
#=================================================
|
|
# MODIFY A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Modifying a config file..." --weight=1
|
|
|
|
#path=${path_url:1}
|
|
ynh_add_config --template="env_backend" --destination="$install_dir/backend/.env"
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# SECURE FILES AND DIRECTORIES
|
|
#=================================================
|
|
ynh_script_progression --message="Securing files and directories..." --weight=1
|
|
|
|
# Set permissions to app files
|
|
chown -R $app:$app $install_dir
|
|
chmod o-rwx $install_dir
|
|
|
|
#=================================================
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
#=================================================
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=2
|
|
|
|
yunohost service add "${app}_backend" --description="Collaborative Markdown editor's backend" --log="/var/log/$app/$app.log"
|
|
yunohost service add "${app}_frontend" --description="Collaborative Markdown editor's frontend" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name="${app}_backend" --action=start --log_path=systemd
|
|
ynh_systemd_action --service_name="${app}_frontend" --action=start --log_path=systemd
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|