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

Merge pull request #4 from YunoHost-Apps/example

Example
This commit is contained in:
yalh76 2021-03-18 20:13:41 +01:00 committed by GitHub
commit 800d11aba1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 124 additions and 97 deletions

View file

@ -9,13 +9,13 @@
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
Pepettes is a donation form working with stripe.
Pepettes is a donation form based on Stripe.
**Shipped version:** 1.0
## Screenshots
![](Link to a screenshot of this app.)
(none yet)
## Demo
@ -23,7 +23,7 @@ Pepettes is a donation form working with stripe.
## Configuration
How to configure this app: From an admin panel, a plain file with SSH, or any other way.
How to configure this app: During the installation, or in `settings.py` after installation.
## Documentation
@ -44,15 +44,15 @@ Can the app be used by multiple users? yes
## Limitations
* Any known limitations.
(none)
## Additional information
(none)
## Links
* Report a bug: https://github.com/YunoHost-Apps/pepettes_ynh/issues
* App website: -
* Upstream app repository: https://github.com/YunoHost/pepettes/
* YunoHost website: https://yunohost.org/
@ -60,7 +60,6 @@ Can the app be used by multiple users? yes
## 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/pepettes_ynh/tree/testing).
To try the testing branch, please proceed like that.

View file

@ -1,38 +1,24 @@
# 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
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
is_public=1 (PUBLIC|public=1|private=0)
project_name="YunoHost"
contact_url="https://forum.yunohost.org/t/donate-to-yunohost/9211"
logo="https://yunohost.org/user/images/logo.png"
favicon="https://yunohost.org/user/themes/yunohost-docs/images/favicon.png"
publishable_key="pk_test_gOgGjacs9YfvDJY03BRZ576O"
secret_key="sk_test_aaaaaaaaaaaaaaaaa"
prices="one_time/EUR/price_1IKuPV,recuring/EUR/price_1IKuPV"
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
is_public=1 (PUBLIC|public=1|private=0)
project_name="YunoHost"
contact_url="https://forum.yunohost.org/t/donate-to-yunohost/9211"
logo="https://yunohost.org/user/images/logo.png"
favicon="https://yunohost.org/user/themes/yunohost-docs/images/favicon.png"
publishable_key="pk_test_gOgGjacs9YfvDJY03BRZ576O"
secret_key="sk_test_aaaaaaaaaaaaaaaaa"
prices="one_time/EUR/price_1IKuPV,recuring/EUR/price_1IKuPV"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=CommitHash
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=CommitHash
name=Name and date of the commit.
manifest_arg=domain=DOMAIN&path=PATH

View file

@ -1,11 +1,11 @@
command = '__FINALPATH__/venv/bin/gunicorn'
pythonpath = '__FINALPATH__'
workers = 4
user = '__NAME__'
user = '__APP__'
bind = 'unix:__FINALPATH__/sock'
pid = '/run/gunicorn/__NAME__-pid'
errorlog = '/var/log/__NAME__/error.log'
accesslog = '/var/log/__NAME__/access.log'
pid = '__FINALPATH__/__APP__-pid'
errorlog = '/var/log/__APP__/error.log'
accesslog = '/var/log/__APP__/access.log'
access_log_format = '%({X-Real-IP}i)s %({X-Forwarded-For}i)s %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
loglevel = 'warning'
capture_output = True

View file

@ -1,13 +1,13 @@
[Unit]
Description=Small description of the service
Description=__APP__ Daemon
After=network.target
[Service]
PIDFile=/run/gunicorn/__APP__-pid
PIDFile=__FINALPATH__/__APP__-pid
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
ExecStart=__FINALPATH__/venv/bin/gunicorn -c __FINALPATH__/gunicorn.py wsgi:app
ExecStart=__FINALPATH__/venv/bin/gunicorn -c __FINALPATH__/gunicorn.py wsgi:app --pid __FINALPATH__/__APP__-pid
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true

View file

