1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/hedgedoc_ynh.git synced 2024-09-03 19:25:52 +02:00
This commit is contained in:
Éric Gaspar 2024-05-28 23:43:54 +02:00
parent 8c32bad9ed
commit 78938b266b
2 changed files with 23 additions and 30 deletions

View file

@ -38,14 +38,12 @@ ynh_use_nodejs
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=2
ynh_script_progression --message="Setting up source files..." --weight=1
# 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
# Download, check integrity, uncompress and patch the source from manifest.toml
ynh_setup_source --dest_dir="$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# SYSTEM CONFIGURATION
@ -56,7 +54,11 @@ ynh_add_nginx_config
ynh_add_systemd_config
yunohost service add $app --description="Collaborative Markdown editor" --log="/var/log/$app/$app.log"
ynh_add_systemd_config --service="${app}_backend" --template="../conf/backend.service"
ynh_add_systemd_config --service="${app}_frontend" --template="../conf/frontend.service"
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"
#=================================================
# SPECIFIC SETUP
@ -77,14 +79,6 @@ pushd "$install_dir/frontend"
# 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
#=================================================
@ -104,14 +98,6 @@ ynh_script_progression --message="Securing files and directories..." --weight=1
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
#=================================================

View file

@ -77,11 +77,16 @@ yunohost service add $app --description="Collaborative Markdown editor" --log="/
#==============================================
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=10
pushd "$install_dir"
ynh_secure_remove /usr/local/share/.cache/yarn
ynh_use_nodejs
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn workspaces focus --production
ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn cache clean
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
#=================================================
@ -100,7 +105,9 @@ chown $app:$app "$install_dir/config.json"
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening"
# 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