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

Apply last example_ynh

This commit is contained in:
yalh76 2022-03-24 00:32:11 +01:00
parent 478404afc5
commit 11bcf20f19
24 changed files with 1042 additions and 688 deletions

55
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,55 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install the_app
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

View file

@ -1,4 +1,4 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.} <one line to give the program's name and a brief idea of what it does.>
Copyright (C) {year} {name of author} Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode: notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname} <program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. under certain conditions; type `show c' for details.

View file

@ -1,39 +0,0 @@
# Headphones pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/headphones.svg)](https://dash.yunohost.org/appci/app/headphones) ![](https://ci-apps.yunohost.org/ci/badges/headphones.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/headphones.maintain.svg)
[![Installer Headphones avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=headphones)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Headphones rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
Automated music downloader for NZB and Torrent
**Version incluse :** 0.6.0~ynh1
## Documentations et ressources
* Site officiel de l'app : https://github.com/rembo10/headphones
* Documentation officielle utilisateur : https://github.com/rembo10/headphones/wiki/Usage-guide
* Dépôt de code officiel de l'app : https://github.com/rembo10/headphones
* Documentation YunoHost pour cette app : https://yunohost.org/app_headphones
* Signaler un bug : https://github.com/YunoHost-Apps/headphones_ynh/issues
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/headphones_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/headphones_ynh/tree/testing --debug
ou
sudo yunohost app upgrade headphones -u https://github.com/YunoHost-Apps/headphones_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

21
check_process Normal file
View file

@ -0,0 +1,21 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none

View file

@ -1,233 +0,0 @@
[General]
config_version = 5
http_port = PORTTOCHANGE
http_host = 0.0.0.0
http_username = ""
http_password = ""
http_root = PATHTOCHANGE
http_proxy = 0
enable_https = 0
https_cert = ""
https_key = ""
launch_browser = 1
api_enabled = 0
api_key = ""
log_dir = LOGSDIRTOCHANGE
cache_dir = APPDIRTOCHANGE/cache
git_path = ""
git_user = rembo10
git_branch = master
do_not_override_git_branch = 0
check_github = 1
check_github_on_startup = 1
check_github_interval = 360
music_dir = ""
destination_dir = ""
lossless_destination_dir = ""
preferred_quality = 0
preferred_bitrate = ""
preferred_bitrate_high_buffer = ""
preferred_bitrate_low_buffer = ""
preferred_bitrate_allow_lossless = 0
detect_bitrate = 0
lossless_bitrate_from = ""
lossless_bitrate_to = ""
auto_add_artists = 1
correct_metadata = 0
move_files = 0
rename_files = 0
folder_format = $Artist/$Album [$Year]
file_format = $Track $Artist - $Album [$Year] - $Title
file_underscores = 0
cleanup_files = 0
keep_nfo = 0
add_album_art = 0
album_art_format = folder
embed_album_art = 0
embed_lyrics = 0
replace_existing_folders = 0
nzb_downloader = 0
torrent_downloader = 0
download_dir = ""
blackhole_dir = ""
usenet_retention = 1500
include_extras = 0
extras = ""
autowant_upcoming = 1
autowant_all = 0
keep_torrent_files = 0
prefer_torrents = 0
open_magnet_links = False
numberofseeders = 10
torrentblackhole_dir = ""
download_torrent_dir = ""
search_interval = 1440
libraryscan = 1
libraryscan_interval = 300
download_scan_interval = 5
update_db_interval = 24
mb_ignore_age = 365
preferred_words = ""
ignored_words = ""
required_words = ""
lastfm_username = ""
interface = default
folder_permissions = 0755
file_permissions = 0644
music_encoder = 0
encoder = ffmpeg
xldprofile = ""
bitrate = 192
samplingfrequency = 44100
encoder_path = ""
advancedencoder = ""
encoderoutputformat = mp3
encoderquality = 2
encodervbrcbr = cbr
encoderlossless = 1
encoder_multicore = 0
encoder_multicore_count = 0
delete_lossless_files = 1
mirror = musicbrainz.org
customhost = localhost
customport = 5000
customsleep = 1
hpuser = ""
hppass = ""
[Kat]
kat = 0
kat_proxy_url = ""
kat_ratio = ""
[Mininova]
mininova = 0
mininova_ratio = ""
[Piratebay]
piratebay = 0
piratebay_proxy_url = ""
piratebay_ratio = ""
[Waffles]
waffles = 0
waffles_uid = ""
waffles_passkey = ""
waffles_ratio = ""
[Rutracker]
rutracker = 0
rutracker_user = ""
rutracker_password = ""
rutracker_ratio = ""
[What.cd]
whatcd = 0
whatcd_username = ""
whatcd_password = ""
whatcd_ratio = ""
[SABnzbd]
sab_host = ""
sab_username = ""
sab_password = ""
sab_apikey = ""
sab_category = ""
[NZBget]
nzbget_username = nzbget
nzbget_password = ""
nzbget_category = ""
nzbget_host = ""
nzbget_priority = 0
[Headphones]
headphones_indexer = 0
[Transmission]
transmission_host = ""
transmission_username = ""
transmission_password = ""
[uTorrent]
utorrent_host = ""
utorrent_username = ""
utorrent_password = ""
utorrent_label = ""
[Newznab]
newznab = 0
newznab_host = ""
newznab_apikey = ""
newznab_enabled = 1
extra_newznabs = ,
[NZBsorg]
nzbsorg = 0
nzbsorg_uid = ""
nzbsorg_hash = ""
[omgwtfnzbs]
omgwtfnzbs = 0
omgwtfnzbs_uid = ""
omgwtfnzbs_apikey = ""
[Growl]
growl_enabled = 0
growl_host = ""
growl_password = ""
growl_onsnatch = 0
[Prowl]
prowl_enabled = 0
prowl_keys = ""
prowl_onsnatch = 0
prowl_priority = 0
[XBMC]
xbmc_enabled = 0
xbmc_host = ""
xbmc_username = ""
xbmc_password = ""
xbmc_update = 0
xbmc_notify = 0
[LMS]
lms_enabled = 0
lms_host = ""
[Plex]
plex_enabled = 0
plex_server_host = ""
plex_client_host = ""
plex_username = ""
plex_password = ""
plex_update = 0
plex_notify = 0
[NMA]
nma_enabled = 0
nma_apikey = ""
nma_priority = 0
nma_onsnatch = 0
[Pushalot]
pushalot_enabled = 0
pushalot_apikey = ""
pushalot_onsnatch = 0
[Pushover]
pushover_enabled = 0
pushover_keys = ""
pushover_onsnatch = 0
pushover_priority = 0
pushover_apitoken = ""
[PushBullet]
pushbullet_enabled = 0
pushbullet_apikey = ""
pushbullet_deviceid = ""
pushbullet_onsnatch = 0
[Twitter]
twitter_enabled = 0
twitter_onsnatch = 0
twitter_username = ""
twitter_password = ""
twitter_prefix = Headphones
[OSX_Notify]
osx_notify_enabled = 0
osx_notify_onsnatch = 0
osx_notify_app = /Applications/Headphones
[Boxcar]
boxcar_enabled = 0
boxcar_onsnatch = 0
boxcar_token = ""
[Songkick]
songkick_enabled = 1
songkick_apikey = nd1We7dFW2RqxPw8
songkick_location = ""
songkick_filter_enabled = 0
[Synoindex]
synoindex_enabled = 0
[Advanced]
album_completion_pct = 80
cache_sizemb = 32
journal_mode = wal
verify_ssl_cert = 1

View file

@ -1,15 +0,0 @@
# COPY THIS FILE TO /etc/default/headphones
# OPTIONS: HP_HOME, HP_USER, HP_DATA, HP_PIDFILE, PYTHON_BIN, HP_OPTS, SSD_OPTS, HP_PORT
## EXAMPLE if want to run as different user
## add HP_USER=username to /etc/default/headphones
## otherwise default headphones is used
HP_USER=__APP__ #$RUN_AS, username to run headphones under, the default is headphones
HP_HOME=__FINALPATH__ #$APP_PATH, the location of Headphones.py, the default is /opt/headphones
HP_DATA=__DATADIR__ #$DATA_DIR, the location of headphones.db, cache, logs, the default is /opt/headphones
#HP_PIDFILE=PIDFILETOCHANGE #$PID_FILE, the location of headphones.pid, the default is /var/run/headphones/headphones.pid
#PYTHON_BIN=/usr/bin/python3 #$DAEMON, the location of the python binary, the default is /usr/bin/python
#HP_OPTS=" --config=OPTSTOCHANGE" #$EXTRA_DAEMON_OPTS, extra cli option for headphones, i.e. " --config=/home/headphones/config.ini"
#SSD_OPTS=SSDTOCHANGE #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
HP_PORT=__PORT__ #$PORT_OPTS, hardcoded port for the webserver, overrides value in config.ini

360
conf/headphones.ini Normal file
View file

@ -0,0 +1,360 @@
[General]
add_album_art = 0
advancedencoder =
album_art_format = folder
album_art_min_width =
album_art_max_width =
api_enabled = 0
api_key =
autowant_all = 0
autowant_manually_added = 1
autowant_upcoming = 1
auto_add_artists = 1
bitrate = 192
blackhole = 0
blackhole_dir =
cache_dir = __DATADIR__/cache
check_github = 0
check_github_interval = 360
check_github_on_startup = 0
cleanup_files = 0
config_version = 6
correct_metadata = 0
cue_split = 1
cue_split_flac_path =
cue_split_shntool_path =
customauth = 0
customhost = localhost
custompass =
customport = 5000
customsleep = 1
customuser =
delete_lossless_files = 1
destination_dir =
detect_bitrate = 0
do_not_process_unmatched = 0
download_dir =
download_scan_interval = 5
download_torrent_dir =
do_not_override_git_branch = 0
embed_album_art = 0
embed_lyrics = 0
enable_https = 0
encoder = ffmpeg
encoderfolder =
encoderlossless = 1
encoderoutputformat = mp3
encoderquality = 2
encodervbrcbr = cbr
encoder_multicore = 0
encoder_multicore_count = 0
encoder_path =
extras =
file_format = $Track $Artist - $Album [$Year] - $Title
file_permissions = 0644
file_permissions_enabled = True
file_underscores = 0
folder_format = $Artist/$Album [$Year]
folder_permissions_enabled = True
folder_permissions = 0755
freeze_db = 0
git_branch = master
git_path =
git_user = rembo10
headphones_indexer = 0
hppass =
hpuser =
https_cert =
https_key =
http_host = localhost
http_password =
http_port = __PORT__
http_proxy = 0
http_root = __PATH_URL__
http_username =
ignore_clean_releases = 0
ignored_words =
include_extras = 0
interface = default
keep_nfo = 0
keep_torrent_files = 0
keep_torrent_files_dir =
lastfm_username =
launch_browser = 1
libraryscan = 1
libraryscan_interval = 24
log_dir = /var/log/__APP__
lossless_bitrate_from = 0
lossless_bitrate_to = 0
lossless_destination_dir =
mb_ignore_age = 365
mb_ignore_age_missing = 0
mirror = musicbrainz.org
move_files = 0
music_dir =
music_encoder = 0
numberofseeders = 10
nzb_downloader = 0
official_releases_only = 0
open_magnet_links = 0
magnet_links = 0
preferred_bitrate =
preferred_bitrate_allow_lossless = 0
preferred_bitrate_high_buffer = 0
preferred_bitrate_low_buffer = 0
preferred_quality = 0
preferred_words =
prefer_torrents = 0
rename_files = 0
rename_single_disc_ignore = 0
rename_unprocessed = 1
rename_frozen = 1
replace_existing_folders = 0
keep_original_folder = 0
required_words =
samplingfrequency = 44100
search_interval = 1440
soft_chroot =
torrentblackhole_dir =
torrent_downloader = 0
torrent_removal_interval = 720
update_db_interval = 24
usenet_retention = 1500
wait_until_release_date = 0
xldprofile =
[Advanced]
album_completion_pct = 80
cache_sizemb = 32
ignored_folders = []
ignored_files = []
journal_mode = wal
verify_ssl_cert = 1
[Orpheus.network]
orpheus = 0
orpheus_password =
orpheus_ratio =
orpheus_username =
orpheus_url = https://orpheus.network
[Boxcar]
boxcar_enabled = 0
boxcar_onsnatch = 0
boxcar_token =
[Deluge]
deluge_host =
deluge_cert =
deluge_password =
deluge_label =
deluge_done_directory =
deluge_paused = 0
[Email]
email_enabled = 0
email_from =
email_to =
email_smtp_server = localhost
email_smtp_user =
email_smtp_password =
email_smtp_port = 25
email_ssl = 0
email_tls = 0
email_onsnatch = 0
[Newznab]
extra_newznabs = []
newznab = 0
newznab_apikey =
newznab_enabled = 1
newznab_host =
[Torznab]
extra_torznabs = []
torznab = 0
torznab_apikey =
torznab_enabled = 1
torznab_host =
torznab_ratio =
[Growl]
growl_enabled = 0
growl_host =
growl_onsnatch = 0
growl_password =
[Beets]
idtag = 0
[Join]
join_apikey =
join_deviceid =
join_enabled = 0
join_onsnatch = 0
[LMS]
lms_enabled = 0
lms_host =
[MPC]
mpc_enabled = 0
[NMA]
nma_apikey =
nma_enabled = 0
nma_onsnatch = 0
nma_priority = 0
[NZBget]
nzbget_category =
nzbget_host =
nzbget_password =
nzbget_priority = 0
nzbget_username = nzbget
[NZBsorg]
nzbsorg = 0
nzbsorg_hash =
nzbsorg_uid =
[omgwtfnzbs]
omgwtfnzbs = 0
omgwtfnzbs_apikey =
omgwtfnzbs_uid =
[OSX_Notify]
osx_notify_app = /Applications/Headphones
osx_notify_enabled = 0
osx_notify_onsnatch = 0
[Piratebay]
piratebay = 0
piratebay_proxy_url =
piratebay_ratio =
[Old Piratebay]
oldpiratebay = 0
oldpiratebay_url =
oldpiratebay_ratio =
[Plex]
plex_client_host =
plex_enabled = 0
plex_notify = 0
plex_password =
plex_server_host =
plex_update = 0
plex_username =
plex_token =
[Prowl]
prowl_enabled = 0
prowl_keys =
prowl_onsnatch = 0
prowl_priority = 0
[Pushalot]
pushalot_apikey =
pushalot_enabled = 0
pushalot_onsnatch = 0
[PushBullet]
pushbullet_apikey =
pushbullet_deviceid =
pushbullet_enabled = 0
pushbullet_onsnatch = 0
[Pushover]
pushover_apitoken =
pushover_enabled = 0
pushover_keys =
pushover_onsnatch = 0
pushover_priority = 0
[QBitTorrent]
qbittorrent_host =
qbittorrent_label =
qbittorrent_password =
qbittorrent_username =
[Rutracker]
rutracker = 0
rutracker_password =
rutracker_ratio =
rutracker_user =
rutracker_cookie =
[SABnzbd]
sab_apikey =
sab_category =
sab_host =
sab_password =
sab_username =
[Slack]
slack_enabled = 0
slack_url =
slack_channel =
slack_emoji =
slack_onsnatch = 0
[Songkick]
songkick_apikey = nd1We7dFW2RqxPw8
songkick_enabled = 1
songkick_filter_enabled = 0
songkick_location =
[Subsonic]
subsonic_enabled = 0
subsonic_host =
subsonic_password =
subsonic_username =
[Synoindex]
synoindex_enabled = 0
[Telegram]
telegram_token =
telegram_userid =
telegram_enabled = 0
telegram_onsnatch = 0
[Transmission]
transmission_host =
transmission_password =
transmission_username =
[Twitter]
twitter_enabled = 0
twitter_onsnatch = 0
twitter_password =
twitter_prefix = Headphones
twitter_username =
[uTorrent]
utorrent_host =
utorrent_label =
utorrent_password =
utorrent_username =
[Waffles]
waffles = 0
waffles_passkey =
waffles_ratio =
waffles_uid =
[Redacted]
redacted = 0
redacted_username =
redacted_password =
redacted_ratio =
redacted_use_fltoken = 0
[XBMC]
xbmc_enabled = 0
xbmc_host =
xbmc_notify = 0
xbmc_password =
xbmc_update = 0
xbmc_username =

View file

@ -1,209 +0,0 @@
#!/bin/sh
#
## Don't edit this file
## Edit user configuation in /etc/default/headphones to change
##
## Make sure init script is executable
## sudo chmod +x /path/to/init.ubuntu
##
## Install the init script
## sudo ln -s /path/to/init.ubuntu /etc/init.d/headphones
##
## Create the headphones daemon user:
## sudo adduser --system --no-create-home headphones
##
## Make sure /opt/headphones is owned by the headphones user
## sudo chown headphones:nogroup -R /opt/headphones
##
## Touch the default file to stop the warning message when starting
## sudo touch /etc/default/headphones
##
## To start Headphones automatically
## sudo update-rc.d headphones defaults
##
## To start/stop/restart Headphones
## sudo service headphones start
## sudo service headphones stop
## sudo service headphones restart
##
## HP_USER= #$RUN_AS, username to run headphones under, the default is headphones
## HP_HOME= #$APP_PATH, the location of Headphones.py, the default is /opt/headphones
## HP_DATA= #$DATA_DIR, the location of headphones.db, cache, logs, the default is /opt/headphones
## HP_PIDFILE= #$PID_FILE, the location of headphones.pid, the default is /var/run/headphones/headphones.pid
## PYTHON_BIN= #$DAEMON, the location of the python binary, the default is /usr/bin/python
## HP_OPTS= #$EXTRA_DAEMON_OPTS, extra cli option for headphones, i.e. " --config=/home/headphones/config.ini"
## SSD_OPTS= #$EXTRA_SSD_OPTS, extra start-stop-daemon option like " --group=users"
## HP_PORT= #$PORT_OPTS, hardcoded port for the webserver, overrides value in config.ini
##
## EXAMPLE if want to run as different user
## add HP_USER=username to /etc/default/headphones
## otherwise default headphones is used
#
### BEGIN INIT INFO
# Provides: headphones
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Should-Start: $NetworkManager
# Should-Stop: $NetworkManager
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of Headphones
# Description: starts instance of Headphones using start-stop-daemon
### END INIT INFO
# Script name
NAME=headphones
# App name
DESC=Headphones
SETTINGS_LOADED=FALSE
. /lib/lsb/init-functions
# Source Headphones configuration
if [ -f /etc/default/headphones ]; then
SETTINGS=/etc/default/headphones
else
log_warning_msg "/etc/default/headphones not found using default settings.";
fi
check_retval() {
if [ $? -eq 0 ]; then
log_end_msg 0
return 0
else
log_end_msg 1
exit 1
fi
}
load_settings() {
if [ $SETTINGS_LOADED != "TRUE" ]; then
. $SETTINGS
## The defaults
# Run as username
RUN_AS=${HP_USER-headphones}
# Path to app HP_HOME=path_to_app_Headphones.py
APP_PATH=${HP_HOME-/opt/headphones}
# Data directory where headphones.db, cache and logs are stored
DATA_DIR=${HP_DATA-/opt/headphones}
# Path to store PID file
PID_FILE=${HP_PIDFILE-/var/run/headphones/headphones.pid}
# Path to python bin
DAEMON=${PYTHON_BIN-/usr/bin/python}
# Extra daemon option like: HP_OPTS=" --config=/home/headphones/config.ini"
EXTRA_DAEMON_OPTS=${HP_OPTS-}
# Extra start-stop-daemon option like START_OPTS=" --group=users"
EXTRA_SSD_OPTS=${SSD_OPTS-}
# Hardcoded port to run on, overrides config.ini settings
[ -n "$HP_PORT" ] && {
PORT_OPTS=" --port=${HP_PORT} "
}
DAEMON_OPTS=" Headphones.py --quiet --daemon --nolaunch --pidfile=${PID_FILE} --datadir=${DATA_DIR} ${PORT_OPTS}${EXTRA_DAEMON_OPTS}"
SETTINGS_LOADED=TRUE
fi
[ -x $DAEMON ] || {
log_warning_msg "$DESC: Can't execute daemon, aborting. See $DAEMON";
return 1;}
return 0
}
load_settings || exit 0
is_running () {
# returns 1 when running, else 0.
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
RET=$?
[ $RET -gt 1 ] && exit 1 || return $RET
else
return 1
fi
}
handle_pid () {
PID_PATH=`dirname $PID_FILE`
[ -d $PID_PATH ] || mkdir -p $PID_PATH && chown -R $RUN_AS $PID_PATH > /dev/null || {
log_warning_msg "$DESC: Could not create $PID_FILE, See $SETTINGS, aborting.";
return 1;}
if [ -e $PID_FILE ]; then
PID=`cat $PID_FILE`
if ! kill -0 $PID > /dev/null 2>&1; then
log_warning_msg "Removing stale $PID_FILE"
rm $PID_FILE
fi
fi
}
handle_datadir () {
[ -d $DATA_DIR ] || mkdir -p $DATA_DIR && chown -R $RUN_AS $DATA_DIR > /dev/null || {
log_warning_msg "$DESC: Could not create $DATA_DIR, See $SETTINGS, aborting.";
return 1;}
}
handle_updates () {
chown -R $RUN_AS $APP_PATH > /dev/null || {
log_warning_msg "$DESC: $APP_PATH not writable by $RUN_AS for web-updates";
return 0; }
}
start_headphones () {
handle_pid
handle_datadir
handle_updates
if ! is_running; then
log_daemon_msg "Starting $DESC"
start-stop-daemon -o -d $APP_PATH -c $RUN_AS --start $EXTRA_SSD_OPTS --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
check_retval
else
log_success_msg "$DESC: already running (pid $PID)"
fi
}
stop_headphones () {
if is_running; then
log_daemon_msg "Stopping $DESC"
start-stop-daemon -o --stop --pidfile $PID_FILE --retry 15
check_retval
else
log_success_msg "$DESC: not running"
fi
}
case "$1" in
start)
start_headphones
;;
stop)
stop_headphones
;;
restart|force-reload)
stop_headphones
start_headphones
;;
status)
status_of_proc -p "$PID_FILE" "$DAEMON" "$DESC"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0

View file

@ -1,15 +1,9 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
proxy_pass https://127.0.0.1:__PORT__; proxy_pass http://localhost:__PORT__;
proxy_redirect off; proxy_set_header Host $host;
proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name __PATH__/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
} }

View file

@ -1,13 +1,12 @@
[Unit] [Unit]
Description=Headphones Description=Headphones
Wants=network.target network-online.target
After=network.target network-online.target
[Service] [Service]
Type=forking Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
ExecStart=/usr/bin/python3 __FINALPATH__/Headphones.py -d --datadir __DATADIR__ --nolaunch --config /etc/headphones/headphones.ini --port __PORT__ WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/venv/bin/python3 __FINALPATH__/Headphones.py --config /etc/__APP__/__APP__.ini --datadir __DATADIR__ --nolaunch
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Headphones is an automated music downloader for NZB and Torrent, written in Python. It supports SABnzbd, NZBget, Transmission, µTorrent, Deluge and Blackhole.

0
doc/DISCLAIMER.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

View file

@ -3,18 +3,17 @@
"id": "headphones", "id": "headphones",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "Automated music downloader for NZB and Torrent", "en": "Automated music downloader for NZB and Torrent"
"fr": "Automated music downloader for NZB and Torrent"
}, },
"version": "0.6.0~ynh1", "version": "0.6.0~ynh1",
"url": "https://github.com/rembo10/headphones", "url": "https://github.com/rembo10/headphones",
"upstream": { "upstream": {
"license": "free", "license": "GPL-3.0-or-later",
"website": "https://github.com/rembo10/headphones", "website": "https://github.com/rembo10/headphones",
"userdoc": "https://github.com/rembo10/headphones/wiki/Usage-guide", "userdoc": "https://github.com/rembo10/headphones/wiki/Usage-guide",
"code": "https://github.com/rembo10/headphones" "code": "https://github.com/rembo10/headphones"
}, },
"license": "free", "license": "GPL-3.0-or-later",
"maintainer": { "maintainer": {
"name": "John doe", "name": "John doe",
"email": "john.doe@example.com" "email": "john.doe@example.com"
@ -27,7 +26,7 @@
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
@ -41,7 +40,7 @@
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"default": true "default": false
} }
] ]
} }

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2" pkg_dependencies="python3 python3-venv"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -1,37 +1,81 @@
#!/bin/bash #!/bin/bash
# Common variable declaration #=================================================
app_id=headphones # GENERIC START
app_user=headphones #=================================================
app_install_dir="/opt/yunohost/${app_id}" # IMPORT GENERIC HELPERS
app_data_dir="/home/yunohost.app/${app_id}" #=================================================
# Retrieve arguments # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
app_method="$(sudo yunohost app setting ${app_id} method)" source ../settings/scripts/_common.sh
app_domain="$(sudo yunohost app setting ${app_id} domain)" source /usr/share/yunohost/helpers
# The parameter $1 is the backup directory location #=================================================
# which will be compressed afterward # MANAGE SCRIPT FAILURE
app_backup_dir="$1/apps/${app_id}" #=================================================
sudo mkdir -p $app_backup_dir
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Backup files if localhost installation #=================================================
if [[ $app_method == "LOCAL"* ]]; then # LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
# Backup sources app=$YNH_APP_INSTANCE_NAME
sudo cp -a $app_install_dir/. $app_backup_dir/sources
# Backup data final_path=$(ynh_app_setting_get --app=$app --key=final_path)
sudo cp -a $app_data_dir/. $app_backup_dir/data domain=$(ynh_app_setting_get --app=$app --key=domain)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
# Backup daemon config #=================================================
sudo cp -a /etc/default/$app_id $app_backup_dir/conf/$app_id.default # DECLARE DATA AND CONF FILES TO BACKUP
sudo cp -a /etc/init.d/$app_id $app_backup_dir/conf/$app_id.init #=================================================
ynh_print_info --message="Declaring files to be backed up..."
fi #=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
# Copy Nginx and YunoHost parameters to make the script "standalone" #=================================================
sudo cp -a /etc/yunohost/apps/$app_id/. $app_backup_dir/yunohost # BACKUP THE DATA DIR
sudo cp -a /etc/nginx/conf.d/$app_domain.d/$app_id.conf $app_backup_dir/nginx.conf #=================================================
ynh_backup --src_path="$datadir" --is_big
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/$app/"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

143
scripts/change_url Normal file
View file

@ -0,0 +1,143 @@
#!/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_script_progression --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
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# 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_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" --line_match="Headphones is shutting down"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --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
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
path_url=$new_path
domain=$new_domain
ynh_add_config --template="../conf/headphones.ini" --destination="/etc/$app/$app.ini"
chmod 600 "/etc/$app/$app.ini"
chown $app:$app "/etc/$app/$app.ini"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting Headphones web server"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app"

View file

@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script. ynh_clean_check_starting
true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -33,7 +32,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --time --weight=1 ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -44,7 +43,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --time --weight=1 ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain 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=path --value=$path_url
@ -54,23 +53,23 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --time --weight=1 ynh_script_progression --message="Finding an available port..."
# Find an available port # Find an available port
port=$(ynh_find_port --port=8181) 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
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
# ynh_script_progression --message="Installing dependencies..." --time --weight=1 ynh_script_progression --message="Installing dependencies..."
# ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --time --weight=1 ynh_script_progression --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -78,7 +77,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --time --weight=1 ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -86,21 +85,30 @@ ynh_setup_source --dest_dir="$final_path"
chmod 750 "$final_path" chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:$app "$final_path"
chmod +x "$final_path/Headphones.py" chmod +x "$final_path/Headphones.py"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1 ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL PYTHON DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing Python dependencies..."
python3 -m venv $final_path/venv
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." --time --weight=1 ynh_script_progression --message="Creating a data directory..."
datadir=/home/yunohost.app/$app datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir ynh_app_setting_set --app=$app --key=datadir --value=$datadir
@ -109,22 +117,23 @@ mkdir -p $datadir
chmod 750 "$datadir" chmod 750 "$datadir"
chmod -R o-rwx "$datadir" chmod -R o-rwx "$datadir"
chown -R $app:www-data "$datadir" chown -R $app:$app "$datadir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --time --weight=1 ynh_script_progression --message="Adding a configuration file..."
ynh_add_config --template="../conf/headphones.defaults" --destination="/etc/default/headphones" mkdir -p "/etc/$app"
ynh_add_config --template="../conf/headphones.ini" --destination="/etc/$app/$app.ini"
#chmod 400 "/etc/default/headphones" chmod 600 "/etc/$app/$app.ini"
#chown $app:$app "/etc/default/headphones" chown $app:$app "/etc/$app/$app.ini"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
@ -134,41 +143,45 @@ ynh_add_systemd_config
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." --time --weight=1 ynh_script_progression --message="Configuring log rotation..."
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting Headphones web server"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --time --weight=1 ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors" ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -176,4 +189,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --time --last ynh_script_progression --message="Installation of $app completed"

View file

@ -12,12 +12,11 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
@ -30,14 +29,14 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." --time --weight=1 ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
@ -45,7 +44,7 @@ ynh_remove_systemd_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -53,7 +52,7 @@ ynh_remove_logrotate
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --time --weight=1 ynh_script_progression --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"
@ -65,14 +64,14 @@ ynh_secure_remove --file="$final_path"
# Remove the data directory if --purge option is used # Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then then
ynh_script_progression --message="Removing app data directory..." --time --weight=1 ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$datadir" ynh_secure_remove --file="$datadir"
fi fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1 ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -80,17 +79,30 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
# ynh_script_progression --message="Removing dependencies..." --time --weight=1 ynh_script_progression --message="Removing dependencies..."
# # Remove metapackage and its dependencies # Remove metapackage and its dependencies
# ynh_remove_app_dependencies ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove a directory securely
ynh_secure_remove --file="/etc/$app"
# Remove the log files
ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 ynh_script_progression --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
@ -99,4 +111,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --time --last ynh_script_progression --message="Removal of $app completed"

View file

@ -1,56 +1,149 @@
#!/bin/bash #!/bin/bash
# Common variable declaration #=================================================
app_id=headphones # GENERIC START
app_user=headphones #=================================================
app_install_dir="/opt/yunohost/${app_id}" # IMPORT GENERIC HELPERS
app_data_dir="/home/yunohost.app/${app_id}" #=================================================
# Retrieve arguments # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
app_method="$(sudo yunohost app setting ${app_id} method)" source ../settings/scripts/_common.sh
app_domain="$(sudo yunohost app setting ${app_id} domain)" source /usr/share/yunohost/helpers
# The parameter $1 is the uncompressed restore directory location #=================================================
app_backup_dir="$1/apps/${app_id}" # 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
# Restore files if localhost installation #=================================================
if [[ $app_method == "LOCAL"* ]]; then # LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
# Kill app app=$YNH_APP_INSTANCE_NAME
sudo service $app_id stop
sudo killall $app_id
# Restore sources domain=$(ynh_app_setting_get --app=$app --key=domain)
sudo cp -a $app_backup_dir/sources/. $app_install_dir path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
# Restore data #=================================================
sudo cp -a $app_backup_dir/data/. $app_data_dir # CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
# Restore daemon config test ! -d $final_path \
sudo cp -a $app_backup_dir/conf/$app_id.default /etc/default/$app_id || ynh_die --message="There is already a directory: $final_path "
sudo cp -a $app_backup_dir/conf/$app_id.init /etc/init.d/$app_id
# Set rights #=================================================
sudo chown -R $app_user $app_install_dir # STANDARD RESTORATION STEPS
sudo chown -R $app_user $app_data_dir #=================================================
sudo chmod +x /etc/init.d/$app_id # RESTORE THE NGINX CONFIGURATION
sudo chmod +x -R $app_install_dir #=================================================
sudo chmod +x -R $app_data_dir ynh_script_progression --message="Restoring the NGINX web server configuration..."
# Start daemon at boot ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
sudo update-rc.d $app_id defaults
# Reload daemon #=================================================
sudo service $app_id restart # RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
fi # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
# Restore Nginx and YunoHost parameters ynh_restore_file --origin_path="$final_path"
sudo cp -a $app_backup_dir/yunohost/. /etc/yunohost/apps/$app_id
sudo cp -a $app_backup_dir/nginx.conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
# Reload Nginx and regenerate SSOwat conf chmod 750 "$final_path"
sudo service nginx reload chmod -R o-rwx "$final_path"
sudo yunohost app ssowatconf chown -R $app:$app "$final_path"
chmod +x "$final_path/Headphones.py"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..."
ynh_restore_file --origin_path="$datadir" --not_mandatory
mkdir -p $datadir
chmod 750 "$datadir"
chmod -R o-rwx "$datadir"
chown -R $app:$app "$datadir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/$app/"
chmod 600 "/etc/$app/$app.ini"
chown $app:$app "/etc/$app/$app.ini"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p "/var/log/$app"
chown -R $app:$app "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting Headphones web server"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"

View file

@ -1,70 +1,170 @@
#!/bin/bash #!/bin/bash
# Basic variable declaration #=================================================
BASEDIR="$(dirname "$(pwd)")" # GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Common variable declaration source _common.sh
app_id=headphones source /usr/share/yunohost/helpers
app_user=headphones
app_install_dir="/opt/yunohost/${app_id}"
app_data_dir="/home/yunohost.app/${app_id}"
app_logs_dir="/var/log/${app_id}"
## Sources definitions
app_src_init="$BASEDIR/conf/${app_id}.init"
app_src_nginx_conf="$BASEDIR/conf/nginx.conf"
# Retrieve arguments #=================================================
app_public="$(sudo yunohost app setting ${app_id} public)" # LOAD SETTINGS
app_method="$(sudo yunohost app setting ${app_id} method)" #=================================================
app_domain="$(sudo yunohost app setting ${app_id} domain)" ynh_script_progression --message="Loading installation settings..."
app_path="$(sudo yunohost app setting ${app_id} path)"
app_host="$(sudo yunohost app setting ${app_id} host)"
app=$YNH_APP_INSTANCE_NAME
# Make upgrade if localhost installation domain=$(ynh_app_setting_get --app=$app --key=domain)
if [[ $app_method == "LOCAL"* ]]; then path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Kill app #=================================================
sudo service $app_id stop # CHECK VERSION
sudo killall $app_id #=================================================
ynh_script_progression --message="Checking version..."
# Upgrade to the latest version of app using the fork upgrade_type=$(ynh_check_app_version_changed)
cd $app_install_dir && sudo git pull
cd -
# Upgrade dependencies #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Update init file # Backup the current version of the app
sudo cp -a $app_src_init /etc/init.d/$app_id 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
# Set rights #=================================================
sudo chown -R $app_user $app_install_dir # STANDARD UPGRADE STEPS
sudo chmod +x /etc/init.d/$app_id #=================================================
sudo chmod +x -R $app_install_dir # STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
# Start service ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" --line_match="Headphones is shutting down"
sudo service $app_id start
#=================================================
# 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 fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Remove trailing "/" for next commands # Create a dedicated user (if not existing)
app_path=${app_path%/} ynh_system_user_create --username=$app --home_dir="$final_path"
# Configure Nginx #=================================================
sudo sed -i "s@PATHTOCHANGE@$app_path@g" $app_src_nginx_conf # DOWNLOAD, CHECK AND UNPACK SOURCE
sudo sed -i "s@HOSTTOCHANGE@$app_host@g" $app_src_nginx_conf #=================================================
sudo cp $app_src_nginx_conf /etc/nginx/conf.d/$app_domain.d/$app_id.conf
# If app is public, add url to SSOWat conf as skipped_uris if [ "$upgrade_type" == "UPGRADE_APP" ]
if [[ $app_public = "Yes" ]];
then then
# See install script ynh_script_progression --message="Upgrading source files..."
sudo yunohost app setting $app_id unprotected_uris -v "/"
# Remove old settings # Download, check integrity, uncompress and patch the source from app.src
sudo yunohost app setting $app_id skipped_uris -d ynh_setup_source --dest_dir="$final_path"
fi fi
# Reload Nginx and regenerate SSOwat conf chmod 750 "$final_path"
sudo service nginx reload chmod -R o-rwx "$final_path"
sudo yunohost app ssowatconf chown -R $app:$app "$final_path"
chmod +x "$final_path/Headphones.py"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
#=================================================
# INSTALL PYTHON DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing Python dependencies..."
ynh_secure_remove --file="$final_path/venv"
python3 -m venv $final_path/venv
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
mkdir -p "/etc/$app"
ynh_add_config --template="../conf/headphones.ini" --destination="/etc/$app/$app.ini"
chmod 600 "/etc/$app/$app.ini"
chown $app:$app "/etc/$app/$app.ini"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="Starting Headphones web server"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"