mirror of
https://github.com/YunoHost-Apps/syncthing_ynh.git
synced 2024-09-03 20:26:23 +02:00
Apply example_ynh
This commit is contained in:
parent
f38524f97d
commit
1b65ba55ca
10 changed files with 57 additions and 72 deletions
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
0
doc/DISCLAIMER.md
Normal file
0
doc/DISCLAIMER.md
Normal file
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
BIN
doc/screenshots/screenshot1.png
Normal file
BIN
doc/screenshots/screenshot1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
|
@ -8,6 +8,13 @@
|
|||
},
|
||||
"version": "1.17.0~ynh1",
|
||||
"url": "https://syncthing.net/",
|
||||
"upstream": {
|
||||
"license": "MPL-2.0",
|
||||
"website": "https://syncthing.net",
|
||||
|
||||
"userdoc": "https://docs.syncthing.net",
|
||||
"code": "https://github.com/syncthing/syncthing"
|
||||
},
|
||||
"license": "MPL-2.0",
|
||||
"maintainer": [
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
@ -42,6 +42,12 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIRECTORY
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$sync_home" --is_big
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -56,13 +62,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE DATA DIRECTORY
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up data directory..."
|
||||
|
||||
ynh_backup --src_path="$sync_home" --is_big
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -93,7 +93,7 @@ then
|
|||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config "gui_port"
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for NGINX
|
||||
|
|
|
@ -30,9 +30,6 @@ admin=$YNH_APP_ARG_ADMIN
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Configure sync folder
|
||||
sync_home="/home/yunohost.app/$app"
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
|
@ -52,7 +49,6 @@ ynh_script_progression --message="Storing installation settings..."
|
|||
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=admin --value=$admin
|
||||
ynh_app_setting_set --app=$app --key=sync_home --value=$sync_home
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -78,7 +74,7 @@ ynh_exec_warn_less yunohost firewall allow TCP $sync_port
|
|||
ynh_script_progression --message="Configuring 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
|
||||
|
@ -99,7 +95,7 @@ chown -R $app:$app "$final_path"
|
|||
ynh_script_progression --message="Configuring NGINX web server..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config "gui_port"
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
|
@ -108,8 +104,11 @@ ynh_add_nginx_config "gui_port"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Creating sync directory..."
|
||||
|
||||
# Make directories and set rights
|
||||
mkdir -p "$sync_home"
|
||||
sync_home=/home/yunohost.app/$app
|
||||
ynh_app_setting_set --app=$app --key=sync_home --value=$sync_home
|
||||
|
||||
mkdir -p $sync_home
|
||||
|
||||
chmod 750 "$sync_home"
|
||||
chmod -R o-rwx "$sync_home"
|
||||
chown -R $app:$app "$sync_home"
|
||||
|
@ -147,12 +146,6 @@ ynh_replace_string --match_string="<listenAddress>tcp://default</listenAddress>"
|
|||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing the config file checksum..."
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$config_file"
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -79,22 +79,21 @@ chmod 750 "$final_path"
|
|||
chmod -R o-rwx "$final_path"
|
||||
chown -R $app:$app "$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# RECREATE SYNC DIRECTORY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating sync directory..."
|
||||
|
||||
# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup.
|
||||
ynh_restore_file --origin_path="$sync_home" --not_mandatory
|
||||
|
||||
# Make directories and set rights
|
||||
mkdir -p "$sync_home"
|
||||
mkdir -p $sync_home
|
||||
|
||||
chmod 750 "$sync_home"
|
||||
chmod -R o-rwx "$sync_home"
|
||||
chown -R $app:$app "$sync_home"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
|
|
|
@ -32,18 +32,34 @@ ynh_script_progression --message="Checking version..."
|
|||
|
||||
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)..."
|
||||
|
||||
# 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..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
# If gui_port doesn't exist, create it
|
||||
if [ -z $gui_port ]; then
|
||||
OLD_SYNCHOME="/home/yunohost.app/syncthing"
|
||||
|
@ -85,40 +101,13 @@ if [ -z $gui_port ]; then
|
|||
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
else
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Inform the backup/restore process that it should not save the data directory
|
||||
# Use only for the previous backup script that doesn't set 'is_big'
|
||||
ynh_app_setting_set --app=$app --key=backup_core_only --value=1
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
||||
# Remove the option backup_core_only after the backup.
|
||||
ynh_app_setting_delete --app=$app --key=backup_core_only
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
# 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..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
# Cleaning legacy permissions
|
||||
if ynh_legacy_permissions_exists; then
|
||||
ynh_legacy_permissions_delete_all
|
||||
|
||||
ynh_app_setting_delete --app=$app --key=is_public
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -127,7 +116,7 @@ fi
|
|||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# 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
|
||||
|
@ -151,7 +140,7 @@ chown -R $app:$app "$final_path"
|
|||
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config "gui_port"
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
|
@ -173,9 +162,7 @@ ynh_script_progression --message="Updating a config file..."
|
|||
|
||||
config_file="$final_path/.config/syncthing/config.xml"
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$config_file"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
ynh_store_file_checksum --file="$config_file"
|
||||
ynh_add_config --template="../conf/config.xml" --destination="$config_file"
|
||||
|
||||
chmod 400 "$config_file"
|
||||
chown $app:$app "$config_file"
|
||||
|
|
Loading…
Add table
Reference in a new issue