diff --git a/check_process b/check_process index a4884c4..f8e73cc 100644 --- a/check_process +++ b/check_process @@ -1,12 +1,8 @@ ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) - language="fr" - is_public=1 (PUBLIC|public=1|private=0) - password="pass" - port="666" (PORT) + domain="domain.tld" + path="/path" + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=1 @@ -15,10 +11,9 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=CommitHash + #upgrade=1 from_commit=CommitHash backup_restore=1 multi_instance=1 - port_already_use=0 change_url=1 ;;; Options Email= diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..947013d --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +scrumblr is a web-based simulation of a physical agile kanban board that supports real-time collaboration. it is built using node.js, websockets (using socket.io), CSS3, and jquery. \ No newline at end of file diff --git a/doc/screenshots/687474703a2f2f736372756d626c722e63612f696d616765732f73637265656e73686f742e706e67.png b/doc/screenshots/687474703a2f2f736372756d626c722e63612f696d616765732f73637265656e73686f742e706e67.png new file mode 100644 index 0000000..aa3742f Binary files /dev/null and b/doc/screenshots/687474703a2f2f736372756d626c722e63612f696d616765732f73637265656e73686f742e706e67.png differ diff --git a/manifest.json b/manifest.json index 24784bf..1508310 100644 --- a/manifest.json +++ b/manifest.json @@ -4,9 +4,18 @@ "packaging_format": 1, "description": { "en": "Software for notes", - "fr": "Application pour créer des post-it." + "fr": "Application pour créer des post-it" }, + "version": "1.0~ynh1", "url": "http://www.scrumblr.ca/", + + "upstream": { + "license": "GPLv3", + "website": "http://www.scrumblr.ca/", + "demo": "http://scrumblr.ca/", + "code": "https://github.com/aliasaria/scrumblr" + "code": "https://framagit.org/framasoft/framemo" + }, "license": "GPLv3", "maintainer": { "name": "frju365", @@ -14,7 +23,7 @@ "url": "https://github.com/YunoHost-Apps/scrumblr_ynh" }, "requirements": { - "yunohost": ">> 3.8.1" + "yunohost": ">> 4.3.0" }, "multi_instance": false, "services": [ @@ -24,30 +33,17 @@ "install" : [ { "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain name for Haste", - "fr": "Choisissez un nom de domaine pour Haste" - }, - "example": "example.com" + "type": "domain" }, { "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for scrumblr, only / is allowed.", - "fr": "Choisissez un chemin pour scrumblr, seul / est autorisé." - }, + "type": "path", "example": "/", "default": "/" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public site? ", - "fr": "Est-ce un site publique ? " - }, "default": true } ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 30e8f5e..ea870fc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,7 +6,7 @@ YNH_PHP_VERSION="7.3" -pkg_dependencies="redis-server php${YNH_PHP_VERSION}-redis" +pkg_dependencies="php${YNH_PHP_VERSION}-redis" nodejs_version=12 diff --git a/scripts/install b/scripts/install index 6ed46ad..a5f0819 100644 --- a/scripts/install +++ b/scripts/install @@ -47,18 +47,18 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=1 +ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port port=$(ynh_find_port --port=4000) ynh_app_setting_set --app=$app --key=port --value=$port + #================================================= # INSTALL NODEJS #================================================= @@ -68,6 +68,14 @@ ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --time --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -77,24 +85,18 @@ 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" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --time --weight=1 - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # SPECIFIC SETUP #================================================= @@ -112,21 +114,12 @@ chown admin -R $install_log # Configuration de logrotate ynh_use_logrotate -#================================================= -# Copy files to the right place -#================================================= - -# Files owned by root, www-data can just read -chown -R www-data: $final_path -chmod -R 755 $final_path - #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_add_systemd_config @@ -136,21 +129,15 @@ ynh_add_systemd_config pushd $final_path ynh_use_nodejs - npm install >> $install_log 2>&1 + $ynh_npm install >> $install_log 2>&1 popd #================================================= -# Enable Database +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -service redis-server start - -# #================================================= -# # INTEGRATE SERVICE IN YUNOHOST -# #================================================= -# ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -# yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -163,7 +150,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # Set Public or private #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary or protect it if [ $is_public -eq 1 ] diff --git a/scripts/remove b/scripts/remove index 935a16b..1908c44 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,34 +1,90 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -u +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source app helpers source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + app=$YNH_APP_INSTANCE_NAME -# Retrieve app settings -domain=$(ynh_app_setting_get $app domain) +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Stop and remove service +#================================================= +# STANDARD REMOVE +#================================================= +# REMOVE SERVICE INTEGRATION IN YUNOHOST +#================================================= + +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status $app >/dev/null +then + ynh_script_progression --message="Removing $app service integration..." --time --weight=1 + yunohost service remove $app +fi + +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 + +# Remove the dedicated systemd config ynh_remove_systemd_config -# Remove logrotate configuration +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 + +# Remove the app-specific logrotate config ynh_remove_logrotate -# Remove sources -ynh_secure_remove "/var/www/$app" +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --time --weight=1 -# Remove nginx configuration file +# Remove metapackage and its dependencies +ynh_remove_nodejs + +#================================================= +# 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 user and data -ynh_system_user_delete $app +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 -# Remove monitor -sudo yunohost service remove $app +# Delete a system user +ynh_system_user_delete --username=$app -# Remove Nodejs -ynh_remove_nodejs +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --time --last diff --git a/scripts/restore b/scripts/restore index 9b0d8e3..a37d708 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,38 +1,131 @@ #!/bin/bash -set -eu -# Récupère les infos de l'application. -app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source app helpers +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -codename=$(ynh_app_setting_get $app codename) +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# The parameter $1 is the uncompressed restore directory location -backup_dir=$1/apps/$app +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Restore sources & data -sudo cp -a $backup_dir/sources/. $final_path +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -# Restore Nginx and YunoHost parameters -sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app -sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +app=$YNH_APP_INSTANCE_NAME +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Installation de perlmagick, interface perl pour imagemagick et de carton, gestionnaire de dépendances perl -sudo apt-get update -sudo apt-get install npm nodejs nodejs-legacy -qy +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 -# Restauration des fichiers du script systemd -sudo cp -a $backup_dir/scrumblr.service /etc/systemd/system/scrumblr.service -## Démarrage auto du service -sudo systemctl enable scrumblr.service +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " -# Restart webserver -sudo service nginx reload +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX configuration..." --time --weight=1 -# Start scrumblr -sudo service scrumblr start +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 + +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 + +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." --time --weight=1 + +ynh_restore_file --origin_path="/etc/cron.d/$app" + +ynh_restore_file --origin_path="/etc/$app/" + +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable $app.service --quiet + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1 + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 + +yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --time --weight=1 + +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --time --last diff --git a/scripts/upgrade b/scripts/upgrade index 24f8e29..ec5c63e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,9 +1,7 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -14,120 +12,141 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -# Set app specific variables +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + app=$YNH_APP_INSTANCE_NAME -# Check destination directory -DESTDIR="/var/www/$app" -[[ ! -d $DESTDIR ]] && ynh_die \ -"The destination directory '$DESTDIR' does not exist.\ - The app is not correctly installed, you should remove it first." - -# Retrieve arguments -domain=$(ynh_app_setting_get "$app" domain) -final_path=$(ynh_app_setting_get "$app" final_path) -is_public=$(ynh_app_setting_get "$app" is_public) -port=$(ynh_app_setting_get "$app" port) -install_log=/var/log/$app/installation.log +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# MANAGE SCRIPT FAILURE +# CHECK VERSION #================================================= -# Use prior backup and restore on error only if backup feature -# exists on installed instance -if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then - ynh_backup_before_upgrade # Backup the current version of the app - ynh_clean_setup () { - ynh_backup_after_failed_upgrade - } - ynh_abort_if_errors # Stop script if an error is detected +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -#================================================= -# INSTALL NODEJS -#================================================= +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all -ynh_install_nodejs 6.2.0 + ynh_app_setting_delete --app=$app --key=is_public +fi #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 -ynh_system_user_create $app - -#================================================= -# SPECIFIC SETUP -#================================================= -# HANDLE LOG FILES AND LOGROTATE -#================================================= - -# Setup logrotate -ynh_use_logrotate /var/log/${app}/*.log --non-append +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -final_path=/var/www/$app -ynh_app_setting_set $app final_path $final_path -ynh_setup_source $final_path - -# Set files ownership during installation -sudo chown $app: $final_path -R -sudo chmod 755 $final_path -R - -#================================================= -# Modify Nginx configuration file and copy it to Nginx conf directory -#================================================= - -ynh_nginx_config - -#================================================= -# ADD SYSTEMD SERVICE -#================================================= - -ynh_replace_string "__NODE__" "$nodejs_path" "../conf/systemd.service" -ynh_replace_string "__NODEJS__" "$nodejs_use_version" "../conf/systemd.service" -ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" -ynh_systemd_config - - -#================================================= -# INSTALL OSJS -#================================================= - -script_dir="$PWD" -pushd "$final_path" -chown -R $app: $final_path -npm install --production >> $install_log 2>&1 -popd -service redis-server start - -#================================================= -# ENABLE SERVICE IN ADMIN PANEL -#================================================= - -# Ajoute le service au monitoring de Yunohost. -yunohost service add $app --log "/var/log/$app/$app.log" - -#================================================= -# START OSJS IN BACKGROUND -#================================================= - -systemctl start $app - -#================================================= -# SETUP SSOWAT -#================================================= - -if [ $is_public -eq 1 ]; +if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_app_setting_set "$app" unprotected_uris "/" + ynh_script_progression --message="Upgrading source files..." --time --weight=1 + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 + +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 + +yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # RELOAD NGINX #================================================= -sudo systemctl restart php5-fpm -sudo systemctl 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