diff --git a/check_process b/check_process new file mode 100644 index 0000000..4733388 --- /dev/null +++ b/check_process @@ -0,0 +1,34 @@ +# See here for more information +# https://github.com/YunoHost/package_check#syntax-check_process-file + +# Move this file from check_process.default to check_process when you have filled it. + +;; Test complet + ; Manifest + domain="domain.tld" (DOMAIN) + path="/path" (PATH) + admin="john" (USER) + is_public=1 (PUBLIC|public=1|private=0) + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=1 + port_already_use=0 + change_url=1 +;;; Levels + # If the level 5 (Package linter) is forced to 1. Please add justifications here. + Level 5=auto +;;; Options +Email= +Notification=none +;;; Upgrade options + ; commit=CommitHash + name=Name and date of the commit. + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& + diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..91e022b --- /dev/null +++ b/conf/app.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/Laverna/static-laverna/archive/gh-pages.zip +SOURCE_SUM=226224a141eeefefcf446e8ba4bda3f9ea7be6e96cd1992b185d44d5ef58e7d3 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=zip +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= diff --git a/scripts/install b/scripts/install index 9745be7..aa6fd34 100755 --- a/scripts/install +++ b/scripts/install @@ -26,7 +26,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH +path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC @@ -50,14 +50,27 @@ test ! -e "$final_path" || ynh_die --message="This path already contains a folde # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --time --weight=1 + +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$final_path" -mkdir -p $final_path -wget -P "$src_path" https://github.com/Laverna/static-laverna/archive/gh-pages.zip -O "$final_path"/laverna.zip -unzip "$final_path"/laverna.zip -d "$final_path" -cp -R "$final_path"/static-laverna-gh-pages/* "$final_path" -rm "$final_path"/laverna.zip -rm -rf "$final_path"/static-laverna-gh-pages + +# mkdir -p $final_path +# wget -P "$src_path" https://github.com/Laverna/static-laverna/archive/gh-pages.zip -O "$final_path"/laverna.zip +# unzip "$final_path"/laverna.zip -d "$final_path" +# cp -R "$final_path"/static-laverna-gh-pages/* "$final_path" +# rm "$final_path"/laverna.zip +# rm -rf "$final_path"/static-laverna-gh-pages + +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= # Set permissions to app files chown -R root: $final_path diff --git a/scripts/remove b/scripts/remove index 9a5dc51..42b25eb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,19 +1,80 @@ #!/bin/bash -# See comments in install script -app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source YunoHost helpers +source _common.sh source /usr/share/yunohost/helpers -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -# Remove sources -sudo rm -rf /var/www/$app +app=$YNH_APP_INSTANCE_NAME -# Remove nginx configuration file -sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# REMOVE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Removing the MySQL database..." --time --weight=1 + +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name + +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --time --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." --time --weight=1 + +# Remove the app directory securely +ynh_secure_remove --file="$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 + +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# REMOVE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1 + +# Remove the dedicated php-fpm config +ynh_remove_fpm_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --time --last -# Reload nginx service -sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade index 1decc77..37a8917 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,8 +21,8 @@ path=${path%/} # Copy source files src_path=/var/www/$app -sudo mkdir -p $src_path -sudo cp -a ../sources/. $src_path +mkdir -p $src_path +cp -a ../sources/. $src_path # Set permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user) @@ -35,7 +35,7 @@ sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf # If a dedicated php-fpm process is used: # # sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf -sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf ### PHP (remove if not used) ### # If a dedicated php-fpm process is used: @@ -49,11 +49,28 @@ sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf # sudo service php5-fpm restart ### PHP end ### -# If app is public, add url to SSOWat conf as skipped_uris -if [[ $is_public -eq 1 ]]; then - # See install script - ynh_app_setting_set "$app" unprotected_uris "/" +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi -# Reload nginx service -sudo service nginx reload +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last +