1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/beehive_ynh.git synced 2024-09-03 18:06:24 +02:00

Merge pull request #4 from YunoHost-Apps/testing

Used yhn helper for rm & upgrade permission
This commit is contained in:
yalh76 2022-02-01 20:18:06 +01:00 committed by GitHub
commit 4bb7cb9fa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 292 additions and 376 deletions

View file

@ -8,10 +8,10 @@ about: When creating a bug report, please use the following template to provide
1. *Read this whole template first.* 1. *Read this whole template first.*
2. *Determine if you are on the right place:* 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!* - *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 beehive itself. Refer to its documentation or repository for help.* - *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.* - *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.* 3. *Delete the italic comments as you write over them below, and remove this guide.*
--- ---
### Describe the bug ### Describe the bug
@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide
- *If you performed a command from the CLI, the command itself is enough. For example:* - *If you performed a command from the CLI, the command itself is enough. For example:*
```sh ```sh
sudo yunohost app install beehive sudo yunohost app install the_app
``` ```
- *If you used the webadmin, please perform the equivalent command from the CLI first.* - *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:* - *If the error occurs in your browser, explain what you did:*

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,48 +1,48 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Beehive for YunoHost # Beehive for YunoHost
![](https://raw.githubusercontent.com/muesli/beehive/master/assets/logo_256.png)
[![Integration level](https://dash.yunohost.org/integration/beehive.svg)](https://dash.yunohost.org/appci/app/beehive) ![](https://ci-apps.yunohost.org/ci/badges/beehive.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/beehive.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/beehive.svg)](https://dash.yunohost.org/appci/app/beehive) ![](https://ci-apps.yunohost.org/ci/badges/beehive.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/beehive.maintain.svg)
[![Install Beehive with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=beehive) [![Install Beehive with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=beehive)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install Beehive quickly and simply on a YunoHost server. > *This package allows you to install Beehive quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
Beehive is an event and agent system, which allows you to create your own agents that perform automated tasks triggered by events and filters. It is modular, flexible and really easy to extend for anyone. It has modules (we call them Hives), so it can interface with, talk to, or retrieve information from Twitter, Tumblr, Email, IRC, Jabber, RSS, Jenkins, Hue - to name just a few.
Available hives: [Click here](https://github.com/muesli/beehive/wiki/Available-Hives) Beehive is an event and agent system, which allows you to create your own agents that perform automated tasks triggered by events and filters. It is modular, flexible and really easy to extend for anyone. It has modules (we call them Hives), so it can interface with, talk to, or retrieve information from Twitter, Tumblr, Email, IRC, Jabber, RSS, Jenkins, Hue - to name just a few.
**Shipped version:** 28.01.2021 ### Features:
- Re-post tweets on your Tumblr blog
- Forward incoming chat messages to your email account
- Turn on the heating system if the temperature drops below a certain value
- Run your own IRC bot that lets you trigger builds on a Jenkins CI
- Control your Hue lighting system
- Notify you when a stock's price drops below a certain value
**Shipped version:** 0.4.0~ynh1
**Demo:** https://github.com/muesli/beehive/wiki/Available-Hives
## Screenshots ## Screenshots
![](https://raw.githubusercontent.com/muesli/beehive-docs/master/screencaps/new_bees.gif) ![](./doc/screenshots/screenshot1.gif)
## YunoHost specific features ## Documentation and resources
#### Multi-user support * Upstream app code repository: https://github.com/muesli/beehive
* YunoHost documentation for this app: https://yunohost.org/app_beehive
Are LDAP and HTTP auth supported? No * Report a bug: https://github.com/YunoHost-Apps/beehive_ynh/issues
Can the app be used by multiple users? Yes
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/beehive%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/beehive/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/beehive%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/beehive/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/beehive_ynh/issues
* Upstream app repository: https://github.com/muesli/beehive
* YunoHost website: https://yunohost.org/
---
## Developer info ## Developer info
**Only if you want to use a testing branch for coding, instead of merging directly into master.**
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/beehive_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/beehive_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
@ -51,3 +51,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/beehive_ynh/tree/test
or or
sudo yunohost app upgrade beehive -u https://github.com/YunoHost-Apps/beehive_ynh/tree/testing --debug sudo yunohost app upgrade beehive -u https://github.com/YunoHost-Apps/beehive_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

51
README_fr.md Normal file
View file

@ -0,0 +1,51 @@
# Beehive pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/beehive.svg)](https://dash.yunohost.org/appci/app/beehive) ![](https://ci-apps.yunohost.org/ci/badges/beehive.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/beehive.maintain.svg)
[![Installer Beehive avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=beehive)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Beehive 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
Beehive is an event and agent system, which allows you to create your own agents that perform automated tasks triggered by events and filters. It is modular, flexible and really easy to extend for anyone. It has modules (we call them Hives), so it can interface with, talk to, or retrieve information from Twitter, Tumblr, Email, IRC, Jabber, RSS, Jenkins, Hue - to name just a few.
### Features:
- Re-post tweets on your Tumblr blog
- Forward incoming chat messages to your email account
- Turn on the heating system if the temperature drops below a certain value
- Run your own IRC bot that lets you trigger builds on a Jenkins CI
- Control your Hue lighting system
- Notify you when a stock's price drops below a certain value
**Version incluse :** 0.4.0~ynh1
**Démo :** https://github.com/muesli/beehive/wiki/Available-Hives
## Captures d'écran
![](./doc/screenshots/screenshot1.gif)
## Documentations et ressources
* Dépôt de code officiel de l'app : https://github.com/muesli/beehive
* Documentation YunoHost pour cette app : https://yunohost.org/app_beehive
* Signaler un bug : https://github.com/YunoHost-Apps/beehive_ynh/issues
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/beehive_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/beehive_ynh/tree/testing --debug
ou
sudo yunohost app upgrade beehive -u https://github.com/YunoHost-Apps/beehive_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -1,13 +1,7 @@
# 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 ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
admin="john" (USER) admin="john"
port="8181" (PORT)
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=0 setup_sub_dir=0
@ -19,7 +13,6 @@
#upgrade=1 from_commit=CommitHash #upgrade=1 from_commit=CommitHash
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0
change_url=0 change_url=0
;;; Options ;;; Options
Email= Email=

6
conf/amd64.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://github.com/muesli/beehive/releases/download/v0.4.0/beehive_0.4.0_Linux_x86_64.tar.gz
SOURCE_SUM=f1959bc2f7c19d4ec8eaabc7b78492836afcc3bcd75d034854e66607efa9efab
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=true

6
conf/armhf.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://github.com/muesli/beehive/releases/download/v0.4.0/beehive_0.4.0_Linux_armv6.tar.gz
SOURCE_SUM=c1fa8f5a1935ee12f09a2bd9579281d64552897c597534361aba90ed992676fb
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=false
SOURCE_EXTRACT=true

19
conf/beehive.conf Normal file
View file

@ -0,0 +1,19 @@
{
"Name":"ircbee_freenode",
"Class":"ircbee",
"Description":"ircbee connected to freenode, channel #beehive",
"Options":[
{
"Name":"server",
"Value":"irc.freenode.net"
},
{
"Name":"nick",
"Value":"beehive"
},
{
"Name":"channels",
"Value":["#beehive"]
}
]
}

View file

@ -1,17 +1,14 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location / {
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__;
proxy_redirect off;
# Force usage of https proxy_set_header Host $host;
if ($scheme = http) { proxy_set_header X-Real-IP $remote_addr;
rewrite ^ https://$server_name$request_uri? permanent; proxy_set_header X-Forwarded-Proto $scheme;
} proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass http://localhost:__PORT__;
proxy_http_version 1.1;
### End of PHP configuration part proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
} }

View file

@ -7,12 +7,12 @@ Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__/
ExecStart=__FINALPATH__/beehive -bind 127.0.0.1:__PORT__ -canonicalurl https://__DOMAIN__ -config __FINALPATH__/__APP__.conf ExecStart=__FINALPATH__/beehive --config __FINALPATH__/beehive.conf -bind "127.0.0.1:__PORT__" -canonicalurl "https://__DOMAIN__"
Restart=always Restart=always
StandardOutput=/var/log/__APP__/__APP__.log #StandardOutput=/var/log/__APP__/__APP__.log
StandardError=/var/log/__APP__/__APP__.log #StandardError=/var/log/__APP__/__APP__.log
SyslogIdentifier=__APP__ #SyslogIdentifier=__APP__
Environment=GOPATH=/usr/local/go/bin WatchdogSec=30s
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

10
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,10 @@
Beehive is an event and agent system, which allows you to create your own agents that perform automated tasks triggered by events and filters. It is modular, flexible and really easy to extend for anyone. It has modules (we call them Hives), so it can interface with, talk to, or retrieve information from Twitter, Tumblr, Email, IRC, Jabber, RSS, Jenkins, Hue - to name just a few.
### Features:
- Re-post tweets on your Tumblr blog
- Forward incoming chat messages to your email account
- Turn on the heating system if the temperature drops below a certain value
- Run your own IRC bot that lets you trigger builds on a Jenkins CI
- Control your Hue lighting system
- Notify you when a stock's price drops below a certain value

0
doc/DISCLAIMER.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

View file

@ -1,40 +1,37 @@
{ {
"name": "beehive", "name": "Beehive",
"id": "beehive", "id": "beehive",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "A flexible event/agent & automation system " "en": "Flexible event/agent & automation system"
}, },
"version": "28.01.2021~ynh1", "version": "0.4.0~ynh1",
"url": "https://github.com/muesli/beehive", "url": "https://github.com/muesli/beehive",
"upstream": {
"license": "AGPL-3.0-or-later",
"demo": "https://github.com/muesli/beehive/wiki/Available-Hives",
"code": "https://github.com/muesli/beehive"
},
"license": "AGPL-1.0-or-later", "license": "AGPL-1.0-or-later",
"maintainer": { "maintainer": {
"name": "anmol" "name": "Anmol Sharma"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.1.3" "yunohost": ">= 4.3.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain"
"ask": {
"en": "Choose a domain name for Beehive"
},
"example": "example.com"
}, },
{ {
"name": "admin", "name": "admin",
"type": "user", "type": "user"
"ask": {
"en": "Choose an admin user"
},
"example": "johndoe"
} }
] ]
} }

View file

@ -1,5 +0,0 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*

View file

@ -3,49 +3,11 @@
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
GO_VERSION=1.16
# dependencies used by the app
pkg_dependencies="wget"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
architecture="arm64"
elif [ -n "$(uname -m | grep 64)" ]; then
architecture="amd64"
else
ynh_die "Unable to detect your achitecture, please open a bug describing \
your hardware and the result of the command \"uname -m\"." 1
fi
ynh_smart_mktemp () {
local min_size="${1:-300}"
# Transform the minimum size from megabytes to kilobytes
min_size=$(( $min_size * 1024 ))
# Check if there's enough free space in a directory
is_there_enough_space () {
local free_space=$(df --output=avail "$1" | sed 1d)
test $free_space -ge $min_size
}
if is_there_enough_space /tmp; then
local tmpdir=/tmp
elif is_there_enough_space /var; then
local tmpdir=/var
elif is_there_enough_space /; then
local tmpdir=/
elif is_there_enough_space /home; then
local tmpdir=/home
else
ynh_die "Insufficient free space to continue..."
fi
echo "$(mktemp --directory --tmpdir="$tmpdir")"
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -15,7 +15,6 @@ 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.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -36,7 +35,6 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
ynh_print_info --message="Declaring files to be backed up..." ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
@ -51,12 +49,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================

View file

@ -19,12 +19,14 @@ old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN new_domain=$YNH_APP_NEW_DOMAIN
new_path="/" new_path="/"
port=$(ynh_app_setting_get --app=$app --key=port)
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
@ -35,9 +37,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -72,14 +74,14 @@ fi
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="stop"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -106,40 +108,27 @@ then
fi fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SETUP SYSTEMD
#=================================================
# ...
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
domain=$new_domain
ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="port domain"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="$app service" --log="/var/log/$app/$app.log"
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Config file loaded from"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --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
@ -147,4 +136,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression --message="Change of URL completed for $app"

View file

@ -14,7 +14,6 @@ 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.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -27,18 +26,16 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
architecture=$YNH_ARCH
app=$YNH_APP_INSTANCE_NAME 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..."
ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app
### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app"
final_path=/opt/yunohost/$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"
# Register (book) web path # Register (book) web path
@ -47,7 +44,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..." --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
@ -58,121 +55,90 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --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 # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_script_progression --message="Configuring system user..."
ynh_install_app_dependencies $pkg_dependencies
# Install Go
tmpdir="$(ynh_smart_mktemp)"
pushd "$tmpdir"
wget https://golang.org/dl/go$GO_VERSION.linux-$architecture.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go$GO_VERSION.linux-$architecture.tar.gz
popd
ynh_secure_remove "$tmpdir"
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/usr/local/go/bin
# Create a system user
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..." --weight=1 ynh_script_progression --message="Setting up source files..."
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
### downloaded from an upstream source, like a git repository.
### `ynh_setup_source` use the file conf/app.src
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
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture"
git clone --recursive https://github.com/muesli/beehive.git "$final_path" chmod 750 "$final_path"
pushd "$final_path" chmod -R o-rwx "$final_path"
make chown -R $app:www-data "$final_path"
popd
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_script_progression --message="Configuring NGINX web server..."
### `ynh_add_nginx_config` will use the file conf/nginx.conf
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # SPECIFIC SETUP
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=1 # ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
# Create a system user ynh_add_config --template="../conf/beehive.conf" --destination="$final_path/beehive.conf"
ynh_system_user_create --username=$app
chmod 600 "$final_path/beehive.conf"
chown $app:$app "$final_path/beehive.conf"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_script_progression --message="Configuring a systemd service..."
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="port domain"
# Create a dedicated systemd config
ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chown -R $app: $final_path
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
ynh_use_logrotate
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app service"
yunohost service add $app --description="$app service" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Config file loaded from"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 ynh_script_progression --message="Configuring permissions..."
# Only the admin can access the admin panel of the app (if the app has an admin panel) # Only the admin can access the admin panel of the app (if the app has an admin panel)
ynh_permission_update --permission "main" --remove all_users --add $admin ynh_permission_update --permission="main" --remove="all_users" --add="$admin"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --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
@ -180,4 +146,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression --message="Installation of $app completed"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -29,31 +29,22 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# 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..." --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..." --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
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --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"
@ -61,46 +52,17 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --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
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
ynh_script_progression --message="Closing port $port..." --weight=1
ynh_exec_warn_less yunohost firewall disallow TCP $port
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
# 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..." --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
@ -109,4 +71,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression --message="Removal of $app completed"

View file

@ -15,7 +15,6 @@ 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.
true true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -24,7 +23,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -35,10 +34,8 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_script_progression --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 \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
@ -47,45 +44,38 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= chmod 750 "$final_path"
# RECREATE THE DEDICATED USER chmod -R o-rwx "$final_path"
#================================================= chown -R $app:www-data "$final_path"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) chmod 600 "$final_path/beehive.conf"
ynh_system_user_create --username=$app chown $app:$app "$final_path/beehive.conf"
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R $app: $final_path
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
@ -93,29 +83,23 @@ systemctl enable $app.service --quiet
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app service" --log="/var/log/$app/$app.log" yunohost service add $app --description="$app service"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting 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=systemd --line_match="Config file loaded from"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --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
@ -123,4 +107,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression --message="Restoration completed for $app"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -21,37 +21,19 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
architecture=$YNH_ARCH
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
if ! ynh_permission_exists --permission="admin"; then
# Create the required permissions
ynh_permission_create --permission="admin" --url="/" --allowed=$admin
fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -67,9 +49,17 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -77,69 +67,48 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
export PATH=$PATH:/usr/local/go/bin ynh_setup_source --dest_dir="$final_path" --source_id="$architecture"
export GOPATH=/usr/local/go/bin
pushd "$final_path"
git pull
make
popd
fi fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_script_progression --message="Updating a configuration file..."
ynh_install_app_dependencies $pkg_dependencies ynh_add_config --template="../conf/beehive.conf" --destination="$final_path/beehive.conf"
#================================================= chmod 600 "$final_path/beehive.conf"
# CREATE DEDICATED USER chown $app:$app "$final_path/beehive.conf"
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app" --template="systemd.service" --others_var="port domain" ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R $app: $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
@ -147,21 +116,21 @@ ynh_use_logrotate --non-append
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="$app service" --log="/var/log/$app/$app.log" yunohost service add $app --description="$app service"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting 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=systemd --line_match="Config file loaded from"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --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
@ -169,4 +138,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of $app completed"