@ -32,16 +32,6 @@
},
"example": "example.com"
},
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for pepettes",
"fr": "Choisissez un chemin pour pepettes"
},
"example": "/donation",
"default": "/donation"
},
{
"name": "is_public",
"type": "boolean",

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
@ -51,8 +50,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
#=================================================
# BACKUP SYSTEMD
#=================================================

View file

@ -74,7 +74,7 @@ fi
#=================================================
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"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped"
#=================================================
# MODIFY URL IN NGINX CONF
@ -118,7 +118,8 @@ fi
#=================================================
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"
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started"
#=================================================
# RELOAD NGINX

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
@ -25,7 +24,7 @@ ynh_abort_if_errors
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
project_name=$YNH_APP_ARG_PROJECT_NAME
contact_url=$YNH_APP_ARG_CONTACT_URL
@ -108,25 +107,29 @@ ynh_add_nginx_config
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL PYTHON DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path
python3 -m venv venv
venv/bin/pip install -r requirements.txt
venv/bin/pip install gunicorn
mkdir -p /var/log/$app
chown -R $app:www-data /var/log/$app
cat <<EOF >> wsgi.py
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements.txt
venv/bin/pip install gunicorn
mkdir -p /var/log/$app
chown -R $app:www-data /var/log/$app
cat <<EOF >> wsgi.py
from server import app
if __name__ == "__main__":
app.run()
EOF
popd
#=================================================
#=================================================
# SETUP SYSTEMD
@ -139,17 +142,11 @@ ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/gunicorn.py" --destination="$final_path/gunicorn.py"
ynh_add_config --template="../conf/settings.py" --destination="$final_path/settings.py"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$final_path/gunicorn.py"
ynh_store_file_checksum --file="$final_path/settings.py"
for price in $(echo $prices | sed "s/,/ /"); do
frequency=$(echo $price | cut -d/ -f1)
currency=$(echo $price | cut -d/ -f2)
@ -162,19 +159,18 @@ done
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R root: $final_path
chown pepettes:root $final_path
chown pepettes:root $final_path/settings.py
chmod o=--- $final_path/settings.py
chown -R $app:www-data $final_path
chmod o=--- $final_path
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A simple donation form" --log="/var/log/$app/$app.log"
yunohost service add $app --description="A simple donation form" --log_type="systemd"
#=================================================
# START SYSTEMD SERVICE
@ -182,7 +178,7 @@ yunohost service add $app --description="A simple donation form" --log="/var/log
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started"
#=================================================
# SETUP SSOWAT

View file

@ -70,9 +70,10 @@ ynh_remove_nginx_config
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
# Remove the log files
#ynh_secure_remove --file="/var/log/$app/"
ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION

View file

@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
@ -24,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -47,6 +46,7 @@ test ! -d $final_path \
#=================================================
# 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"
@ -63,14 +63,7 @@ ynh_restore_file --origin_path="$final_path"
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown -R root: $final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SPECIFIC RESTORATION
@ -82,6 +75,29 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# INSTALL PYTHON DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements.txt
venv/bin/pip install gunicorn
mkdir -p /var/log/$app
chown -R $app:www-data /var/log/$app
popd
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app:www-data $final_path
chmod o=--- $final_path
#=================================================
# RESTORE SYSTEMD
#=================================================
@ -95,21 +111,21 @@ systemctl enable $app.service --quiet
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A simple donation form" --log="/var/log/$app/$app.log"
yunohost service add $app --description="A simple donation form" --log_type="systemd"
#=================================================
# 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"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -18,10 +18,23 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
project_name=$(ynh_app_setting_get --app=$app --key=project_name)
contact_url=$(ynh_app_setting_get --app=$app --key=contact_url)
logo=$(ynh_app_setting_get --app=$app --key=logo)
favicon=$(ynh_app_setting_get --app=$app --key=favicon)
publishable_key=$(ynh_app_setting_get --app=$app --key=publishable_key)
secret_key=$(ynh_app_setting_get --app=$app --key=secret_key)
prices=$(ynh_app_setting_get --app=$app --key=prices)
secret=$(ynh_app_setting_get --app=$app --key=secret)
csrf_key=$(ynh_app_setting_get --app=$app --key=csrf_key)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -51,7 +64,7 @@ ynh_abort_if_errors
#=================================================
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"
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -86,13 +99,29 @@ ynh_install_app_dependencies $pkg_dependencies
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
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
# UPGRADE PYTHON DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing Python dependencies..."
pushd $final_path
python3 -m venv venv
venv/bin/pip install --upgrade pip
venv/bin/pip install -r requirements.txt
venv/bin/pip install gunicorn
mkdir -p /var/log/$app
chown -R $app:www-data /var/log/$app
cat <<EOF >> wsgi.py
from server import app
if __name__ == "__main__":
app.run()
EOF
popd
#=================================================
# SETUP SYSTEMD
@ -105,30 +134,42 @@ ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..."
ynh_add_config --template="../conf/gunicorn.py" --destination="$final_path/gunicorn.py"
ynh_add_config --template="../conf/settings.py" --destination="$final_path/settings.py"
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)
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$final_path/settings.py"
done
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R root: $final_path
chown -R $app:www-data $final_path
chmod o=--- $final_path
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A simple donation form" --log="/var/log/$app/$app.log"
yunohost service add $app --description="A simple donation form" --log_type="systemd"
#=================================================
# 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"
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started"
#=================================================
# RELOAD NGINX