1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/roundcube_ynh.git synced 2024-09-03 20:16:28 +02:00

refactor: common install functions

This commit is contained in:
HugoPoi 2024-02-05 15:08:07 +01:00
parent 03829657e8
commit a2bc97b5fa
No known key found for this signature in database
GPG key ID: E581734975D3836F
3 changed files with 78 additions and 60 deletions

View file

@ -16,32 +16,17 @@ carddav_version=5.0.1
# DEFINE ALL COMMON FONCTIONS
#=================================================
install_roundcube_with_plugins() {
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
ynh_script_progression --message="Installing Roundcube with Composer..." --weight=30
# Install composer.json
install_composer() {
cp "$install_dir/composer.json-dist" "$install_dir/composer.json"
# Install composer
ynh_install_composer
}
#=================================================
# CONFIGURE ROUNDCUBE
#=================================================
ynh_script_progression --message="Configuring Roundcube..." --weight=2
configure_roundcube() {
deskey=$(ynh_string_random --length=24)
ynh_add_config --template="../conf/config.inc.php" --destination="$install_dir/config/config.inc.php"
}
#=================================================
# INSTALL ADDITIONAL PLUGINS
#=================================================
ynh_script_progression --message="Installing additional plugins..." --weight=60
install_ldap_addressbook_contextmenu_plugins() {
# Create logs and temp directories
mkdir -p "$install_dir/"{logs,temp}
@ -61,10 +46,9 @@ install_roundcube_with_plugins() {
ynh_add_config --template="../conf/enigma.config.inc.php" --destination="$install_dir/plugins/enigma/config.inc.php"
mkdir -p "$install_dir/plugins/enigma/home"
chown -R $app:www-data "$install_dir/plugins/enigma/home"
}
# Install CardDAV plugin
if [ $with_carddav -eq 1 ]
then
install_carddav_plugin(){
ynh_composer_exec --commands="require roundcube/carddav $carddav_version --with-all-dependencies"
carddav_tmp_config="../conf/carddav.config.inc.php"
@ -96,13 +80,10 @@ install_roundcube_with_plugins() {
then
installed_plugins+=" 'carddav',"
fi
fi
#=================================================
# UPDATE ROUNDCUBE CONFIGURATION
#=================================================
ynh_script_progression --message="Updating Roundcube configuration..." --weight=3
}
enable_plugins_in_config() {
ynh_replace_string --match_string="^\s*// installed plugins" --replace_string="&\n $installed_plugins" --target_file="$install_dir/config/config.inc.php"
# Store the config file checksum into the app settings
@ -110,10 +91,10 @@ install_roundcube_with_plugins() {
chmod 400 "$install_dir/config/config.inc.php"
chown $app:$app "$install_dir/config/config.inc.php"
# Update javascript dependencies
(cd "$install_dir"
/usr/bin/php$phpversion -q ./bin/install-jsdeps.sh -v ?)
}
update_javascript_deps() {
(cd "$install_dir"
/usr/bin/php$phpversion -q ./bin/install-jsdeps.sh -v ?)
}

View file

@ -58,6 +58,25 @@ ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name
#=================================================
# INSTALL DEPENDENCIES AND PLUGINS
#=================================================
install_roundcube_with_plugins
ynh_script_progression --message="Installing Roundcube with Composer..." --weight=30
install_composer
ynh_script_progression --message="Configuring Roundcube..." --weight=2
configure_roundcube
ynh_script_progression --message="Installing ldap, automatic addressbook and contextmenu plugins..." --weight=60
install_ldap_addressbook_contextmenu_plugins
if [ $with_carddav -eq 1 ]
then
ynh_script_progression --message="Installing carddav plugin..." --weight=30
install_carddav_plugin
fi
ynh_script_progression --message="Install javascript dependencies..." --weight=10
update_javascript_deps
ynh_script_progression --message="Updating Roundcube configuration..." --weight=3
enable_plugins_in_config
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -82,10 +82,28 @@ ynh_add_nginx_config
#=================================================
# CONFIGURE ROUNDCUBE
#=================================================
install_roundcube_with_plugins
ynh_script_progression --message="Installing Roundcube with Composer..." --weight=30
install_composer
ynh_composer_exec --commands="update --no-dev"
ynh_script_progression --message="Configuring Roundcube..." --weight=2
configure_roundcube
ynh_script_progression --message="Installing ldap, automatic addressbook and contextmenu plugins..." --weight=60
install_ldap_addressbook_contextmenu_plugins
if [ $with_carddav -eq 1 ]
then
ynh_script_progression --message="Installing carddav plugin..." --weight=30
install_carddav_plugin
fi
ynh_script_progression --message="Install javascript dependencies..." --weight=10
update_javascript_deps
ynh_script_progression --message="Updating Roundcube configuration..." --weight=3
enable_plugins_in_config
# Migrate roundcube database
pushd "$install_dir"
COMPOSER_ALLOW_SUPERUSER=1 ynh_exec_warn "php$phpversion" ./bin/update.sh --version=$oldversion -y