diff --git a/TODO b/TODO new file mode 100644 index 0000000..15c41ed --- /dev/null +++ b/TODO @@ -0,0 +1,16 @@ +- finir les scripts: install, remove, upgrade + - on crée un utilisateur spécifique pour lancer l'exécutable: syncthingd + - le dossier sera /home/yunohost.syncthing/ est le $HOME du user syncthingd + - le dossier sera /home/yunohost.syncthing/bin pour le binaire + - le dossier sera /home/yunohost.syncthing/sync pour créer des dossiers de synchro (à revoir à l'usage) +ces dossiers appartiennent à syncthingd + +- écrire le script pour le service syncthing + + +wget https://github.com/syncthing/syncthing/releases/download/v$version/syncthing-linux-amd64-v$version.tar.gz + +tar xvf syncthing-linux-amd64-v$version.tar.gz + + +cd syncthing-linux-amd64-v$version diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..3f01d4d --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,19 @@ +location PATHTOCHANGE/syncthing { + proxy_pass http://127.0.0.1:8080PATHTOCHANGE/syncthing; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; + more_clear_input_headers 'Accept-Encoding'; +} +location PATHTOCHANGE/ { + proxy_pass http://127.0.0.1:8080/; +} +location PATHTOCHANGE/downloads { + alias /home/yunohost.syncthing/completed/; + autoindex on; + autoindex_exact_size off; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; + more_clear_input_headers 'Accept-Encoding'; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..be75aac --- /dev/null +++ b/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "Syncthing", + "id": "syncthing", + "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/", + "maintainer": { + "name": "txmrl", + "email": "txmrl@txmrl.net" + }, + "multi_instance": "false", + "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" + } + ] + } +} diff --git a/scripts/install b/scripts/install new file mode 100644 index 0000000..4ea7020 --- /dev/null +++ b/scripts/install @@ -0,0 +1,51 @@ +#!/bin/bash + +# Retrieve arguments +domain=$1 +path=$2 + +version="0.10.29" + +sudo yunohost app checkurl $domain$path -a syncthing +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Remove trailing "/" for next commands +path=${path%/} + +# Check port availability +sudo yunohost app checkport 8080 +if [[ ! $? -eq 0 ]]; then + exit 1 +fi +sudo yunohost app checkport 22000 +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Open port in firewall +sudo yunohost firewall allow TCP 22000 > /dev/null 2>&1 + +# Make directories and set rights +#~ sudo mkdir -p /home/yunohost.syncthing/{bin,sync} +#~ sudo chown -R debian-syncthing:www-data /home/yunohost.syncthing/ +#~ sudo chown -R debian-syncthing:debian-syncthing /home/yunohost.syncthing/progress +#~ sudo find /home/yunohost.syncthing/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done +#~ sudo find /home/yunohost.syncthing/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done + + +# Install official debian package +## Ici il faut ajouter le code pour télécharger l'archive depuis le github de syncthing +## créer un utilisateur pour lancer syncthing +#~ sudo apt-get install syncthing-daemon -y -qq + + +# Monitor service +#~ sudo yunohost service add syncthing-daemon + +# Configure Nginx and reload +sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf +sudo service nginx reload +echo $? diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..6b31bcc --- /dev/null +++ b/scripts/remove @@ -0,0 +1,14 @@ +#!/bin/bash + +sudo service syncthing-daemon stop +sudo yunohost firewall disallow TCP 22000 +sudo yunohost service remove syncthing-daemon +domain=$(sudo yunohost app setting syncthing domain) + +sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf +sudo rm -rf /home/yunohost.syncthing + +sudo apt-get remove -y -qq syncthing-daemon + +sudo service nginx reload +sudo yunohost app ssowatconf diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..00d794d --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,26 @@ +#!/bin/bash + +# Retrieve arguments +domain=$(sudo yunohost app setting syncthing domain) +path=$(sudo yunohost app setting syncthing path) + +# Remove trailing "/" for next commands +path=${path%/} + +# Open port in firewall +sudo yunohost firewall allow TCP 22000 > /dev/null 2>&1 + +# Upgrade official debian package +sudo apt-get install syncthing-daemon -y -qq + +# Make directories and set rights +sudo mkdir -p /home/yunohost.syncthing//{bin,sync} +sudo chown -R debian-syncthing:www-data /home/yunohost.syncthing/ +sudo chown -R debian-syncthing:debian-syncthing /home/yunohost.syncthing/progress +sudo find /home/yunohost.syncthing/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done +sudo find /home/yunohost.syncthing/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done + +# Configure Nginx and reload +sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf +sudo service nginx reload diff --git a/sources/toolbar-downloads.png b/sources/toolbar-downloads.png new file mode 100644 index 0000000..e60479f Binary files /dev/null and b/sources/toolbar-downloads.png differ diff --git a/sources/ynh_common.css b/sources/ynh_common.css new file mode 100644 index 0000000..ebcf246 --- /dev/null +++ b/sources/ynh_common.css @@ -0,0 +1,9 @@ + + /* Inserted by Yunohost install script */ + div#toolbar > * { + background-position: center center; + background-repeat: no-repeat; + } + div#toolbar > #toolbar-downloads { + background-image: url("images/toolbar-downloads.png"); + } diff --git a/syncthing.man b/syncthing.man new file mode 100644 index 0000000..851abb8 --- /dev/null +++ b/syncthing.man @@ -0,0 +1,78 @@ +Usage: + syncthing [options] + +Options: + -generate="" Generate key and config in specified dir, then exit + -gui-address="" Override GUI address + -gui-apikey="" Override GUI API key + -gui-authentication="" Override GUI authentication; username:password + -home="" Set configuration directory + -logflags="2" Select information in log line prefix + -no-browser Do not start browser + -no-restart Do not restart; just exit + -reset Prepare to resync from cluster + -upgrade Perform upgrade + -upgrade-check Check for available upgrade + -upgrade-to="" Force upgrade directly from specified URL + -version Show version + + +The default configuration directory is: + + /home/lahire/.config/syncthing + + +The -logflags value is a sum of the following: + + 1 Date + 2 Time + 4 Microsecond time + 8 Long filename + 16 Short filename + +I.e. to prefix each log line with date and time, set -logflags=3 (1 + 2 from +above). The value 0 is used to disable all of the above. The default is to +show time only (2). + + +Development Settings +-------------------- + +The following environment variables modify syncthing's behavior in ways that +are mostly useful for developers. Use with care. + + STGUIASSETS Directory to load GUI assets from. Overrides compiled in assets. + + STTRACE A comma separated string of facilities to trace. The valid + facility strings are: + + - "beacon" (the beacon package) + - "discover" (the discover package) + - "events" (the events package) + - "files" (the files package) + - "net" (the main package; connections & network messages) + - "model" (the model package) + - "scanner" (the scanner package) + - "stats" (the stats package) + - "upnp" (the upnp package) + - "xdr" (the xdr package) + - "all" (all of the above) + + STPROFILER Set to a listen address such as "127.0.0.1:9090" to start the + profiler with HTTP access. + + STCPUPROFILE Write a CPU profile to cpu-$pid.pprof on exit. + + STHEAPPROFILE Write heap profiles to heap-$pid-$timestamp.pprof each time + heap usage increases. + + STBLOCKPROFILE Write block profiles to block-$pid-$timestamp.pprof every 20 + seconds. + + STPERFSTATS Write running performance statistics to perf-$pid.csv. Not + supported on Windows. + + STNOUPGRADE Disable automatic upgrades. + + GOMAXPROCS Set the maximum number of CPU cores to use. Defaults to all + available CPU cores.