Compare commits

...

52 commits

Author SHA1 Message Date
Boudewijn
9aef174f1c Replace nginx conf with the Laravel default 2025-03-04 16:13:04 +01:00
Boudewijn
9a4639b1d0 re-try screenshot 2025-03-03 22:13:02 +01:00
Boudewijn
3988f71f09 cleaning up before publishing 2025-03-03 22:10:40 +01:00
Boudewijn
934dfddcb3 token generation works, tinker call works, but directly afterwards rollback. Change order of artisan calls in install to pinpoint cause of roll back 2025-03-03 15:32:58 +01:00
Boudewijn
a718380bfd retry, now generating in _common instead of manifest 2025-03-03 15:25:23 +01:00
Boudewijn
9519cfaa43 retry, now generating in manifest instead of install'
:
2025-03-03 15:22:15 +01:00
Boudewijn
1be91cc2dd Revised method for user injection: artisan tinker 2025-03-03 15:15:31 +01:00
Boudewijn
8b69328c85 remove user creation during install 2025-03-03 14:09:06 +01:00
Boudewijn
6eeb04a332 CreateUser crashes on missing factory and faker. Perhaps caused by me not including the Artisan test script. For now, do not prompt for credentials or attempt to crate the user 2025-03-02 22:56:41 +01:00
Boudewijn
4cb061c021 'name' is a reserved keyword, replace it by 'user' in manifest and install 2025-03-02 22:29:38 +01:00
Boudewijn
adb5d3b94c first attempt at preseeding the app with user credentials 2025-03-02 22:19:18 +01:00
Boudewijn
418c941db9 update manifest, install; add CreateUser.php to preseed admin during install 2025-03-02 22:06:35 +01:00
Boudewijn
18ea4071c7 tailor remove script; remove extended config script 2025-03-02 21:48:36 +01:00
Boudewijn
6a7e851454 Include restore and upgrade scripts, update change_url 2025-03-02 21:45:15 +01:00
Boudewijn
d41c3be841 Include backup- and change-URL-scripts 2025-03-02 21:27:39 +01:00
Boudewijn
960cf6e0c0 move rewrite rule to inside (outer) location instead of in php location 2025-03-02 19:14:28 +01:00
Boudewijn
fb517aff32 move rewrite rule to inside location, remove root directive 2025-03-02 18:59:29 +01:00
Boudewijn
a8d41f6af5 re-add root to nginx.conf 2025-03-02 11:08:30 +01:00
Boudewijn
b32ccf5ee8 Update description and other docs, cleanup scripts 2025-03-01 17:42:29 +01:00
Boudewijn
a63795dbc0 update description 2025-03-01 17:18:51 +01:00
Boudewijn
1de66a57c5 add description and screenshot 2025-03-01 17:14:30 +01:00
Boudewijn
dfa92b6640 tweak conf/nginx.conf - add rewrite for seemingly erronous redirect to /usr/share/nginx by laravel auth.php to login/register 2025-03-01 16:18:38 +01:00
Boudewijn
24cc1ae4c3 tweak conf/nginx.conf 2025-03-01 13:31:03 +01:00
Boudewijn
4690aa29e0 tweak permissions in conf/install 2025-03-01 10:59:53 +01:00
Boudewijn
5ccc9c7b3c tweak permissions in manifest and conf/install 2025-03-01 10:57:07 +01:00
Boudewijn
fb171c8e65 switch from __variable__ to in install file 2025-03-01 09:43:16 +01:00
Boudewijn
351e4ba985 remove systemd references, restart nginx/php-fpm 2025-03-01 09:40:53 +01:00
Boudewijn
6266f4ab30 enclose .env's app_name in quotes to allow space 2025-03-01 09:32:13 +01:00
Boudewijn
7f865c37a1 remove systemd.service 2025-03-01 09:24:30 +01:00
Boudewijn
eeb0102d9a Various alterations, deletions and additions after running my idlers successfully without path on non-Yunohost 2025-03-01 09:17:43 +01:00
Boudewijn
2657cc1e48 Replace lychee nginx.conf with the default nginx.conf from the example package 2025-02-27 08:15:10 +01:00
Boudewijn
cb1c42cbc3 remove another lychee copy-ism, this time for a non-existant directory 2025-02-26 22:37:40 +01:00
Boudewijn
e021cda93e follow cp6's instructions for installing, not a copy of lychee: remove --force from database install via artisan to prevent errors 2025-02-26 22:35:32 +01:00
Boudewijn
9994b4f8b4 remove from install an attempt at updating composer 2025-02-26 22:32:42 +01:00
Boudewijn
6fffad8aca remove from install all references to ynh_composer_version 2025-02-26 22:25:04 +01:00
Boudewijn
21de0157b2 add ynh_composer_version in _common.sh 2025-02-26 22:22:37 +01:00
Boudewijn
717d17545a install: r34 in commentaar zetten (composer version) 2025-02-26 21:52:21 +01:00
Boudewijn
b4c78749d5 install: proberen om ynh_composer_version mee te geven, zie https://forum.yunohost.org/t/new-experimental-2-1-helpers/30114 2025-02-26 21:50:00 +01:00
Boudewijn
6504a34186 install: proberen om ynh_composer_version mee te geven, zie https://forum.yunohost.org/t/new-experimental-2-1-helpers/30114 2025-02-26 21:47:42 +01:00
Boudewijn
75a7305ce0 install: proberen om ynh_composer_version mee te geven, zie https://forum.yunohost.org/t/new-experimental-2-1-helpers/30114 2025-02-26 21:43:18 +01:00
Boudewijn
945f289d91 install: proberen om ynh_composer_version mee te geven 2025-02-26 21:26:41 +01:00
Boudewijn
36f2025a0f install: ynh_composer_update bestaat niet, verwijderd. Later alternatief zoeken 2025-02-26 11:05:24 +01:00
Boudewijn
60899342a5 php-curl aan manifest toevoegen, ynh_composer_update aan install 2025-02-26 11:02:58 +01:00
Boudewijn
d4102d0e85 .env __TIMEZONE__ is misschien ookn niet beschikbaar 2025-02-26 10:39:24 +01:00
Boudewijn
0ad090b471 __APP_KEY__ vullen via artisan ipv parameter replacement 2025-02-26 10:37:29 +01:00
Boudewijn
63ba69359d include composer/building lines in install script 2025-02-26 10:24:13 +01:00
Boudewijn
38217b536a disable admin/password for now while testing installation 2025-02-25 15:15:17 +01:00
Boudewijn
e2c6566a94 some_config_file does not seem to be needed, was commented out - mostly. Last occurence not, causing install failure. Now commented as well 2025-02-25 15:13:56 +01:00
Boudewijn
3baeb288c3 manifest.toml: mariadb-server is nog niet beschikbaar op kale installatie, ook meegeven 2025-02-25 15:08:59 +01:00
Boudewijn
5f909daf50 error installing, command 'mysql' not recognized --> add mariadb-client to apt resources in manifest.toml 2025-02-25 14:43:34 +01:00
Boudewijn
e3e68e2e17 Commit first changes to example package for My Idlers 2025-02-25 14:30:31 +01:00
Boudewijn
7dc62bdd06 manifest, conf/* en scripts/install bijgewerkt 2025-02-23 22:48:25 +01:00
20 changed files with 187 additions and 568 deletions

View file

@ -1,4 +1 @@
File containing the license of your package.
More information here:
https://choosealicense.com/
AGPL-3

15
conf/.env Normal file
View file

@ -0,0 +1,15 @@
APP_NAME="My Idlers"
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=https://__DOMAIN__
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=__DB_NAME__
DB_USERNAME=__DB_USER__
DB_PASSWORD=__DB_PWD__
DB_LOG_SQL=false

View file

@ -1,25 +1,33 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
server {
listen 80;
server_name __DOMAIN_NAME__;
root /example.com/public;
# Path to source
alias __INSTALL_DIR__/;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
### Example PHP configuration (remove it if not used)
index index.php;
index index.html index.htm index.php;
# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file
# client_max_body_size 50M;
charset utf-8;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
### End of PHP configuration part
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php__PHP_VERSION__-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}

View file

@ -1,49 +0,0 @@
[Unit]
Description=Small description of the service
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__INSTALL_DIR__/
ExecStart=__INSTALL_DIR__/script
StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit
### Depending on specificities of your service/app, you may need to tweak these
### .. but this should be a good baseline
# Sandboxing options to harden security
# 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 AF_NETLINK
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed
ProtectClock=yes
ProtectHostname=yes
ProtectProc=invisible
ProtectSystem=full
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
SystemCallArchitectures=native
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged
# 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 +1,22 @@
This is a dummy description of this app features
If you are the person in your family, group of friends or colleauges that manages the servers, domain names, online accounts and other hosted services, than this app is for you.
My Idlers is a useful register for keeping track of your servers and online hosting accounts.
It is a single-user app; if more than one person wants to use this functionality, it needs to be installed multiple times.
Besides that, for now, it needs a (sub)domain for itself.
This is my first app packaging attempt; there may be some rough edges.
What works:
* installing the app and using its features
* uninstalling
* backup
* moving the app to another domain
What does not (yet?) work or is untested:
* installing the app in subfolder
* LDAP integration
* restore from backup
* API access
![Screenshot of My Idlers](./doc/screenshots/my_idlers.jpg)

View file

@ -1 +1,24 @@
Ceci est une fausse description des fonctionalités de l'app
(machine translate from English)
Si vous êtes la personne de votre famille, de votre groupe d'amis ou de vos collègues qui gère les serveurs, les noms de domaine, les comptes en ligne et d'autres services hébergés, alors cette application est faite pour vous.
My Idlers est un registre utile pour suivre vos serveurs et vos comptes d'hébergement en ligne.
C'est une application monoposte; si plusieurs personnes veulent utiliser cette fonctionnalité, il faut l'installer plusieurs fois. De plus, pour l'instant, elle nécessite un (sous-)domaine dédié.
Il s'agit de ma première tentative d'emballage d'application; il peut y avoir quelques imperfections.
Ce qui fonctionne :
* installation de l'application et utilisation de ses fonctionnalités
* désinstallation
* sauvegarde
* déplacement de l'application vers un autre domaine
Ce qui ne fonctionne pas (encore) ou n'est pas testé :
* installation de l'application dans un sous-dossier
* intégration LDAP
* restauration à partir d'une sauvegarde
* accès API
![Screenshot of My Idlers](./doc/screenshots/my_idlers.jpg)

View file

@ -1,7 +1,7 @@
This is a dummy disclaimer to display after the install
The app url is <https://__DOMAIN____PATH__>
The app install dir is `__INSTALL_DIR__`
The app id is `__ID__`
There was an attempt to create a user with the credentials you provided. Please open the app to log in. If presented with a "registration" page instead of "login", please create an account yourself. Either way, the account will unfortunately not be synchronized with Yunohost users.

View file

@ -1 +1,3 @@
This is a dummy disclaimer to display prior to the install
For now, only the domain and group can be set.
After installation, visit the app to create an account. As this is a single-user app, the registration page will not be available after that anymore.

View file

@ -1 +1,3 @@
Ceci est un faux disclaimer à présenter avant l'installation
Pour l'instant, seuls le domaine et le groupe peuvent être définis.
Après l'installation, visitez l'application pour créer un compte. Comme il s'agit d'une application monoposte, la page de création de compte ne sera plus disponible par la suite.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 319 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 KiB

View file

@ -2,135 +2,80 @@
packaging_format = 2
id = "example"
name = "Example app"
description.en = "Explain in *a few (10~15) words* the purpose of the app or what it actually does (it is meant to give a rough idea to users browsing a catalog of 100+ apps)"
description.fr = "Expliquez en *quelques* (10~15) mots l'utilité de l'app ou ce qu'elle fait (l'objectif est de donner une idée grossière pour des utilisateurs qui naviguent dans un catalogue de 100+ apps)"
id = "my_idlers"
name = "My Idlers"
description.en = "A self-hosted web app for displaying, organizing and storing information about your servers (VPS/Dedi), shared & reseller hosting, seedboxes, domains, DNS and misc services. Are you the person in your family, group of friends or at work who keeps an eye on everyones Yunohosts, then this is the app to help you."
description.fr = "Une application Web auto-hébergée pour afficher, organiser et stocker des informations sur vos serveurs (VPS/Dedi), votre hébergement partagé et revendeur, vos seedboxes, vos domaines, vos DNS et divers services."
version = "1.0~ynh1"
version = "3.0~ynh1"
maintainers = ["johndoe"]
maintainers = ["wbk"]
[upstream]
# NB: Only the "license" key is mandatory. Remove entries for which there's no relevant data
license = "free" # you can see the available licenses identifiers list here: https://spdx.org/licenses/
website = "https://example.com"
demo = "https://demo.example.com"
admindoc = "https://yunohost.org/packaging_apps"
userdoc = "https://yunohost.org/apps"
code = "https://some.forge.com/example/example"
# FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is
# sort of a standard id for applications defined by the NIST. In particular, YunoHost may use this is in the future
# to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here:
# https://nvd.nist.gov/products/cpe/search.
# For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
cpe = "???"
license = "MIT"
demo = "https://demo.myidlers.com/login"
userdoc = "https://lowendspirit.com/discussion/2449/my-idlers-self-hosted-web-app-for-your-servers-shared-hosting-and-domains-information/"
code = "https://github.com/cp6/my-idlers#install"
# FIXME: optional but recommended (or remove if irrelevant / not applicable).
# This is meant to be an URL where people can financially support this app, especially when its development is based
# on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
fund = "???"
[integration]
yunohost = ">= 12.0.9"
yunohost = ">= 12.0.9"
helpers_version = "2.1"
# FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
architectures = "all"
multi_instance = true
architectures = "all"
multi_instance = true
# FIXME: replace with true, false, or "not_relevant".
# Not to confuse with the "sso" key: the "ldap" key corresponds to wether or not a user *can* login on the app using
# its YunoHost credentials.
ldap = "?"
#try whether integration is possible later on
ldap = "false"
sso = "false"
# FIXME: replace with true, false, or "not_relevant".
# Not to confuse with the "ldap" key: the "sso" key corresponds to wether or not a user is *automatically logged-in*
# on the app when logged-in on the YunoHost portal.
sso = "?"
# FIXME: replace with an **estimate** minimum disk and RAM requirements. e.g. 20M, 400M, 1G...
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
disk = "100M"
ram.build = "150M"
ram.runtime = "100M"
[install]
[install.domain]
# this is a generic question - ask strings are automatically handled by YunoHost's core
type = "domain"
[install.path]
# this is a generic question - ask strings are automatically handled by YunoHost's core
type = "path"
default = "/example"
# unable to get this to work, disable for now
#[install.path]
#type = "path"
#default = "/idlers"
[install.init_main_permission]
# this is a generic question - ask strings are automatically handled by YunoHost's core
# This won't be saved as setting and will instead be used to initialize the SSOwat permission
type = "group"
default = "visitors"
[install.language]
ask.en = "Choose the application language"
ask.fr = "Choisissez la langue de l'application"
type = "select"
choices = ["fr", "en"]
default = "fr"
[install.admin]
# this is a generic question - ask strings are automatically handled by YunoHost's core
type = "user"
default = "all_users"
[install.user]
help.en = "The name of the user"
type = "string"
[install.email]
help.en = "The email address used for logging in to the application"
type = "email"
[install.password]
# this is a generic question - ask strings are automatically handled by YunoHost's core
# Note that user-provided passwords questions are not automatically saved as setting
help.en = "Use the help field to add an information for the admin about this question."
help.fr = "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
type = "password"
[resources]
# See the packaging documentation for the full set
# of explanation regarding the behavior and properties for each of those
[resources.sources]
[resources.sources.main]
# This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with :
# ynh_setup_source --dest_dir="$install_dir"
# You can also define other assets than "main" and add --source_id="foobar" in the previous command
url = "https://github.com/foo/bar/archive/refs/tags/v1.2.3.tar.gz"
sha256 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
# These infos are used by https://github.com/YunoHost/apps/blob/master/tools/autoupdate_app_sources/autoupdate_app_sources.py
# to auto-update the previous asset urls and sha256sum + manifest version
# assuming the upstream's code repo is on github and relies on tags or releases
# See the 'sources' resource documentation for more details
# autoupdate.strategy = "latest_github_tag"
# This will pre-fetch the asset
url = "https://github.com/cp6/my-idlers/archive/refs/tags/3.0.zip"
sha256 = "f92a6dc9c98ec1e3837939db571833d28e72b992f5a9611925e9d242fcb40f72"
[resources.system_user]
# This will provision/deprovision a unix system user
user = "__APP_NAME__:rwx"
[resources.install_dir]
# This will create/remove the install dir as /var/www/$app
# and store the corresponding setting $install_dir
[resources.data_dir]
# This will create/remove the data dir as /home/yunohost.app/$app
# and store the corresponding setting $data_dir
group = "www-data:r-x"
[resources.permissions]
# This will configure SSOwat permission for $domain/$path/
# The initial allowed group of user is configured via the init_main_permission question (public=visitors, private=all_users)
main.url = "/"
[resources.ports]
# This will pick a random port for reverse-proxying and store it as the $port setting
[resources.apt]
# This will automatically install/uninstall the following apt packages
# and implicitly define the $phpversion setting as 8.0 (if phpX.Y-foobar dependencies are listed)
packages = "mariadb-server, deb1, deb2, php8.3-foo, php8.3-bar"
packages = "php8.3, php8.3-cli, php8.3-mbstring, php8.3-xml, php8.3-mysql, php8.3-intl, php8.3-pdo, php8.3-intl, composer, mariadb-server, mariadb-client, php8.3-curl"
[resources.database]
# This will automatically provision/deprovison a MySQL DB and store the corresponding credentials in settings $db_user, $db_name, $db_pwd
type = "mysql"

View file

@ -3,3 +3,7 @@
#=================================================
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
composer_version="2.5.5"
php_version="8.3"
# will not stay stable over installs, should not be a problem
token=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 60)

View file

@ -10,67 +10,23 @@ source /usr/share/yunohost/helpers
ynh_print_info "Declaring files to be backed up..."
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
### to be backuped and not an actual copy of any file. The actual backup that
### creates and fills the archive with the files happens in the core after this
### script is called. Hence ynh_backups calls take basically 0 seconds to run.
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
# Only relevant if there is a "data_dir" resource for this app
# NB: $data_dir is not backuped during safety-backup-before-upgrades,
# because the data dir may be huge and we don't want to just yolo-create a 10+ GB archive just for upgrades.
# On the other hand, $data_dir is also *not* removed by default in the "app remove" step unless --purge is used
# This means that even if the upgrade fails and the backup is restored, the data are still there.
ynh_backup "$data_dir"
#=================================================
# BACKUP SYSTEM CONFIGURATION
#=================================================
# Backup the PHP-FPM configuration
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
# Backup the NGINX configuration
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup the systemd service unit
ynh_backup "/etc/systemd/system/$app.service"
# Backup the logrotate configuration
ynh_backup "/etc/logrotate.d/$app"
# Backup the Fail2Ban config
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup "/etc/cron.d/$app"
ynh_backup "/etc/$app/"
# NB: /var/log is not backuped during safety-backup-before-upgrades, same as $data_dir
ynh_backup "/var/log/$app/"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info "Backing up the MySQL database..."
### (However, things like MySQL dumps *do* take some time to run, though the
### copy of the generated dump to the archive still happens later)
ynh_mysql_dump_db > db.sql
#=================================================

View file

@ -1,6 +1,5 @@
#!/bin/bash
## this script is only run if actual change to domain/path is detected, if you're here either $domain or $path changed
## new location is available via $domain and $path (or $new_domain and $new_path variables if you want to be explicit)
## old values are available via, you guessed it, $old_domain and $old_path
@ -14,9 +13,8 @@ source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemctl --service="$app" --action="stop"
## My Idlers runs as a Laravel app on nginx; keep nginx running, so no stop
#=================================================
# MODIFY URL IN NGINX CONF
@ -30,14 +28,14 @@ ynh_config_change_url_nginx
# SPECIFIC MODIFICATIONS
#=================================================
## do any changes to files that reference specific installation domain/path, i.e. regenerate configs etc
## Only the app_url in .env needs to change
sed -i -e 's/$old_domain/new_domain/g' $install_dir/.env
sed -i -e 's/$old_path/new_path/g' $install_dir/.env
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service="$app" --action="start"
## perhaps a better option than sed: ynh_replace + ynh_store_file_checksum; try it out later
# ynh_replace --match=$old_domain --replace="$new_domain --file="$install_dir/.env"
# ynh_replace --match=$old_path --replace="$new_path --file="$install_dir/.env"
ynh_store_file_checksum "$install_dir/.env"
#=================================================
# END OF SCRIPT

View file

@ -1,96 +0,0 @@
#!/bin/bash
# In simple cases, you don't need a config script.
# With a simple config_panel.toml, you can write in the app settings, in the
# upstream config file or replace complete files (logo ...) and restart services.
# The config scripts allows you to go further, to handle specific cases
# (validation of several interdependent fields, specific getter/setter for a value,
# display dynamic informations or choices, pre-loading of config type .cube... ).
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
install_dir=$(ynh_app_setting_get --key=install_dir)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__amount() {
# Here we can imagine to have an API call to stripe to know the amount of donation during a month
local amount=200
# It's possible to change some properties of the question by overriding it:
if [ "$amount" -gt 100 ]; then
cat << EOF
style: success
value: $amount
ask:
en: A lot of donation this month: **$amount €**
EOF
else
cat << EOF
style: danger
value: $amount
ask:
en: Not so much donation this month: $amount €
EOF
fi
}
get__prices() {
local prices
prices="$(grep "DONATION\['" "$install_dir/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
if [ "$prices" == "," ]; then
# Return YNH_NULL if you prefer to not return a value at all.
echo YNH_NULL
else
echo "$prices"
fi
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
validate__publishable_key() {
# We can imagine here we test if the key is really a publishable key
(is_secret_key "$publishable_key") &&
echo 'This key seems to be a secret key'
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__prices() {
#---------------------------------------------
# IMPORTANT: setters are triggered only if a change is detected
#---------------------------------------------
for price in $(echo "$prices" | sed "s/,/ /"); do
frequency=$(echo "$price" | cut -d/ -f1)
currency=$(echo "$price" | cut -d/ -f2)
price_id=$(echo "$price" | cut -d/ -f3)
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$install_dir/settings.py"
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$install_dir/settings.py"
done
#---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to save the value in settings too
#---------------------------------------------
ynh_app_setting_set --key=prices --value="$prices"
}
#=================================================
ynh_app_config_run "$1"

View file

@ -7,52 +7,12 @@
source _common.sh
source /usr/share/yunohost/helpers
### Install parameters are automatically saved as settings
###
### Settings are automatically loaded as bash variables
### in every app script context, therefore typically these will exist:
### - $domain
### - $path
### - $language
### ... etc
###
### Resources defined in the manifest are provisioned prior to this script
### and corresponding settings are also available, such as:
### - $install_dir
### - $port
### - $db_name
### ...
###
### $app is the app id (i.e. 'example' for first install,
### or 'example__2', '__3'... for multi-instance installs)
#=================================================
# INITIALIZE AND STORE SETTINGS
#=================================================
# If you need to, you can define custom settings
# (or remove this section entirely if not relevant for you)
foo="bar"
ynh_app_setting_set --key=foo --value=$foo
ynh_app_setting_set --key=php_upload_max_filesize --value=50M
ynh_app_setting_set --key=php_post_max_size --value=50M
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "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 manifest.toml
# Download, check integrity, uncompress and patch the source from manifest.toml
ynh_setup_source --dest_dir="$install_dir"
### $install_dir will automatically be initialized with some decent
### permission by default... however, you may need to recursively reapply
### ownership to all files such as after the ynh_setup_source step
chown -R "$app:www-data" "$install_dir"
#=================================================
@ -60,140 +20,58 @@ chown -R "$app:www-data" "$install_dir"
#=================================================
ynh_script_progression "Adding $app's configuration files..."
### You can add specific configuration files.
###
### Typically, put your template conf file in ../conf/your_config_file
### The template may contain strings such as __FOO__ or __FOO_BAR__,
### which will automatically be replaced by the values of $foo and $foo_bar
###
### ynh_config_add will also keep track of the config file's checksum,
### which later during upgrade may allow to automatically backup the config file
### if it's found that the file was manually modified
###
### Check the documentation of `ynh_config_add` for more info.
ynh_config_add --template=.env --destination="$install_dir/.env"
ynh_config_add --template="some_config_file" --destination="$install_dir/some_config_file"
# FIXME: this should be handled by the core in the future
### You may need to use chmod 600 instead of 400,
### for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/some_config_file"
chown "$app:$app" "$install_dir/some_config_file"
### For more complex cases where you want to replace stuff using regexes,
### you shoud rely on ynh_replace (which is basically a wrapper for sed)
### When doing so, you also need to manually call ynh_store_file_checksum
###
### ynh_replace --match="match_string" --replace="replace_string" --file="$install_dir/some_config_file"
### ynh_store_file_checksum "$install_dir/some_config_file"
chmod 640 "$install_dir/.env"
chown "$app:www-data" "$install_dir/.env"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Adding system configurations related to $app..."
### `ynh_config_add_phpfpm` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
### `ynh_config_add_phpfpm` will use the files conf/extra_php-fpm.conf
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
### with the reload at the end of the script.
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
# Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it)
ynh_config_add_phpfpm
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_config_add_nginx
### `ynh_config_add_systemd` is used to configure a systemd script for an app.
### It can be used for apps that use sysvinit (with adaptation) or systemd.
### Have a look at the app to be sure this app needs a systemd script.
### `ynh_config_add_systemd` will use the file conf/systemd.service
### If you're not using these lines:
### - You can remove those files in conf/.
### - Remove the section "BACKUP SYSTEMD" in the backup script
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
### - As well as the section "RESTORE SYSTEMD" in the restore script
### - And the section "SETUP SYSTEMD" in the upgrade script
#=================================================
# INSTALL APP WITH COMPOSER
#=================================================
ynh_script_progression "Installing app with Composer..."
# Create a dedicated systemd config
ynh_config_add_systemd
ynh_composer_install
ynh_composer_exec install --no-dev
### `yunohost service add` integrates a service in YunoHost. It then gets
### displayed in the admin interface and through the others `yunohost service` commands.
### (N.B.: this line only makes sense if the app adds a service to the system!)
### If you're not using these lines:
### - You can remove these files in conf/.
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
#=================================================
# BUILDING
#=================================================
ynh_script_progression "configuring $app..."
### Additional options starting with 3.8:
###
### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed
### which will then be checked by YunoHost's diagnosis system
### (N.B. DO NOT USE THIS if the port is only internal!!!)
###
### --test_status "some command" a custom command to check the status of the service
### (only relevant if 'systemctl status' doesn't do a good job)
###
### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service
###
### Re-calling 'yunohost service add' during the upgrade script is the right way
### to proceed if you later realize that you need to enable some flags that
### weren't enabled on old installs (be careful it'll override the existing
### service though so you should re-provide all relevant flags when doing so)
yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log"
pushd "$install_dir"
"php$php_version" artisan key:generate -n --force --env
"php$php_version" artisan make:database $app
"php$php_version" artisan migrate:fresh --seed -n --force
"php$php_version" artisan config:clear -n
"php$php_version" artisan config:cache -n
popd
### `ynh_config_add_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app.
### If you're not using this helper:
### - Remove the section "BACKUP LOGROTATE" in the backup script
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
### - And the section "SETUP LOGROTATE" in the upgrade script
# Use logrotate to manage application logfile(s)
ynh_config_add_logrotate
# file was touched by artisan, create a new key (copy/paste from Lychee)
ynh_store_file_checksum "$install_dir/.env"
app_key=$(cat $install_dir/.env | grep -e ^APP_KEY | cut -c 9-)
ynh_app_setting_set --key=app_key --value=$app_key
# Create a dedicated Fail2Ban config
ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
# group only, make it www-data vs user/group $app:www-data
chgrp "www-data" -R "$install_dir/storage" "$install_dir/public"
chmod -R 2775 "$install_dir/storage" "$install_dir/app" "$install_dir/public" "$install_dir/bootstrap/"
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
### Use these lines only if the app installation needs to be finalized through
### web forms. We generally don't want to ask the final user,
### so we're going to use curl to automatically fill the fields and submit the
### forms.
# Installation with curl
ynh_script_progression "Finalizing installation..."
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
### `ynh_systemctl` is used to start a systemd service for an app.
### Only needed if you have configure a systemd service
### If you're not using these lines:
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
### - As well as the section "START SYSTEMD SERVICE" in the restore script
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
# Start a systemd service
ynh_systemctl --service="$app" --action="start"
# Installation with curl: set up the first/single user
ynh_local_curl "/INSTALL_PATH" "key1=$user" "key2=$email" "key3=$password" "key4=$password"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"

View file

@ -7,19 +7,6 @@
source _common.sh
source /usr/share/yunohost/helpers
### Settings are automatically loaded as bash variables
### in every app script context, therefore typically these will exist:
### - $domain
### - $path
### - $language
### - $install_dir
### - $port
### ...
### For remove operations:
### - the core will deprovision every resource defined in the manifest **after** this script is ran
### this includes removing the install directory, and data directory (if --purge was used)
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
@ -27,26 +14,8 @@ ynh_script_progression "Removing system configurations related to $app..."
### This should be a symetric version of what happens in the install script
ynh_config_remove_fail2ban
ynh_config_remove_logrotate
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
ynh_config_remove_systemd
ynh_config_remove_nginx
ynh_config_remove_phpfpm
# Remove other various files specific to the app... such as:
ynh_safe_rm "/etc/cron.d/$app"
ynh_safe_rm "/etc/$app"
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -15,21 +15,8 @@ ynh_script_progression "Restoring the app main directory..."
ynh_restore "$install_dir"
### $install_dir will automatically be initialized with some decent
### permissions by default... however, you may need to recursively reapply
### ownership to all files such as after the ynh_setup_source step
chown -R "$app:www-data" "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression "Restoring the data directory..."
ynh_restore "$data_dir"
### (Same as for install dir)
chown -R "$app:www-data" "$data_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
@ -42,47 +29,13 @@ ynh_mysql_db_shell < ./db.sql
#=================================================
ynh_script_progression "Restoring system configurations related to $app..."
### This should be a symetric version of what happens in the install script
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log"
ynh_restore "/etc/logrotate.d/$app"
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
ynh_systemctl --action=restart --service=fail2ban
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_restore "/etc/cron.d/$app"
ynh_restore "/etc/$app/"
### For apps with huge logs, you might want to not backup logs every time:
### The mkdir call is just here in case the log directory was not backed up.
### mkdir -p "/var/log/$app"
### chown $app:www-data "/var/log/$app"
### ynh_restore "/var/log/$app/" || true
###
### For other apps, the simple way is better:
ynh_restore "/var/log/$app/"
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression "Reloading NGINX web server and $app's service..."
### Typically you only have either $app or PHP-FPM but not both at the same time...
ynh_systemctl --service="$app" --action="start"
ynh_systemctl --service="php$php_version-fpm" --action=reload
ynh_systemctl --service=nginx --action=reload

View file

@ -63,6 +63,13 @@ ynh_setup_source --dest_dir="$install_dir" --full_replace --keep=".env data"
### ownership to all files such as after the ynh_setup_source step
chown -R "$app:www-data" "$install_dir"
#=================================================
# TODO - DB migration if applicable
#=================================================
ynh_script_progression "Migrating $app's database to the new data model..."
## find upstream migration script
#=================================================
# UPDATE A CONFIG FILE
#=================================================
@ -73,13 +80,14 @@ ynh_script_progression "Updating $app's configuration files..."
### The file will automatically be backed-up if it's found to be manually modified (because
### ynh_config_add keeps track of the file's checksum)
ynh_config_add --template="some_config_file" --destination="$install_dir/some_config_file"
#ynh_config_add --template="some_config_file" --destination="$install_dir/some_config_file"
# there's just the nginx conf and the .env that's still available (--keep above)
# FIXME: this should be handled by the core in the future
### You may need to use chmod 600 instead of 400,
### for example if the app is expected to be able to modify its own config
chmod 400 "$install_dir/some_config_file"
chown "$app:$app" "$install_dir/some_config_file"
#chmod 400 "$install_dir/some_config_file"
#chown "$app:$app" "$install_dir/some_config_file"
### For more complex cases where you want to replace stuff using regexes,
### you shoud rely on ynh_replace (which is basically a wrapper for sed)
@ -95,24 +103,9 @@ ynh_script_progression "Upgrading system configurations related to $app..."
### This should be a literal copypaste of what happened in the install's "System configuration" section
ynh_config_add_phpfpm
ynh_config_add_nginx
ynh_config_add_systemd
yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log"
ynh_config_add_logrotate
ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service="$app" --action="start"
#ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# END OF SCRIPT