mirror of
https://github.com/YunoHost-Apps/syncthing_ynh.git
synced 2024-09-03 20:26:23 +02:00
commit
29e26b973a
18 changed files with 1373 additions and 879 deletions
7
.travis.yml
Normal file
7
.travis.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
language: python
|
||||
|
||||
before_install:
|
||||
- git clone https://github.com/YunoHost/package_linter /tmp/package_linter
|
||||
|
||||
script:
|
||||
- /tmp/package_linter/package_linter.py ./
|
54
README.md
54
README.md
|
@ -1,4 +1,54 @@
|
|||
# syncthing_ynh
|
||||
# Syncthing app for YunoHost
|
||||
|
||||
Only for Debian Jessie and after
|
||||
[](https://dash.yunohost.org/appci/app/syncthing)
|
||||
[](https://install-app.yunohost.org/?app=syncthing)
|
||||
|
||||
> *This package allow you to install Syncthing quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
||||
## Overview
|
||||
Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet.
|
||||
|
||||
**Shipped version:** 1.1.1
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## Configuration
|
||||
|
||||
How to configure this app: by an admin panel, a plain file with SSH, or any other way.
|
||||
|
||||
## Documentation
|
||||
|
||||
* Official documentation: https://docs.syncthing.net
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/syncthing/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/syncthing/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/syncthing/)
|
||||
|
||||
## Links
|
||||
|
||||
* Report a bug: https://github.com/YunoHost-Apps/syncthing_ynh/issues
|
||||
* App website: https://syncthing.net/
|
||||
* Upstream app repository: https://github.com/syncthing/syncthing
|
||||
* YunoHost website: https://yunohost.org/
|
||||
|
||||
---
|
||||
|
||||
Developers info
|
||||
----------------
|
||||
|
||||
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
|
||||
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/syncthing_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
```
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/syncthing_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade syncthing -u https://github.com/YunoHost-Apps/syncthing_ynh/tree/testing --debug
|
||||
```
|
||||
|
|
41
check_process
Normal file
41
check_process
Normal file
|
@ -0,0 +1,41 @@
|
|||
# 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)
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
setup_root=1
|
||||
setup_nourl=0
|
||||
setup_private=0
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
|
||||
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
|
||||
Level 4=0
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
||||
|
6
conf/app.src
Normal file
6
conf/app.src
Normal file
|
@ -0,0 +1,6 @@
|
|||
SOURCE_URL=https://github.com/syncthing/syncthing/releases/download/v1.1.1/syncthing-linux-amd64-v1.1.1.tar.gz
|
||||
SOURCE_SUM=33554cdc9c6ed4f540cca234c10c046b40d036e24730eebe95e9cffa1c3dd61e
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
48
conf/config.xml
Normal file
48
conf/config.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<configuration>
|
||||
<gui enabled="true" tls="false" debugging="false">
|
||||
<address>127.0.0.1:__GUI_PORT__</address>
|
||||
</gui>
|
||||
<ldap>
|
||||
<address>localhost:389</address>
|
||||
<bindDN>uid=%s,ou=users,dc=yunohost,dc=org</bindDN>
|
||||
<transport>nontls</transport>
|
||||
<insecureSkipVerify>false</insecureSkipVerify>
|
||||
</ldap>
|
||||
<options>
|
||||
<listenAddress>default</listenAddress>
|
||||
<globalAnnounceServer>default</globalAnnounceServer>
|
||||
<globalAnnounceEnabled>true</globalAnnounceEnabled>
|
||||
<localAnnounceEnabled>true</localAnnounceEnabled>
|
||||
<maxSendKbps>0</maxSendKbps>
|
||||
<maxRecvKbps>0</maxRecvKbps>
|
||||
<reconnectionIntervalS>60</reconnectionIntervalS>
|
||||
<relaysEnabled>true</relaysEnabled>
|
||||
<relayReconnectIntervalM>10</relayReconnectIntervalM>
|
||||
<startBrowser>true</startBrowser>
|
||||
<natEnabled>false</natEnabled>
|
||||
<natLeaseMinutes>0</natLeaseMinutes>
|
||||
<natRenewalMinutes>0</natRenewalMinutes>
|
||||
<natTimeoutSeconds>0</natTimeoutSeconds>
|
||||
<urAccepted>3</urAccepted>
|
||||
<urSeen>3</urSeen>
|
||||
<urUniqueID></urUniqueID>
|
||||
<urURL>https://data.syncthing.net/newdata</urURL>
|
||||
<urPostInsecurely>false</urPostInsecurely>
|
||||
<urInitialDelayS>1800</urInitialDelayS>
|
||||
<restartOnWakeup>true</restartOnWakeup>
|
||||
<autoUpgradeIntervalH>12</autoUpgradeIntervalH>
|
||||
<upgradeToPreReleases>false</upgradeToPreReleases>
|
||||
<keepTemporariesH>24</keepTemporariesH>
|
||||
<cacheIgnoredFiles>false</cacheIgnoredFiles>
|
||||
<progressUpdateIntervalS>5</progressUpdateIntervalS>
|
||||
<limitBandwidthInLan>false</limitBandwidthInLan>
|
||||
<minHomeDiskFree unit="%">0</minHomeDiskFree>
|
||||
<releasesURL>https://upgrades1.syncthing.net/meta.json</releasesURL>
|
||||
<overwriteRemoteDeviceNamesOnConnect>true</overwriteRemoteDeviceNamesOnConnect>
|
||||
<tempIndexMinBlocks>10</tempIndexMinBlocks>
|
||||
<trafficClass>0</trafficClass>
|
||||
<defaultFolderPath>__SYNC_HOME__</defaultFolderPath>
|
||||
<setLowPriority>true</setLowPriority>
|
||||
<maxConcurrentScans>0</maxConcurrentScans>
|
||||
</options>
|
||||
</configuration>
|
|
@ -1,14 +0,0 @@
|
|||
/var/log/syncthing.log {
|
||||
rotate 4
|
||||
weekly
|
||||
minsize 1M
|
||||
missingok
|
||||
create 640 root adm
|
||||
notifempty
|
||||
compress
|
||||
delaycompress
|
||||
postrotate
|
||||
systemctl restart syncthing@SYNCUSER > /dev/null
|
||||
endscript
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
location PATHTOCHANGE/ {
|
||||
location __PATH__/ {
|
||||
proxy_set_header Host 127.0.0.1;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
proxy_pass http://127.0.0.1:PORTTOCHANGE/;
|
||||
proxy_pass http://127.0.0.1:__GUI_PORT__/;
|
||||
|
||||
proxy_read_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
|
|
21
conf/systemd.service
Normal file
21
conf/systemd.service
Normal file
|
@ -0,0 +1,21 @@
|
|||
[Unit]
|
||||
Description=Syncthing - Open Source Continuous File Synchronization for %I
|
||||
Documentation=man:syncthing(1)
|
||||
After=multi-user.target network.target
|
||||
|
||||
[Service]
|
||||
User=__APP__
|
||||
ExecStart=__FINALPATH__/syncthing -no-browser -no-restart -logflags=0
|
||||
Restart=on-failure
|
||||
SuccessExitStatus=3 4
|
||||
RestartForceExitStatus=3 4
|
||||
|
||||
# Hardening
|
||||
ProtectSystem=full
|
||||
PrivateTmp=true
|
||||
SystemCallArchitectures=native
|
||||
MemoryDenyWriteExecute=true
|
||||
NoNewPrivileges=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
110
manifest.json
110
manifest.json
|
@ -1,61 +1,53 @@
|
|||
{
|
||||
"name": "Syncthing",
|
||||
"id": "syncthing",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized.",
|
||||
"fr": "Syncthing remplace les services propriétaires de synchro et de cloud avec quelque chose d'ouvert, digne de confiance et décentralisée."
|
||||
},
|
||||
"url": "https://syncthing.net/",
|
||||
"license": "free",
|
||||
"maintainer": {
|
||||
"name": "txmrl",
|
||||
"email": "txmrl@txmrl.net"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.4.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Syncthing"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Syncthing"
|
||||
},
|
||||
"example": "/syncthing",
|
||||
"default": "/syncthing"
|
||||
},
|
||||
{
|
||||
"name": "user",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the user for Syncthing (must be an existing yunohost user)",
|
||||
"fr": "Choisissez l'utilisateur de Syncthing (doit être un utilisateur yunohost existant)"
|
||||
},
|
||||
"example": "johndoe"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"ask": {
|
||||
"en": "Choose Syncthing channel ?",
|
||||
"fr": "Choissez la version de Syncthing ?"
|
||||
},
|
||||
"choices": ["stable", "candidate"],
|
||||
"default": "stable"
|
||||
}
|
||||
]
|
||||
}
|
||||
"name": "Syncthing",
|
||||
"id": "syncthing",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized.",
|
||||
"fr": "Syncthing remplace les services propriétaires de synchro et de cloud avec quelque chose d'ouvert, digne de confiance et décentralisée."
|
||||
},
|
||||
"version": "1.1.1~ynh1",
|
||||
"url": "https://syncthing.net/",
|
||||
"license": "MPL-2.0",
|
||||
"maintainer": {
|
||||
"name": "txmrl",
|
||||
"email": "txmrl@txmrl.net"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.5"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
"nginx"
|
||||
],
|
||||
"arguments": {
|
||||
"install": [
|
||||
{
|
||||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for Syncthing"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for Syncthing"
|
||||
},
|
||||
"example": "/syncthing",
|
||||
"default": "/syncthing"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the user for Syncthing (must be an existing yunohost user)",
|
||||
"fr": "Choisissez l'utilisateur de Syncthing (doit être un utilisateur yunohost existant)"
|
||||
},
|
||||
"example": "johndoe"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
23
pull_request_template.md
Normal file
23
pull_request_template.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
## Problem
|
||||
- *Description of why you made this PR*
|
||||
|
||||
## Solution
|
||||
- *And how do you fix that problem*
|
||||
|
||||
## PR Status
|
||||
- [ ] Code finished.
|
||||
- [ ] Tested with Package_check.
|
||||
- [ ] Fix or enhancement tested.
|
||||
- [ ] Upgrade from last version tested.
|
||||
- [ ] Can be reviewed and tested.
|
||||
|
||||
## Validation
|
||||
---
|
||||
- [ ] **Code review**
|
||||
- [ ] **Approval (LGTM)**
|
||||
*Code review and approval have to be from a member of @YunoHost/apps group*
|
||||
- **CI succeeded** :
|
||||
[](https://ci-apps-dev.yunohost.org/jenkins/job/syncthing_ynh%20-BRANCH-/)
|
||||
*Please replace '-BRANCH-' in this link by the name of the branch used.*
|
||||
*If the PR is from a forked repository. Please provide public results from package_check.*
|
||||
When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.
|
20
scripts/_common.sh
Normal file
20
scripts/_common.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies=""
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# 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 /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the main app directory..."
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up systemd configuration..."
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
117
scripts/change_url
Normal file
117
scripts/change_url
Normal file
|
@ -0,0 +1,117 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# 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)
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Stopping a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_print_info --message="Updating nginx web server configuration..."
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Change of URL completed for $app"
|
245
scripts/install
245
scripts/install
|
@ -1,96 +1,187 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Configurable variables
|
||||
SYNCHOME="/home/yunohost.app/syncthing"
|
||||
SYNCUSER=debian-syncthing
|
||||
SYNCPORT=22000
|
||||
GUIPORT=8384
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
user=$3
|
||||
channel=$4
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Check Debian version
|
||||
if [[ $(cat /etc/debian_version) < 8 ]]
|
||||
then
|
||||
echo "You need debian Jessie (8.x) or more to install syncthing_ynh."
|
||||
exit 1
|
||||
fi
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Check that admin user is an existing account
|
||||
sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" \
|
||||
|| (echo "Error: the chosen admin user does not exist" && exit 1)
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a syncthing
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
echo $domain$path is not available. Please choose another url for Syncthing.
|
||||
exit 1
|
||||
fi
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
path=${path%/}
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path_url=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
|
||||
# Check port availability
|
||||
sudo yunohost app checkport $GUIPORT
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
echo Port $GUIPORT for Syncthing UI is not available.
|
||||
exit 1
|
||||
fi
|
||||
sudo yunohost app checkport $SYNCPORT
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
echo Port $SYNCPORT is for Syncthing protocol is not available.
|
||||
exit 1
|
||||
fi
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Open port in firewall
|
||||
sudo yunohost firewall allow TCP $SYNCPORT > /dev/null 2>&1
|
||||
# Configure sync folder
|
||||
sync_home="/home/yunohost.app/$app"
|
||||
|
||||
# Create $SYNCUSER user to run syncthing service
|
||||
sudo useradd -m -d $SYNCHOME/ -s /bin/bash $SYNCUSER
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Validating installation parameters..."
|
||||
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info --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
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring firewall..."
|
||||
|
||||
gui_port=$(ynh_find_port --port=8384)
|
||||
ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port
|
||||
|
||||
sync_port=$(ynh_find_port --port=22000)
|
||||
# Open this port
|
||||
ynh_exec_warn_less yunohost firewall allow TCP $sync_port
|
||||
ynh_app_setting_set --app=$app --key=sync_port --value=$sync_port
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info --message="Setting up source files..."
|
||||
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config "gui_port"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# CREATE SYNC DIRECTORY
|
||||
#=================================================
|
||||
ynh_print_info --message="Creating sync directory..."
|
||||
|
||||
# Make directories and set rights
|
||||
sudo chown -R $SYNCUSER:$SYNCUSER $SYNCHOME/
|
||||
sudo find $SYNCHOME/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
||||
sudo find $SYNCHOME/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
||||
mkdir -p "$sync_home"
|
||||
chown -R "$app": "$sync_home"
|
||||
|
||||
# Download and install syncthing binary
|
||||
sudo apt-get install curl
|
||||
## Add the release PGP keys:
|
||||
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
|
||||
## Add the choosed channel to your APT sources:
|
||||
echo "deb http://apt.syncthing.net/ syncthing $channel" | sudo tee /etc/apt/sources.list.d/syncthing.list
|
||||
## Update and install syncthing:
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install syncthing -y --force-yes
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring a systemd service..."
|
||||
|
||||
# Install and monitor service
|
||||
sudo sed -i '/^\[Service\]$/,/^\[/ s/^Restart=on-failure/Restart=always/' /lib/systemd/system/syncthing@.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable syncthing@$SYNCUSER.service
|
||||
sudo yunohost service add syncthing@$SYNCUSER -l /var/log/syncthing.log
|
||||
sudo systemctl start syncthing@$SYNCUSER.service
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
# Configure logrotate if present
|
||||
if [ -d "/etc/logrotate.d" ]; then
|
||||
sed -i "s@SYNCUSER@$SYNCUSER@g" ../conf/logrotate.conf
|
||||
sudo cp ../conf/logrotate.conf /etc/logrotate.d/syncthing
|
||||
sudo chmod 0644 /etc/logrotate.d/syncthing
|
||||
fi
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_print_info --message="Modifying a config file..."
|
||||
|
||||
# Configure Nginx
|
||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf
|
||||
mkdir -p "$final_path/.config/syncthing"
|
||||
config_file="$final_path/.config/syncthing/config.xml"
|
||||
cp "../conf/config.xml" "$config_file"
|
||||
|
||||
# Remove acces to all users
|
||||
sudo yunohost app removeaccess syncthing
|
||||
sudo yunohost app addaccess syncthing -u $user
|
||||
ynh_replace_string --match_string="__GUI_PORT__" --replace_string="$gui_port" --target_file="$config_file"
|
||||
ynh_replace_string --match_string="__SYNC_HOME__" --replace_string="$sync_home" --target_file="$config_file"
|
||||
|
||||
# Reload nginx and update ssowatch
|
||||
sudo systemctl reload nginx.service
|
||||
sudo yunohost app ssowatconf
|
||||
#=================================================
|
||||
# FIX LISTENING SERVICE
|
||||
#=================================================
|
||||
|
||||
echo $?
|
||||
chown -R $app: $final_path
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL"
|
||||
|
||||
ynh_replace_string --match_string="<listenAddress>tcp://default</listenAddress>" --replace_string="<listenAddress>default</listenAddress>" --target_file="$config_file"
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
ynh_store_file_checksum --file="$config_file"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions to app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
yunohost service add $app --description "$app daemon for Syncthing"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL"
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring SSOwat..."
|
||||
|
||||
# Make app public
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Installation of $app completed"
|
||||
|
|
100
scripts/remove
100
scripts/remove
|
@ -1,43 +1,83 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Configurable variables
|
||||
SYNCHOME="/home/yunohost.app/syncthing"
|
||||
SYNCUSER=debian-syncthing
|
||||
SYNCPORT=22000
|
||||
GUIPORT=8384
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Stop and remove syncthing service
|
||||
sudo systemctl stop syncthing@$SYNCUSER.service
|
||||
sudo yunohost service remove syncthing
|
||||
sudo systemctl disable syncthing@$SYNCUSER.service
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Remove syncthing binairy
|
||||
sudo apt-get autoremove syncthing -y --purge
|
||||
sudo rm /etc/apt/sources.list.d/syncthing.list
|
||||
sudo apt-get update -qq
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
# Backup syncthing SYNCHOME directory
|
||||
sudo mv $SYNCHOME $SYNCHOME.old
|
||||
# sudo rm -rf $SYNCHOME
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Remove syncthing user
|
||||
sudo userdel $SYNCUSER
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
# Close port in firewall
|
||||
sudo yunohost firewall disallow TCP $SYNCPORT
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
# Remove syncthing logrotate configuration
|
||||
if [ -f /etc/logrotate.d/syncthing ]
|
||||
sync_port=$(ynh_app_setting_get --app=$app --key=sync_port)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# REMOVE SERVICE FROM ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
# Remove a service from the admin panel, added by `yunohost service add`
|
||||
if yunohost service status $app >/dev/null 2>&1
|
||||
then
|
||||
sudo rm /etc/logrotate.d/syncthing
|
||||
ynh_print_info --message="Removing $app service..."
|
||||
yunohost service remove $app
|
||||
fi
|
||||
|
||||
# Remove syncthing nginx configuration
|
||||
domain=$(sudo yunohost app setting syncthing domain)
|
||||
sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Stopping and removing the systemd service..."
|
||||
|
||||
# Reload nginx and update ssowatch
|
||||
sudo systemctl reload nginx.service
|
||||
sudo yunohost app ssowatconf
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
||||
echo $?
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing app main directory..."
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing nginx web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Closing port $sync_port"
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $sync_port
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Removal of $app completed"
|
||||
|
|
120
scripts/restore
120
scripts/restore
|
@ -0,0 +1,120 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# 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 /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading settings..."
|
||||
|
||||
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)
|
||||
sync_home=$(ynh_app_setting_get --app=$app --key=sync_home)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
#=================================================
|
||||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info --message="Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R "$app": $final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# RECREATE SYNC DIRECTORY
|
||||
#=================================================
|
||||
ynh_print_info --message="Recreating sync directory..."
|
||||
|
||||
# Make directories and set rights
|
||||
mkdir -p "$sync_home"
|
||||
chown -R "$app": "$sync_home"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Restoring the systemd configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
|
||||
yunohost service add $app --description "$app daemon for Syncthing"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Restoration completed for $app"
|
213
scripts/upgrade
213
scripts/upgrade
|
@ -1,29 +1,200 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Configurable variables
|
||||
SYNCHOME="/home/yunohost.app/syncthing"
|
||||
SYNCUSER=debian-syncthing
|
||||
SYNCPORT=22000
|
||||
GUIPORT=8384
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$(sudo yunohost app setting syncthing domain)
|
||||
path=$(sudo yunohost app setting syncthing path)
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
path=${path%/}
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
# Upgrade official debian package
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get upgrade syncthing -y
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Update Nginx configuration
|
||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||
sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
|
||||
# And reload
|
||||
sudo service nginx reload
|
||||
sudo yunohost app ssowatconf
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
echo $?
|
||||
sync_home=$(ynh_app_setting_get --app=$app --key=sync_home)
|
||||
sync_port=$(ynh_app_setting_get --app=$app --key=sync_port)
|
||||
gui_port=$(ynh_app_setting_get --app=$app --key=gui_port)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info --message="Ensuring downward compatibility..."
|
||||
|
||||
# If gui_port doesn't exist, create it
|
||||
if [ -z $gui_port ]; then
|
||||
|
||||
OLD_SYNCHOME="/home/yunohost.app/syncthing"
|
||||
OLD_SYNCUSER=debian-syncthing
|
||||
OLD_SYNCPORT=22000
|
||||
OLD_GUIPORT=8384
|
||||
OLD_CONFIG="$OLD_SYNCHOME/.config/syncthing/config.xml"
|
||||
|
||||
admin=$(ynh_app_setting_get $app allowed_users)
|
||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||
ynh_app_setting_delete --app="$app" --key="allowed_users"
|
||||
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
|
||||
gui_port=$OLD_GUIPORT
|
||||
ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port
|
||||
|
||||
sync_home="/home/yunohost.app/$app"
|
||||
ynh_app_setting_set --app=$app --key=sync_home --value=$sync_home
|
||||
|
||||
sync_port=$OLD_SYNCPORT
|
||||
ynh_app_setting_set --app=$app --key=sync_port --value=$sync_port
|
||||
|
||||
mkdir -p $final_path
|
||||
cp -R $OLD_SYNCHOME/.config $final_path/.config
|
||||
|
||||
ynh_replace_string "~" "$sync_home" "$final_path/.config/syncthing/config.xml"
|
||||
|
||||
systemctl stop syncthing@$OLD_SYNCUSER.service
|
||||
yunohost service remove syncthing@$OLD_SYNCUSER.service
|
||||
systemctl disable syncthing@$OLD_SYNCUSER.service
|
||||
|
||||
ynh_secure_remove --file="/etc/apt/sources.list.d/syncthing.list"
|
||||
|
||||
ynh_system_user_delete --username="$SYNCUSER"
|
||||
|
||||
ynh_remove_logrotate
|
||||
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
else
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info --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 () {
|
||||
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_print_info --message="Stopping Syncthing services..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd
|
||||
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_print_info --message="Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading nginx web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config "gui_port"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# CREATE SYNC DIRECTORY
|
||||
#=================================================
|
||||
ynh_print_info --message="Creating sync directory..."
|
||||
|
||||
# Make directories and set rights
|
||||
mkdir -p "$sync_home"
|
||||
chown -R "$app": "$sync_home"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading systemd configuration..."
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info --message="Upgrading SSOwat configuration..."
|
||||
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Starting a systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue