1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00

Remove exec_cm and cleanups

This commit is contained in:
Jean-Baptiste Holcroft 2018-08-12 00:59:39 +02:00
parent 1c4e766984
commit 5504deffe2
5 changed files with 71 additions and 66 deletions

17
conf/db.inc.php Normal file
View file

@ -0,0 +1,17 @@
<?php
# This is the database configuration of Movim
# You need to copy an rename this file to 'db.inc.php' and complete the values
$conf = [
# The type can be 'pgsql' or 'mysql'
'type' => 'mysql',
# The database username
'username' => '__DB_USER__',
# The password
'password' => '__DB_PWD__',
# Where can we find the database ?
'host' => 'localhost',
# The port number, 3306 for MySQL and 5432 for PostGreSQL
'port' => 3306,
# The database name
'database' => '__DB_NAME__'
];

View file

@ -10,14 +10,7 @@ PKGDIR=$(cd ../; pwd)
# Common helpers
#
# Execute a command as movim user in the destination directory
# usage: exec_cmd COMMAND [ARG ...]
exec_cmd() {
(cd "$final_path" \
&& sudo sudo -u movim "$@")
}
# Undo the SSO patch to Movim source code (applied by default with ynh_setup_source)
# Undo the SSO patch to source code (applied by default with ynh_setup_source)
# usage: undo_sso_patch
undo_sso_patch() {
(

View file

@ -131,46 +131,26 @@ ynh_add_fpm_config
#=================================================
# TODO: add checksum
# Set database configuration
cp "$final_path/config/"{db.example.inc.php,db.inc.php}
ynh_replace_string "'username' => 'username'" "'username' => '$db_user'" \
"$final_path/config/db.inc.php"
ynh_replace_string "'password' => 'password'" "'password' => '$db_pwd'" \
"$final_path/config/db.inc.php"
cp ../conf/db.inc.php "$final_path/config/db.inc.php"
ynh_replace_string "__DB_USER__" "$db_user" "$final_path/config/db.inc.php"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/config/db.inc.php"
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/config/db.inc.php"
## TODO: consider installation in a subpath
ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \
"$final_path/app/assets/js/movim_websocket.js"
#=================================================
# SET PERMISSIONS
#=================================================
chown -R movim:www-data "$final_path"
find "${final_path}/" -type f -print0 | xargs -0 chmod 0644
find "${final_path}/" -type d -print0 | xargs -0 chmod 0755
chmod 400 "${final_path}/config/db.inc.php"
#=================================================
# Install PHP dependencies using composer
#=================================================
# Install PHP dependencies using composer
(curl -sS https://getcomposer.org/installer \
| exec_cmd php -- --install-dir="$final_path" \
&& exec_cmd php composer.phar config --global discard-changes true \
&& exec_cmd php composer.phar install --no-interaction) \
|| ynh_die "Unable to install Movim dependencies."
#=================================================
# Set Movim database and configuration
#=================================================
# Set Movim database and configuration
exec_cmd php mud.php db --set
exec_cmd php mud.php config --loglevel=1 \
--locale="$language" --timezone="$timezone" \
--username="$admin" --password="$password"
(
cd "$final_path"
curl -sS https://getcomposer.org/installer | php -- --install-dir="$final_path" \
&& php composer.phar config --global discard-changes true --quiet \
&& php composer.phar install --no-interaction --quiet
)
#=================================================
# SETUP SYSTEMD
@ -181,9 +161,29 @@ ynh_replace_string "__URL__" "${domain}${path_url}" ../conf/systemd.service
ynh_replace_string "__PORT__" "${port}" ../conf/systemd.service
ynh_add_systemd_config
#=================================================
# Set-up database and configuration
#=================================================
(
cd "$final_path"
php mud.php db --set
php mud.php config --loglevel=1 \
--locale="$language" --timezone="$timezone" \
--username="$admin" --password="$password"
)
#=================================================
# GENERIC FINALIZATION
#=================================================
# SET PERMISSIONS
#=================================================
# TODO: use more strict permissions
chown -R "$app":www-data "$final_path"
find "${final_path}/" -type f -print0 | xargs -0 chmod 0644
find "${final_path}/" -type d -print0 | xargs -0 chmod 0755
chmod 400 "${final_path}/config/db.inc.php"
#=================================================
# SETUP SSOWAT
@ -192,7 +192,7 @@ ynh_add_systemd_config
# SSOwat configuration
if [[ "$ssoenabled" = "No" ]]; then
ynh_app_setting_set "$app" skipped_uris "/"
exec_cmd php mud.php config --xmppwhitelist="$domain"
(cd "$final_path" && php mud.php config --xmppwhitelist="$domain")
undo_sso_patch
else
ynh_app_setting_set "$app" unprotected_uris "/"

View file

@ -69,7 +69,7 @@ ynh_secure_remove "$final_path"
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port" >&2
yunohost firewall disallow TCP $port 2>&1
yunohost firewall disallow TCP "$port" 2>&1
fi
#=================================================

View file

@ -72,7 +72,6 @@ path_url=$(ynh_normalize_url_path $path_url)
# UPGRADE DEPENDENCIES
#=================================================
# Since Movim 0.13, zmq is required
ynh_install_app_dependencies php-gd php-curl php-imagick php-cli php-zmq
#=================================================
@ -81,6 +80,10 @@ ynh_install_app_dependencies php-gd php-curl php-imagick php-cli php-zmq
ynh_setup_source "$final_path"
## TODO: consider installation in a subpath
ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \
"${final_path}/app/assets/js/movim_websocket.js"
#=================================================
# NGINX CONFIGURATION
#=================================================
@ -102,40 +105,34 @@ ynh_system_user_create "$app"
# Create a dedicated php-fpm config
ynh_add_fpm_config
chown -R movim:www-data "$final_path"
## TODO: consider installation in a subpath
ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \
"${final_path}/app/assets/js/movim_websocket.js"
#=================================================
# SET PERMISSIONS
#=================================================
chown -R movim:www-data "$final_path"
chown -R "$app":www-data "$final_path"
find "${final_path}/" -type f -print0 | xargs -0 chmod 0644
find "${final_path}/" -type d -print0 | xargs -0 chmod 0755
chmod 400 "${final_path}/config/db.inc.php"
#=================================================
# install PHP dependencies
# Install PHP dependencies using composer
#=================================================
curl -sS https://getcomposer.org/installer \
| exec_cmd php -- --install-dir="$final_path"
# Update PHP dependencies using composer
(exec_cmd php composer.phar config --global discard-changes true \
&& exec_cmd php composer.phar install --no-interaction) \
|| ynh_die "Unable to update Movim dependencies."
(
cd "$final_path"
curl -sS https://getcomposer.org/installer | php -- --install-dir="$final_path" \
&& php composer.phar config --global discard-changes true --quiet \
&& php composer.phar install --no-interaction --quiet
)
#=================================================
# Upgrade Movim Databas
# Set-up database
#=================================================
# Upgrade Movim database as needed
exec_cmd php mud.php db --set
(
cd "$final_path"
php mud.php db --set
)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
@ -144,7 +141,7 @@ exec_cmd php mud.php db --set
# Reset SSO parameters
ynh_app_setting_delete "$app" protected_uris
ynh_app_setting_delete "$app" skipped_uris
yunohost app clearaccess movim
yunohost app clearaccess "$app"
# Replace old public_site variable (if exists) by ssoenabled
# TODO: add clean support for old/new setting public_site/ssoenabled
@ -163,7 +160,7 @@ fi
# SSOwat configuration
if [[ "$ssoenabled" = "No" ]]; then
ynh_app_setting_set "$app" skipped_uris "/"
exec_cmd php mud.php config --xmppwhitelist=$domain
(cd "$final_path" && php mud.php config --xmppwhitelist="$domain")
yunohost app ssowatconf
undo_sso_patch
else
@ -185,6 +182,4 @@ ynh_add_systemd_config
#=================================================
# Reload services
service movim restart
service php5-fpm restart
service nginx reload