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

Merge pull request #51 from YunoHost-Apps/testing

Testing
This commit is contained in:
yalh76 2019-05-16 20:37:09 +02:00 committed by GitHub
commit 19baca81ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 121 additions and 84 deletions

View file

@ -35,9 +35,9 @@ The app can be used by multiple users, anonymously.
#### Supported architectures #### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/distbin%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/distbin/) * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/distbin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/distbin/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/distbin%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/distbin/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/distbin%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/distbin/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/distbin%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/distbin/) * Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/distbin%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/distbin/)
## Limitations ## Limitations

View file

@ -6,8 +6,7 @@
"en": "Distributed pastebin with ActivityPub.", "en": "Distributed pastebin with ActivityPub.",
"fr": "Pastebin distribué utilisant le protocole ActivityPub." "fr": "Pastebin distribué utilisant le protocole ActivityPub."
}, },
"version": "1.3.0~ynh3", "version": "1.3.0~ynh4",
"url": "https://example.com",
"license": "Apache-2.0", "license": "Apache-2.0",
"maintainer": { "maintainer": {
"name": "yalh76" "name": "yalh76"

View file

@ -30,6 +30,9 @@ ynh_print_info --message="Loading installation settings..."
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application # Add settings here as needed by your application
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#db_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
@ -50,6 +53,13 @@ fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd --line_match="Stopped Distbin Service"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
@ -81,15 +91,10 @@ fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#=================================================
# STOP SERVICE
#=================================================
ynh_systemd_action --action=stop --service_name=$app --log_path=systemd --line_match="Stopped Distbin Service"
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying config file..."
# Change the URL in the configuration file # Change the URL in the configuration file
@ -102,19 +107,25 @@ fi
ynh_replace_string --match_string="EXTERNAL_URL=.*" --replace_string="EXTERNAL_URL=https://$new_domain_uri/" --target_file="$final_path/.env" ynh_replace_string --match_string="EXTERNAL_URL=.*" --replace_string="EXTERNAL_URL=https://$new_domain_uri/" --target_file="$final_path/.env"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_print_info --message="Storing the config file checksum..."
ynh_backup_if_checksum_is_different --file="$final_path/.env" ynh_backup_if_checksum_is_different --file="$final_path/.env"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/.env" ynh_store_file_checksum --file="$final_path/.env"
#================================================= #=================================================
# START SERVICE # GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service" ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service"
sleep 10 sleep 10
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================

View file

@ -57,7 +57,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_print_info --message="Configuring firewall..." ynh_print_info --message="Configuring firewall..."
# Find a free port # Find a free port
port=$(ynh_find_port 8095) port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
@ -66,7 +66,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port
ynh_print_info --message="Installing dependencies..." ynh_print_info --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs 10 ynh_install_nodejs --nodejs_version="10"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -91,13 +91,14 @@ ynh_add_nginx_config
ynh_print_info --message="Configuring system user..." ynh_print_info --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create "$app" "$final_path" ynh_system_user_create --username="$app" --home_dir="$final_path"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
# CREATE LOG FOLDER # CREATE LOG FOLDER
#================================================= #=================================================
ynh_print_info --message="Creating log folder..."
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app" chown -R "$app":"$app" "/var/log/$app"
@ -105,16 +106,19 @@ chown -R "$app":"$app" "/var/log/$app"
#================================================= #=================================================
# CREATE DB FOLDER # CREATE DB FOLDER
#================================================= #=================================================
ynh_print_info --message="Creating DB folder..."
mkdir -p "$final_path/distbin-db" mkdir -p "$final_path/distbin-db"
mkdir -p "$final_path/distbin-db/activities" mkdir -p "$final_path/distbin-db/activities"
mkdir -p "$final_path/distbin-db/inbox" mkdir -p "$final_path/distbin-db/inbox"
#================================================= #=================================================
# MAKE SETUP # INSTALLING DISTBIN
#================================================= #=================================================
ynh_print_info --message="Installing distin..."
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
pushd $final_path pushd $final_path
ynh_use_nodejs ynh_use_nodejs
sudo -u $app env PATH=$PATH npm install --ignore-scripts sudo -u $app env PATH=$PATH npm install --ignore-scripts
@ -126,7 +130,6 @@ pushd $final_path/dist
sudo -u $app env PATH=$PATH npm install --ignore-scripts --production sudo -u $app env PATH=$PATH npm install --ignore-scripts --production
popd popd
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
@ -138,6 +141,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying a config file..."
cp "../conf/.env" "$final_path/.env" cp "../conf/.env" "$final_path/.env"
@ -156,6 +160,7 @@ ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_print_info --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/.env" ynh_store_file_checksum --file="$final_path/.env"
@ -165,6 +170,7 @@ ynh_store_file_checksum --file="$final_path/.env"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
@ -180,11 +186,20 @@ ynh_use_logrotate
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
ynh_print_info --message="Advertising service in admin panel..."
#yunohost service add $app --log "/var/log/$app/$app.log" #yunohost service add $app --log "/var/log/$app/$app.log"
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added # if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
yunohost service add $app --description "$app daemon for distbin" --log "/var/log/$app/$app.log" yunohost service add $app --description "$app daemon for distbin" --log "/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Distbin Service"
sleep 10
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
@ -202,14 +217,7 @@ fi
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# START SERVICE
#=================================================
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service"
sleep 10
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -29,14 +29,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Remove a service from the admin panel, added by `yunohost service add` # Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status $app >/dev/null 2>&1 if yunohost service status $app >/dev/null 2>&1
then then
ynh_print_info --message="Removing $app service" ynh_print_info --message="Removing $app service..."
yunohost service remove $app yunohost service remove $app
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_print_info --message="Stopping and removing the systemd service" ynh_print_info --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
@ -44,7 +44,7 @@ ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info --message="Removing dependencies" ynh_print_info --message="Removing dependencies..."
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -53,7 +53,7 @@ ynh_remove_nodejs
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info --message="Removing app main directory" ynh_print_info --message="Removing app main directory..."
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -61,7 +61,7 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Removing nginx web server configuration" ynh_print_info --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -69,7 +69,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_print_info --message="Removing logrotate configuration" ynh_print_info --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -77,11 +77,10 @@ ynh_remove_logrotate
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
ynh_print_info --message="Closing a port..."
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
ynh_print_info --message="Closing port $port" ynh_print_info --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
@ -99,7 +98,7 @@ ynh_secure_remove --file="/var/log/$app/"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info --message="Removing the dedicated system user" ynh_print_info --message="Removing the dedicated system user..."
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app

View file

@ -68,6 +68,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Restore permissions on app files # Restore permissions on app files
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
@ -77,6 +78,7 @@ chown -R "$app":"$app" "$final_path"
#================================================= #=================================================
# CREATE LOG FOLDER # CREATE LOG FOLDER
#================================================= #=================================================
ynh_print_info --message="Creating log folder..."
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app" chown -R "$app":"$app" "/var/log/$app"
@ -88,7 +90,7 @@ ynh_print_info --message="Reinstalling dependencies..."
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs 10 ynh_install_nodejs --nodejs_version="10"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
@ -102,9 +104,18 @@ systemctl daemon-reload
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
ynh_print_info --message="Advertising service in admin panel..."
yunohost service add $app --log "/var/log/$app/$app.log" yunohost service add $app --log "/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Distbin Service"
sleep 10
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
@ -118,21 +129,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# CREATE LOG FOLDER
#=================================================
mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app"
#=================================================
# START SERVICE
#=================================================
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service"
sleep 10
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -22,6 +22,12 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) 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)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -37,7 +43,7 @@ elif [ "$is_public" = "No" ]; then
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=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
@ -57,21 +63,28 @@ ynh_clean_setup () {
# 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
#=================================================
# STOP SERVICE
#=================================================
ynh_systemd_action --action=stop --service_name=$app
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action=stop
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_print_info --message="Upgrading source files..." ynh_print_info --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src# # Download, check integrity, uncompress and patch the source from app.src#
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
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" ynh_setup_source --dest_dir="$final_path"
fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -87,8 +100,7 @@ ynh_add_nginx_config
ynh_print_info --message="Upgrading dependencies..." ynh_print_info --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
ynh_remove_nodejs ynh_install_nodejs --nodejs_version="10"
ynh_install_nodejs 10
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -100,9 +112,18 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#=================================================
# CREATE LOG FOLDER
#=================================================
ynh_print_info --message="Creating log folder..."
mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app"
#================================================= #=================================================
# CREATE STORAGE FOLDER # CREATE STORAGE FOLDER
#================================================= #=================================================
ynh_print_info --message="Creating storage folder..."
DIRECTORY="$final_path/db" DIRECTORY="$final_path/db"
#Move old db #Move old db
@ -113,6 +134,7 @@ fi
#================================================= #=================================================
# MAKE INSTALL # MAKE INSTALL
#================================================= #=================================================
ynh_print_info --message="Making install..."
chown -R "$app":"$app" "$final_path" chown -R "$app":"$app" "$final_path"
pushd $final_path pushd $final_path
@ -129,6 +151,7 @@ popd
#================================================= #=================================================
# MODIFY A CONFIG FILE # MODIFY A CONFIG FILE
#================================================= #=================================================
ynh_print_info --message="Modifying config file..."
cp "../conf/.env" "$final_path/.env" cp "../conf/.env" "$final_path/.env"
@ -144,6 +167,11 @@ ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_f
ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain_uri" --target_file="$final_path/.env" ynh_replace_string --match_string="__DOMAIN_URI__" --replace_string="$domain_uri" --target_file="$final_path/.env"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$final_path/.env" ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$final_path/.env"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_print_info --message="Storing the config file checksum..."
ynh_backup_if_checksum_is_different --file="$final_path/.env" ynh_backup_if_checksum_is_different --file="$final_path/.env"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/.env" ynh_store_file_checksum --file="$final_path/.env"
@ -169,17 +197,11 @@ ynh_add_systemd_config
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions on app files # Set permissions on app files
chown -R $app:$app $final_path chown -R $app:$app $final_path
#=================================================
# CREATE LOG FOLDER
#=================================================
mkdir -p "/var/log/$app"
chown -R "$app":"$app" "/var/log/$app"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
@ -192,19 +214,20 @@ then
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_print_info --message="Starting a systemd service..."
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service"
sleep 10
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_print_info --message="Reloading nginx web server..." ynh_print_info --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# START SERVICE
#=================================================
ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Started Distbin Service"
sleep 10
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT