1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/petrolette_ynh.git synced 2024-09-03 19:56:26 +02:00
* update to 1.6

* use dev environment to accept reverse proxy

* add sed to allow subdomain

Co-authored-by: Tobias Ollive <tobias@ollive.oiseauroch.fr>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
This commit is contained in:
oiseauroch 2022-11-17 22:19:45 +00:00 committed by GitHub
parent 0a1c3f314a
commit 8261c57c58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 251 additions and 58 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Petrolette for YunoHost
[![Integration level](https://dash.yunohost.org/integration/petrolette.svg)](https://dash.yunohost.org/appci/app/petrolette) ![](https://ci-apps.yunohost.org/ci/badges/petrolette.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/petrolette.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/petrolette.svg)](https://dash.yunohost.org/appci/app/petrolette) ![Working status](https://ci-apps.yunohost.org/ci/badges/petrolette.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/petrolette.maintain.svg)
[![Install Petrolette with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=petrolette)
*[Lire ce readme en français.](./README_fr.md)*
@ -17,34 +17,40 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
The news reader that doesn't know you
**Shipped version:** 1.5.3~ynh1
**Shipped version:** 1.6.0~ynh1
**Demo:** https://petrolette.space
## Screenshots
![](./doc/screenshots/petrolette.png)
![Screenshot of Petrolette](./doc/screenshots/petrolette.webp)
## Disclaimers / important information
- require a dedicated domain
- the application doesn't store anything locally. Restore/uprade operation is basically reinstalling the app.
- The application has 2 modes
- multi user : each user store is own config itself.
- mono user : configuration is store locally in the server. Each visitor see the same page.
/!\ For now, there is no any mechanism included for feed protection. Any visitor can modify the feed list.
- If you like this software, Please consider to [support the Pétrolette project by sending a donation](https://liberapay.com/yPhil/donate). Even the smallest amount will help a lot.
## Documentation and resources
* Upstream app code repository: https://framagit.org/yphil/petrolette
* YunoHost documentation for this app: https://yunohost.org/app_petrolette
* Report a bug: https://github.com/YunoHost-Apps/petrolette_ynh/issues
* Upstream app code repository: <https://framagit.org/yphil/petrolette>
* YunoHost documentation for this app: <https://yunohost.org/app_petrolette>
* Report a bug: <https://github.com/YunoHost-Apps/petrolette_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/petrolette_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/petrolette_ynh/tree/testing --debug
or
sudo yunohost app upgrade petrolette -u https://github.com/YunoHost-Apps/petrolette_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
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.
-->
# Petrolette pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/petrolette.svg)](https://dash.yunohost.org/appci/app/petrolette) ![](https://ci-apps.yunohost.org/ci/badges/petrolette.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/petrolette.maintain.svg)
[![Niveau d'intégration](https://dash.yunohost.org/integration/petrolette.svg)](https://dash.yunohost.org/appci/app/petrolette) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/petrolette.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/petrolette.maintain.svg)
[![Installer Petrolette avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=petrolette)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Petrolette 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.*
@ -13,34 +17,40 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
La page d'actu qui ne sait rien de toi
**Version incluse :** 1.5.3~ynh1
**Version incluse :** 1.6.0~ynh1
**Démo :** https://petrolette.space
## Captures d'écran
![](./doc/screenshots/petrolette.png)
![Capture d'écran de Petrolette](./doc/screenshots/petrolette.webp)
## Avertissements / informations importantes
- require a dedicated domain
- the application doesn't store anything locally. Restore/uprade operation is basically reinstalling the app.
- The application has 2 modes
- multi user : each user store is own config itself.
- mono user : configuration is store locally in the server. Each visitor see the same page.
/!\ For now, there is no any mechanism included for feed protection. Any visitor can modify the feed list.
- If you like this software, Please consider to [support the Pétrolette project by sending a donation](https://liberapay.com/yPhil/donate). Even the smallest amount will help a lot.
## Documentations et ressources
* Dépôt de code officiel de l'app : https://framagit.org/yphil/petrolette
* Documentation YunoHost pour cette app : https://yunohost.org/app_petrolette
* Signaler un bug : https://github.com/YunoHost-Apps/petrolette_ynh/issues
* Dépôt de code officiel de l'app : <https://framagit.org/yphil/petrolette>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_petrolette>
* Signaler un bug : <https://github.com/YunoHost-Apps/petrolette_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/petrolette_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/petrolette_ynh/tree/testing --debug
ou
sudo yunohost app upgrade petrolette -u https://github.com/YunoHost-Apps/petrolette_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -4,7 +4,7 @@
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=0
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
@ -15,4 +15,4 @@
backup_restore=1
multi_instance=1
port_already_use=0
change_url=0
change_url=1

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://framagit.org/yphil/petrolette/-/archive/v1.5.6/petrolette-v1.5.6.tar.gz
SOURCE_SUM=f615a84aa5026ca18b79d3d14b2eaebd6e76dd047a325465d3d8957bc7bf5967
SOURCE_URL=https://framagit.org/yphil/petrolette/-/archive/v1.6.0/petrolette-v1.6.0.tar.gz
SOURCE_SUM=25cff32873fb643882a1b43681842a646d4e46a9802da2ab086ab29f770b7d7e
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true

View file

@ -1,5 +1,8 @@
location / {
proxy_pass http://localhost:__PORT__/;
location __PATH__/ {
proxy_set_header Host $host;
proxy_buffering off;
rewrite ^__PATH__$ __PATH__/ break;
proxy_pass http://localhost:__PORT__/;
}

View file

@ -0,0 +1,3 @@
{
"instanceType" : "monoUser"
}

View file

@ -5,33 +5,43 @@ After=network.target
[Service]
Type=simple
Environment="__YNH_NODE_LOAD_PATH__"
Environment="NODE_ENV=development"
User=__APP__
Group=__APP__
ExecStart=/bin/sh -c ' node http/server.js'
ExecStart=/bin/sh -c ' npm run unmanaged'
WorkingDirectory=__FINALPATH__/
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=__APP__
Restart=always
; Some security directives.
; Use private /tmp and /var/tmp folders inside a new file system namespace,
; which are discarded after the process stops.
PrivateTmp=true
; Mount /usr, /boot, and /etc as read-only for processes invoked by this service.
# Sandboxing options to harden security
# Depending on specificities of your service/app, you may need to tweak these
# .. but this should be a good baseline
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed
ProtectSystem=full
; Sets up a new /dev mount for the process and only adds API pseudo devices
; like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled
; by default because it may not work on devices like the Raspberry Pi.
PrivateDevices=false
; Ensures that the service process and all its children can never gain new
; privileges through execve().
NoNewPrivileges=true
; This makes /home, /root, and /run/user inaccessible and empty for processes invoked
; by this unit. Make sure that you do not depend on data inside these folders.
ProtectHome=false
; Drops the sys admin capability from the daemon.
CapabilityBoundingSet=~CAP_SYS_ADMIN
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
# Denying access to capabilities that should not be relevant for webapps
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
[Install]
WantedBy=multi-user.target

View file

@ -1,3 +1,7 @@
- require a dedicated domain
- the application doesn't store anything locally. Restore/uprade operation is basically reinstalling the app.
- The application has 2 modes
- multi user : each user store is own config itself.
- mono user : configuration is store locally in the server. Each visitor see the same page.
/!\ For now, there is no any mechanism included for feed protection. Any visitor can modify the feed list.
- If you like this software, Please consider to [support the Pétrolette project by sending a donation](https://liberapay.com/yPhil/donate). Even the smallest amount will help a lot.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View file

@ -6,7 +6,7 @@
"en": "The news reader that doesn't know you",
"fr": "La page d'actu qui ne sait rien de toi"
},
"version": "1.5.3~ynh1",
"version": "1.6.0~ynh1",
"url": "https://framagit.org/yphil/petrolette",
"upstream": {
"license": "AGPL-3.0-only",
@ -31,6 +31,25 @@
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/petrolette",
"default": "/petrolette"
},
{
"name": "mono_user",
"type": "boolean",
"default": true,
"ask": {
"fr" : "Cette instance est elle mono utilisateur ?",
"en" : "Is this instance mono user ?"
},
"help" : {
"fr" : "Cette instance ne proposera qu'une seule selection de flux, la même pour tous les visiteurs",
"en" : "This instance will have the same rss selection for any visitor visiting the page"
}
},
{
"name": "is_public",
"type": "boolean",

View file

@ -4,7 +4,7 @@
# COMMON VARIABLES
#=================================================
NODEJS_VERSION=15
NODEJS_VERSION=16
#=================================================
# PERSONAL HELPERS

125
scripts/change_url Normal file
View file

@ -0,0 +1,125 @@
#!/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..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# 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
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# 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..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
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
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -24,8 +24,9 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
mono_user=$YNH_APP_ARG_MONO_USER
app=$YNH_APP_INSTANCE_NAME
@ -47,6 +48,7 @@ ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=mono_user --value=$mono_user
#=================================================
# STANDARD MODIFICATIONS
@ -106,10 +108,17 @@ pushd $final_path
sed -i "/HTTP_PORT/s/[0-9]*[0-9]/$port/" package.json
sed -i "/HTTPS_PORT/s/[0-9]*[0-9]/$https_port/" package.json
# use custom home value to avoid bower storing values in root and have right errors
if [ $mono_user -eq 1 ] ; then
ynh_add_config --template="petrolette.config.json" --destination="petrolette.config.json"
fi
if [ "$path_url" != "/" ] ; then
sed -i "s|\$.get(\"/feed\", {|\$.get(\"feed\", {|" public/js/PTL.feed.js
fi
[[ -v HOME ]] && TMP_HOME=$HOME
HOME=$(pwd)
export NODE_ENV=production
ynh_use_nodejs
ynh_npm install
ynh_npm install --ignore-scripts
[[ -v TMP_HOME ]] && HOME=$TMP_HOME || unset HOME
popd
@ -140,7 +149,7 @@ yunohost service add $app --description="The news reader that doesn't know you"
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="(v1.5.6)"
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Pétrolette HTTP Server running on port"
#=================================================
# SETUP SSOWAT

View file

@ -98,7 +98,7 @@ yunohost service add $app --description="The news reader that doesn't know you"
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Directory created"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Pétrolette HTTP Server running on port"
#=================================================
# GENERIC FINALIZATION

View file

@ -99,11 +99,14 @@ pushd $final_path
# set port in configuration file
sed -i "/HTTP_PORT/s/[0-9]*[0-9]/$port/" package.json
sed -i "/HTTPS_PORT/s/[0-9]*[0-9]/$https_port/" package.json
if [ "$path_url" != "/" ] ; then
sed -i "s|\$.get(\"/feed\", {|\$.get(\"feed\", {|" public/js/PTL.feed.js
fi
[[ -v HOME ]] && TMP_HOME=$HOME
HOME=$(pwd)
ynh_use_nodejs
ynh_npm install
ynh_npm update
[[ -v TMP_HOME ]] && HOME=$TMP_HOME || unset HOME
popd
@ -133,7 +136,8 @@ yunohost service add $app --description="The news reader that doesn't know you"
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="(v1.5.6)"
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Pétrolette HTTP Server running on port"
#=================================================
# RELOAD NGINX