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

Apply last example_ynh

This commit is contained in:
yalh76 2022-03-10 02:47:20 +01:00
parent d48461cbf1
commit 01a679245a
15 changed files with 96 additions and 88 deletions

View file

@ -2,8 +2,8 @@
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path" path="/path"
admin="john"
is_public=1 is_public=1
admin="john"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -12,6 +12,8 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 2.0.0~ynh4
upgrade=1 from_commit=e381055bd0e6b6b862bdbec72945ec589d8128d7
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=1 port_already_use=1
@ -20,4 +22,3 @@
Email= Email=
Notification=none Notification=none
;;; Upgrade options ;;; Upgrade options
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,4 +1,5 @@
location ^~ __PATH__/ { #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__/; proxy_pass http://127.0.0.1:__PORT__/;
proxy_redirect off; proxy_redirect off;

View file

@ -7,7 +7,7 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__ WorkingDirectory=__FINALPATH__/
Environment="PATH=__ENV_PATH__" Environment="PATH=__ENV_PATH__"
Environment="NODE_ENV=production" Environment="NODE_ENV=production"
ExecStart=__YNH_NPM__ run build ExecStart=__YNH_NPM__ run build

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Luckysheet is an online spreadsheet that is powerful, simple to configure, and completely open source.

0
doc/DISCLAIMER.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

View file

@ -8,6 +8,13 @@
}, },
"version": "2.0.0~ynh4", "version": "2.0.0~ynh4",
"url": "https://github.com/mengshukeji/Luckysheet", "url": "https://github.com/mengshukeji/Luckysheet",
"upstream": {
"license": "MIT",
"website": "https://github.com/mengshukeji/Luckysheet",
"demo": "https://mengshukeji.github.io/LuckysheetDemo/",
"admindoc": "https://mengshukeji.github.io/LuckysheetDocs/guide/",
"code": "https://github.com/mengshukeji/Luckysheet"
},
"license": "MIT", "license": "MIT",
"maintainer": { "maintainer": {
"name": "eric_G" "name": "eric_G"
@ -20,7 +27,7 @@
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,7 +15,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting true
} }
# 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
@ -58,4 +59,4 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for Luckysheet. (YunoHost will then actually copy those files to the archive)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -31,17 +31,18 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up Luckysheet before changing its URL (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# 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 () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# 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
@ -122,4 +123,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for Luckysheet" --last ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -73,7 +73,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_script_progression --message="Configuring system user..." --weight=3 ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -82,7 +82,11 @@ ynh_script_progression --message="Setting up source files..." --weight=2
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# 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 --dest_dir=$final_path 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 # NGINX CONFIGURATION
@ -95,19 +99,24 @@ ynh_add_nginx_config
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#============================================== #==============================================
# INSTALL HEDGEDOC # BUILD LUCKYSHEET
#============================================== #==============================================
ynh_script_progression --message="Building Luckysheet... (this will take some time and resources!)" --weight=20 ynh_script_progression --message="Building Luckysheet... (this will take some time and resources!)" --weight=20
pushd "$final_path" pushd "$final_path"
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install ynh_exec_warn_less $ynh_npm install 2>/dev/null
ynh_exec_warn_less $ynh_npm install gulp -g ynh_exec_warn_less $ynh_npm install gulp -g 2>/dev/null
popd popd
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# MODIFY A CONFIG FILE # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..."
cp ../conf/config.example.js $final_path/src/config.js cp ../conf/config.example.js $final_path/src/config.js
@ -116,21 +125,12 @@ cp ../conf/config.example.js $final_path/src/config.js
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 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" env_path="$PATH"
ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files
chown -R $app: $final_path
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -151,7 +151,7 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
@ -168,4 +168,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of Luckysheet completed" --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -29,7 +29,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # 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 if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing Luckysheet service..." --weight=1 ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app yunohost service remove $app
fi fi
@ -41,13 +41,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -61,9 +54,16 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
# Remove the dedicated nginx config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -78,4 +78,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of Luckysheet completed" --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -22,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -35,38 +36,33 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2 ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring Luckysheet main directory..." --weight=50
ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring user rights..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=50
ynh_restore_file --origin_path="$final_path"
# Restore permissions on app files
chown -R $app: $final_path chown -R $app: $final_path
#================================================= #=================================================
@ -114,4 +110,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for Luckysheet" --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -28,27 +28,16 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up Luckysheet before upgrading (may take a while)..." --weight=20 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=20
# 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 ynh_clean_check_starting
# 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
@ -63,13 +52,25 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -83,9 +84,13 @@ then
ynh_secure_remove --file=$final_path ynh_secure_remove --file=$final_path
# 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 --dest_dir=$final_path ynh_setup_source --dest_dir="$final_path"
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -105,7 +110,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#============================================== #==============================================
# INSTALL HEDGEDOC # BUILD LUCKYSHEET
#============================================== #==============================================
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
@ -113,31 +118,26 @@ then
pushd "$final_path" pushd "$final_path"
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install ynh_exec_warn_less $ynh_npm install 2>/dev/null
ynh_exec_warn_less $ynh_npm install gulp -g ynh_exec_warn_less $ynh_npm install gulp -g 2>/dev/null
popd popd
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2 ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
env_path="$PATH"
# 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
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions on app files
chown -R $app: $final_path
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -163,4 +163,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of Luckysheet completed" --last ynh_script_progression --message="Upgrade of $app completed" --last