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

[fix] Correct errors found by 'package_check'

This commit is contained in:
Gofannon 2018-06-17 11:36:13 +02:00
parent feba478177
commit 15c44f67bf
3 changed files with 210 additions and 221 deletions

View file

@ -53,12 +53,6 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/php5/fpm/pool.d/$app.conf" ynh_backup "/etc/php5/fpm/pool.d/$app.conf"
ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_mysql_dump_db "$db_name" > db.sql
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
@ -73,8 +67,3 @@ ynh_backup "/etc/logrotate.d/$app"
ynh_backup "/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE CRON FILE
#=================================================
ynh_backup "/etc/cron.d/$app"

View file

@ -105,7 +105,7 @@ ynh_add_fpm_config
#================================================= #=================================================
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE

View file

@ -1,209 +1,209 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC START # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin) admin=$(ynh_app_setting_get $app admin)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
# Fix is_public as a boolean value # Fix is_public as a boolean value
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 ynh_app_setting_set $app is_public 1
is_public=1 is_public=1
elif [ "$is_public" = "No" ]; then elif [ "$is_public" = "No" ]; then
ynh_app_setting_set $app is_public 0 ynh_app_setting_set $app is_public 0
is_public=0 is_public=0
fi fi
# If final_path doesn't exist, create it # If final_path doesn't exist, create it
if [ -z $final_path ]; then if [ -z $final_path ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app final_path $final_path
fi fi
# TODO Not sure if still needed ?? # TODO Not sure if still needed ??
# admin default value, if not set # admin default value, if not set
if [ -z "$admin" ]; then if [ -z "$admin" ]; then
admin=$(sudo yunohost user list | grep 'username' -m1 | awk '{print $2}') admin=$(sudo yunohost user list | grep 'username' -m1 | awk '{print $2}')
sudo ynh_app_setting_set $app is_public -v "$is_public" sudo ynh_app_setting_set $app is_public -v "$is_public"
fi fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# restore it if the upgrade fails # restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# CHECK THE PATH # CHECK THE PATH
#================================================= #=================================================
# Normalize the URL path syntax # Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url) path_url=$(ynh_normalize_url_path $path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
# Create a system user # Create a system user
ynh_system_user_create $app ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# TODO Taken from old "upgrade" script. Should check if it is needed and what it does # TODO Taken from old "upgrade" script. Should check if it is needed and what it does
if [ -d "${final_path}/data/media" ]; then if [ -d "${final_path}/data/media" ]; then
sudo chown -R $app:root $final_path/{data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp} sudo chown -R $app:root $final_path/{data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp}
fi fi
# Modify dokuwiki conf # Modify dokuwiki conf
#sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/dokuwiki.php #sed -i "s@YNH_ADMIN_USER@$admin@g" ../conf/dokuwiki.php
ynh_replace_string "YNH_ADMIN_USER" "$admin" "../conf/dokuwiki.php" ynh_replace_string "YNH_ADMIN_USER" "$admin" "../conf/dokuwiki.php"
sudo cp ../conf/dokuwiki.php $final_path/conf sudo cp ../conf/dokuwiki.php $final_path/conf
# Do not override ACL configuration file # Do not override ACL configuration file
if [ ! -f "$final_path/conf/acl.auth.php" ]; then if [ ! -f "$final_path/conf/acl.auth.php" ]; then
sudo cp ../conf/acl.auth.php $final_path/conf sudo cp ../conf/acl.auth.php $final_path/conf
fi fi
# Remove upgrade notification # Remove upgrade notification
# See https://www.dokuwiki.org/update_check # See https://www.dokuwiki.org/update_check
sudo touch $final_path/doku.php sudo touch $final_path/doku.php
# Remove deleted files # Remove deleted files
# See https://www.dokuwiki.org/install:unused_files # See https://www.dokuwiki.org/install:unused_files
if [ -f "../sources/data/deleted.files" ]; then if [ -f "../sources/data/deleted.files" ]; then
grep -Ev '^($|#)' ../sources/data/deleted.files | xargs -I {} sudo rm -vrf $final_path/{} grep -Ev '^($|#)' ../sources/data/deleted.files | xargs -I {} sudo rm -vrf $final_path/{}
fi fi
# Update all plugins # Update all plugins
for name_plugin in $(sudo -s cat $final_path/lib/plugins/*/plugin.info.txt | grep url | awk -F':' '{print $3}'); for name_plugin in $(sudo -s cat $final_path/lib/plugins/*/plugin.info.txt | grep url | awk -F':' '{print $3}');
do do
# Get a official plugin for dokuwiki, not update a no-official # Get a official plugin for dokuwiki, not update a no-official
sudo wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-${name_plugin}/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true sudo wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-${name_plugin}/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true
if [ -s "${name_plugin}.zip" ]; then if [ -s "${name_plugin}.zip" ]; then
sudo unzip ${name_plugin}.zip sudo unzip ${name_plugin}.zip
sudo cp -a splitbrain-dokuwiki-plugin-${name_plugin}*/. "${final_path}/lib/plugins/${name_plugin}/" sudo cp -a splitbrain-dokuwiki-plugin-${name_plugin}*/. "${final_path}/lib/plugins/${name_plugin}/"
fi fi
done done
#================================================= #=================================================
# Verify the checksum and backup the file if it's different # Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" ynh_backup_if_checksum_is_different "$final_path/conf/dokuwiki.php"
# Recalculate and store the config file checksum into the app settings # Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/CONFIG_FILE" ynh_store_file_checksum "$final_path/conf/dokuwiki.php"
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
# Files owned by dokuwiki can just read # Files owned by dokuwiki can just read
chown -R root: $final_path chown -R root: $final_path
# except for conf, data, some data subfolders, and lib/plugin, where dokuwiki must have write permissions # except for conf, data, some data subfolders, and lib/plugin, where dokuwiki must have write permissions
#TODO compare rights with install script !!! #TODO compare rights with install script !!!
# Install script : # Install script :
#sudo chown -R $app:root $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins,lib/tpl} #sudo chown -R $app:root $final_path/{conf,data,data/attic,data/cache,data/index,data/locks,data/media*,data/meta,data/pages,data/tmp,lib/plugins,lib/tpl}
sudo chown -R $app:root $final_path/{conf,data,lib/plugins,lib/tpl} sudo chown -R $app:root $final_path/{conf,data,lib/plugins,lib/tpl}
sudo chmod -R 700 $final_path/conf sudo chmod -R 700 $final_path/conf
sudo chmod -R 700 $final_path/data sudo chmod -R 700 $final_path/data
sudo chmod -R 755 $final_path/lib/plugins sudo chmod -R 755 $final_path/lib/plugins
sudo chmod 755 $final_path/lib/tpl/{dokuwiki,dokuwiki/images} sudo chmod 755 $final_path/lib/tpl/{dokuwiki,dokuwiki/images}
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then # Remove the public access then # Remove the public access
ynh_app_setting_delete $app skipped_uris ynh_app_setting_delete $app skipped_uris
fi fi
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# unprotected_uris allows SSO credentials to be passed anyway # unprotected_uris allows SSO credentials to be passed anyway
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set $app unprotected_uris "/"
fi fi
# TODO: Still needed ?? # TODO: Still needed ??
#if [ "$is_public" = "Yes" ]; #if [ "$is_public" = "Yes" ];
#then #then
# sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf # sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
#fi #fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
systemctl reload nginx systemctl reload nginx
# TODO # TODO
#sudo yunohost app ssowatconf #sudo yunohost app ssowatconf