1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git synced 2024-09-03 18:36:09 +02:00

Improve update

This commit is contained in:
yalh76 2022-06-09 22:33:40 +02:00
parent a6bb004518
commit 7bc5767b64

View file

@ -219,6 +219,7 @@ elif [ "$export" = "libreoffice" ]; then
fi fi
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -232,64 +233,13 @@ install_log=/var/log/$app/installation.log
touch $install_log touch $install_log
chown $app -R /var/log/$app chown $app -R /var/log/$app
#=================================================
# UPGRADE NPM MODULES
#=================================================
ynh_script_progression --message="Upgrading Etherpad..." --weight=60
pushd $final_path
ynh_use_nodejs
ynh_exec_as $app env "$ynh_node_load_PATH" src/bin/installDeps.sh
popd
#=================================================
# INSTALL FRAMAPAD'S PLUGINS
#=================================================
ynh_script_progression --message="Installing Etherpad plugins..." --weight=90
pushd "$final_path"
# Add Left/Center/Right/Justify to lines of text in a pad
ynh_npm install ep_align@${ep_align_version} >> $install_log 2>&1
# Framapad - Adds author names to span titles
ynh_npm install ep_author_hover@${ep_author_hover_version} >> $install_log 2>&1
# Framapad - Adds comments on sidebar and link it to the text.
ynh_npm install ep_comments_page@${ep_comments_page_version} >> $install_log 2>&1
# Framapad - Displays paragraphs, sentences, words and characters counts.
ynh_npm install ep_countable@${ep_countable_version} >> $install_log 2>&1
# Framapad - Delete pads which were never edited
ynh_npm install ep_delete_empty_pads@${ep_delete_empty_pads_version} >> $install_log 2>&1
# Framapad - Apply colors to fonts
ynh_npm install ep_font_color@${ep_font_color_version} >> $install_log 2>&1
# Framapad - Adds heading support to Etherpad Lite.
ynh_npm install ep_headings2@${ep_headings2_version} >> $install_log 2>&1
# Framapad - Edit and Export as Markdown in Etherpad
ynh_npm install ep_markdown@${ep_markdown_version} >> $install_log 2>&1
if [ $mypads -eq 1 ]; then
# Framapad - Groups and private pads for etherpad
ynh_npm install ep_mypads@${mypads_version} >> $install_log 2>&1
fi
# Framapad - Add support to do 'Spell checking'
ynh_npm install ep_spellcheck@${ep_spellcheck_version} >> $install_log 2>&1
# Framapad - Add support for Subscript and Superscript
ynh_npm install ep_subscript_and_superscript@${ep_subscript_and_superscript_version} >> $install_log 2>&1
# Framapad - View a table of contents for your pad
ynh_npm install ep_table_of_contents@${ep_table_of_contents_version} >> $install_log 2>&1
# Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views
ynh_npm install ep_font_size@${ep_font_size_version} >> $install_log 2>&1
popd
chown -R $app: $final_path/node_modules
# Remove package-lock.json otherwise plugins installation and upgrade fails miserablywith 502 error
ynh_secure_remove --file="$final_path/package-lock.json"
#================================================= #=================================================
# CONFIGURE ETHERPAD # CONFIGURE ETHERPAD
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Reconfiguring Etherpad..." --weight=3 ynh_script_progression --message="Reconfiguring Etherpad..." --weight=3
# Overwrite the settings config file only if it's allowed # Overwrite the settings config file only if it's allowed
if [ $overwrite_settings -eq 1 ] if [ $overwrite_settings -eq 1 ]
@ -354,27 +304,7 @@ then
fi fi
fi fi
#=================================================
# SECURING FILES AND DIRECTORIES
#=================================================
# Set files ownership to Etherpad
chmod 750 "$final_path"
chmod o-rwx "$final_path"
chown -R $app: "$final_path"
# Restrict access to credentials.json
chmod 600 "$final_path/credentials.json" chmod 600 "$final_path/credentials.json"
chown $app -R /var/log/$app/etherpad.log
#=================================================
# SOME HACKS
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] && [ $mypads -eq 1 ]
then
# Find the /div just after the field to open a pad in order to add a link to mypads plugin.
sed -i '157i<center><br><font size="4"><a href="./mypads/" style="text-decoration: none; color: #555">MyPads</a></font></center>' $final_path/src/templates/index.html
fi
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
@ -384,7 +314,62 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config # Create a dedicated systemd config
if [ $overwrite_systemd -eq 1 ] if [ $overwrite_systemd -eq 1 ]
then then
ynh_add_systemd_config ynh_add_systemd_config
fi
#=================================================
# INSTALL ETHERPAD'S PLUGINS
#=================================================
ynh_script_progression --message="Installing Etherpad plugins..." --weight=90
pushd "$final_path"
# Add Left/Center/Right/Justify to lines of text in a pad
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_align@${ep_align_version}
# Framapad - Adds author names to span titles
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_author_hover@${ep_author_hover_version}
# Framapad - Adds comments on sidebar and link it to the text.
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_comments_page@${ep_comments_page_version}
# Framapad - Displays paragraphs, sentences, words and characters counts.
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_countable@${ep_countable_version}
# Framapad - Delete pads which were never edited
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_delete_empty_pads@${ep_delete_empty_pads_version}
# Framapad - Apply colors to fonts
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_font_color@${ep_font_color_version}
# Framapad - Adds heading support to Etherpad Lite.
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_headings2@${ep_headings2_version}
# Framapad - Edit and Export as Markdown in Etherpad
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_markdown@${ep_markdown_version}
if [ $mypads -eq 1 ]; then
# Framapad - Groups and private pads for Etherpad
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_mypads@${mypads_version}
fi
# Framapad - Add support to do 'Spell checking'
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_spellcheck@${ep_spellcheck_version}
# Framapad - Add support for Subscript and Superscript
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_subscript_and_superscript@${ep_subscript_and_superscript_version}
# Framapad - View a table of contents for your pad
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_table_of_contents@${ep_table_of_contents_version}
# Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --no-save ep_font_size@${ep_font_size_version}
popd
#=================================================
# UPGRADE NPM MODULES
#=================================================
ynh_script_progression --message="Upgrading Etherpad..." --weight=60
pushd $final_path
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH bin/installDeps.sh
popd
#=================================================
# SOME HACKS
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] && [ $mypads -eq 1 ]
then
# Find the /div just after the field to open a pad in order to add a link to mypads plugin.
sed -i '157i<center><br><font size="4"><a href="./mypads/" style="text-decoration: none; color: #555">MyPads</a></font></center>' $final_path/src/templates/index.html
fi fi
#================================================= #=================================================