From 34949198e415517658a3e3c04fa8c66eb059f9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:39:48 +0100 Subject: [PATCH 01/22] v2 --- conf/app.src | 5 --- conf/systemd.service | 4 +-- manifest.toml | 54 +++++++++++++++++++++++++++++++++ scripts/_common.sh | 2 +- scripts/backup | 14 ++++----- scripts/change_url | 62 ++++++++++++++++++++------------------ scripts/install | 58 +++++++++++++++++------------------ scripts/remove | 22 +++++++------- scripts/restore | 40 ++++++++++++------------ scripts/upgrade | 72 ++++++++++++++++++++++---------------------- 10 files changed, 192 insertions(+), 141 deletions(-) delete mode 100644 conf/app.src create mode 100644 manifest.toml diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 186aba5..0000000 --- a/conf/app.src +++ /dev/null @@ -1,5 +0,0 @@ -SOURCE_URL=https://github.com/wasi-master/13ft/archive/refs/tags/v0.2.0.tar.gz -SOURCE_SUM=727fe845823b400d60a0b98656308773ef2c19898f6b9c249be7682b269d854a -SOURCE_SUM_PRG=sha256sum -SOURCE_EXTRACT=true -SOURCE_IN_SUBDIR=true diff --git a/conf/systemd.service b/conf/systemd.service index 4b748dc..89fcbd3 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,8 +6,8 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/venv/bin/python3 __FINALPATH__/index.py +WorkingDirectory=__INSTALL_DIR__/ +ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/index.py StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..3ba0b84 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,54 @@ +packaging_format = 2 + +id = "13ft" +name = "13ft" +description.en = "Bypass paywall by acting as GoogleBot" +description.fr = "Contourner les paywall en vous faisant passer pour GoogleBot" + +version = "0.2.0~ynh1" + +maintainers = ["Lapineige"] + +[upstream] +license = "MIT" +code = "https://github.com/wasi-master/13ft" +website = "https://github.com/wasi-master/13ft" +cpe = "???" # 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) +fund = "???" # 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. + +[integration] +yunohost = ">= 11.2" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # 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. +sso = "?" # 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. +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[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 = "/13ft" + + [install.init_main_permission] + type = "group" + default = "visitors" + +[resources] + [resources.sources.main] + url = "https://github.com/wasi-master/13ft/archive/refs/tags/v0.2.0.tar.gz" + sha256 = "727fe845823b400d60a0b98656308773ef2c19898f6b9c249be7682b269d854a" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index 3dc22d9..450d207 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES # dependencies used by the app (must be on a single line) -pkg_dependencies="python3-venv" +#REMOVEME? pkg_dependencies="python3-venv" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index dc4813b..ae8e15c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,22 +14,22 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? 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 -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -40,7 +40,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index b286df6..839d09a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,53 +13,53 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path=$YNH_APP_NEW_PATH -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? 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) +#REMOVEME? # Needed for helper "ynh_add_nginx_config" +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # 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 +#REMOVEME? 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 () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? 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" +#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then - change_path=1 + #REMOVEME? change_path=1 fi #================================================= @@ -76,28 +76,30 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config + +#REMOVEME? 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" +#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" +#REMOVEME? domain="$old_domain" +#REMOVEME? path="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config +#REMOVEME? 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 +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? 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" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -112,9 +114,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 3d3097c..59f4a37 100755 --- a/scripts/install +++ b/scripts/install @@ -13,77 +13,77 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? 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 -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +#REMOVEME? path=$YNH_APP_ARG_PATH +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +#REMOVEME? install_dir=/var/www/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # INSTALL APT DEPENDENCIES #================================================= -ynh_script_progression --message="Installing apt dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing apt dependencies..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Installing python dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing python dependencies..." --weight=1 -pushd $final_path +pushd $install_dir python3 -m venv venv venv/bin/pip install --upgrade pip venv/bin/pip install -r requirements.txt # should only be flask for now, but just in case @@ -129,22 +129,22 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary -if [ $is_public -eq 1 ] +#REMOVEME? if [ $is_public -eq 1 ] then # Everyone can access the app. # The "main" permission is automatically created before the install script. - ynh_permission_update --permission="main" --add="visitors" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 8b18014..3b9dbdb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,13 +12,13 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) #================================================= # STANDARD REMOVE @@ -44,10 +44,10 @@ ynh_remove_systemd_config #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" ynh_secure_remove --file=/var/log/$app @@ -62,20 +62,20 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing apt dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing apt dependencies..." --weight=1 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 2866f2c..bebe63c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,48 +14,48 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? 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 -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? 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) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions @@ -63,26 +63,26 @@ ynh_restore_file --origin_path="$final_path" # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling apt dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reinstalling apt dependencies..." --weight=1 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling Python dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reinstalling Python dependencies..." --weight=1 -pushd $final_path +pushd $install_dir python3 -m venv venv venv/bin/pip install --upgrade pip venv/bin/pip install -r requirements.txt # should only be flask for now, but just in case diff --git a/scripts/upgrade b/scripts/upgrade index 43d78e6..205daea 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,16 +12,16 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -language=$(ynh_app_setting_get --app=$app --key=language) -admin=$(ynh_app_setting_get --app=$app --key=admin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # CHECK VERSION @@ -32,16 +32,16 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -66,42 +66,42 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If db_name doesn't exist, create it #if [ -z "$db_name" ]; then # db_name=$(ynh_sanitize_dbid --db_name=$app) -# ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? # ynh_app_setting_set --app=$app --key=db_name --value=$db_name #fi -# If final_path doesn't exist, create it -#if [ -z "$final_path" ]; then -# final_path=/var/www/$app -# ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# If install_dir doesn't exist, create it +#if [ -z "$install_dir" ]; then +# install_dir=/var/www/$app +#REMOVEME? # ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir #fi ### If nobody installed your app before 4.1, ### then you may safely remove these lines # Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all +#REMOVEME? if ynh_legacy_permissions_exists; then +#REMOVEME? ynh_legacy_permissions_delete_all ynh_app_setting_delete --app=$app --key=is_public fi -if ! ynh_permission_exists --permission="admin"; then +#REMOVEME? if ! ynh_permission_exists --permission="admin"; then # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin +#REMOVEME? ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin fi # Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" +#REMOVEME? if ! ynh_permission_exists --permission="api"; then +#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +#REMOVEME? 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 --home_dir="$final_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -112,27 +112,27 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= -ynh_script_progression --message="Installing python dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Installing python dependencies..." --weight=1 -pushd $final_path +pushd $install_dir python3 -m venv venv venv/bin/pip install --upgrade pip venv/bin/pip install -r requirements.txt # should only be flask for now, but just in case @@ -190,9 +190,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT From 444d77905fea401840518c9cf6bab2630c4de9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:46:28 +0100 Subject: [PATCH 02/22] v2 --- .github/workflows/updater.sh | 137 ----------------------------------- conf/nginx.conf | 2 +- conf/systemd.service | 2 +- doc/DISCLAIMER.md | 1 - manifest.json | 45 ------------ manifest.toml | 32 ++++---- scripts/_common.sh | 4 +- scripts/change_url | 84 --------------------- scripts/install | 93 +----------------------- scripts/remove | 47 ------------ scripts/restore | 85 ---------------------- scripts/upgrade | 114 +---------------------------- 12 files changed, 24 insertions(+), 622 deletions(-) delete mode 100755 .github/workflows/updater.sh delete mode 100644 doc/DISCLAIMER.md delete mode 100644 manifest.json diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100755 index 72eb5cb..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -# Remove this exit command when you are ready to run this Action -exit 1 - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -echo "REPO=$repo" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi - -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do - -echo "Handling asset at $asset_url" - -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - *"admin"*) - src="app" - ;; - *"update"*) - src="app-upgrade" - ;; - *) - src="" - ;; -esac - -# If $src is not empty, let's process the asset -if [ ! -z "$src" ]; then - -# Create the temporary directory -tempdir="$(mktemp -d)" - -# Download sources and calculate checksum -filename=${asset_url##*/} -curl --silent -4 -L $asset_url -o "$tempdir/$filename" -checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory -rm -rf $tempdir - -# Get extension -if [[ $filename == *.tar.gz ]]; then - extension=tar.gz -else - extension=${filename##*.} -fi - -# Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -EOT -echo "... conf/$src.src updated" - -else -echo "... asset ignored" -fi - -done - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/conf/nginx.conf b/conf/nginx.conf index 8ce80ba..2a9a08b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - proxy_pass http://127.0.0.1:5000; + proxy_pass http://127.0.0.1:__PORT__; proxy_set_header Host $host; more_set_headers "X-Frame-Options: ALLOWALL"; diff --git a/conf/systemd.service b/conf/systemd.service index 89fcbd3..2f4a85e 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=13ft launcher service +Description=13ft: launcher service After=network.target [Service] diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 8b13789..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/manifest.json b/manifest.json deleted file mode 100644 index a811d84..0000000 --- a/manifest.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "13ft", - "id": "13ft", - "packaging_format": 1, - "description": { - "en": "Bypass paywall by acting as GoogleBot", - "fr": "Contourner les paywall en vous faisant passer pour GoogleBot" - }, - "version": "0.2.0~ynh1", - "url": "https://github.com/wasi-master/13ft", - "upstream": { - "license": "MIT", - "code": "https://github.com/wasi-master/13ft" - }, - "license": "MIT", - "maintainer": { - "name": "Lapineige" - }, - "requirements": { - "yunohost": ">= 11.2" - }, - "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/13ft", - "default": "/13ft" - }, - { - "name": "is_public", - "type": "boolean", - "default": true - } - ] - } -} diff --git a/manifest.toml b/manifest.toml index 3ba0b84..1cfd415 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "13ft" description.en = "Bypass paywall by acting as GoogleBot" description.fr = "Contourner les paywall en vous faisant passer pour GoogleBot" -version = "0.2.0~ynh1" +version = "0.2.3~ynh1" maintainers = ["Lapineige"] @@ -13,26 +13,25 @@ maintainers = ["Lapineige"] license = "MIT" code = "https://github.com/wasi-master/13ft" website = "https://github.com/wasi-master/13ft" -cpe = "???" # 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) -fund = "???" # 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. [integration] yunohost = ">= 11.2" -architectures = "all" # 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 -ldap = "?" # 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. -sso = "?" # 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. -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +ldap = false + +sso = false + +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" [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 = "/13ft" @@ -42,13 +41,18 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources] [resources.sources.main] - url = "https://github.com/wasi-master/13ft/archive/refs/tags/v0.2.0.tar.gz" - sha256 = "727fe845823b400d60a0b98656308773ef2c19898f6b9c249be7682b269d854a" - + url = "https://github.com/wasi-master/13ft/archive/refs/tags/v0.2.3.tar.gz" + sha256 = "d03abfded671fad157a883e348a7c5a2f21b251a592317f8208c9fc190ecbfde" + autoupdate.strategy = "latest_github_tag" [resources.system_user] [resources.install_dir] + [resources.ports] + [resources.permissions] main.url = "/" + + [resources.apt] + packages = "python3-venv" diff --git a/scripts/_common.sh b/scripts/_common.sh index 450d207..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,9 +2,7 @@ #================================================= # COMMON VARIABLES - -# dependencies used by the app (must be on a single line) -#REMOVEME? pkg_dependencies="python3-venv" +#================================================= #================================================= # PERSONAL HELPERS diff --git a/scripts/change_url b/scripts/change_url index 839d09a..ae914ad 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,59 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path=$YNH_APP_NEW_PATH - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? # Needed for helper "ynh_add_nginx_config" -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? 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 -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -78,30 +25,6 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -#REMOVEME? 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 -#REMOVEME? ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper -#REMOVEME? domain="$old_domain" -#REMOVEME? path="$new_path" - # Create a dedicated NGINX config -#REMOVEME? 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 -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # GENERIC FINALISATION #================================================= @@ -111,13 +34,6 @@ 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 -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 59f4a37..2326298 100755 --- a/scripts/install +++ b/scripts/install @@ -9,79 +9,20 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? 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 -#REMOVEME? ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -#REMOVEME? path=$YNH_APP_ARG_PATH -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 - -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 - -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -# Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# INSTALL APT DEPENDENCIES +# INSTALL PYTHON DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing apt dependencies..." --weight=1 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# INSTALL PYTHON DEPENDENCIES -#================================================= - -#REMOVEME? ynh_script_progression --message="Installing python dependencies..." --weight=1 +ynh_script_progression --message="Installing python dependencies..." --weight=1 pushd $install_dir python3 -m venv venv @@ -98,11 +39,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - if [ ! -d /var/log/$app ]; then mkdir /var/log/$app fi @@ -111,11 +47,6 @@ fi # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" #================================================= @@ -126,26 +57,6 @@ 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" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary -#REMOVEME? if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 3b9dbdb..6bd5329 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,17 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) - #================================================= # STANDARD REMOVE #================================================= @@ -33,50 +22,14 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - ynh_secure_remove --file=/var/log/$app -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing apt dependencies..." --weight=1 - -# Remove metapackage and its dependencies -#REMOVEME? ynh_remove_app_dependencies - -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index bebe63c..4878f90 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,46 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? 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 -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -57,37 +17,9 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling apt dependencies..." --weight=1 - -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# INSTALL PYTHON DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling Python dependencies..." --weight=1 - -pushd $install_dir - python3 -m venv venv - venv/bin/pip install --upgrade pip - venv/bin/pip install -r requirements.txt # should only be flask for now, but just in case -popd - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -95,19 +27,9 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" #================================================= @@ -117,13 +39,6 @@ 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" -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 205daea..8780028 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,40 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) -#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language) -#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) - #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -52,57 +24,6 @@ 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" -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# -# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* -# of what you may want to do in some cases (e.g. a setting was not defined on -# some legacy installs and you therefore want to initiaze stuff during upgrade) -# - -# If db_name doesn't exist, create it -#if [ -z "$db_name" ]; then -# db_name=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? # ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#fi - -# If install_dir doesn't exist, create it -#if [ -z "$install_dir" ]; then -# install_dir=/var/www/$app -#REMOVEME? # ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir -#fi - -### If nobody installed your app before 4.1, -### then you may safely remove these lines - -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#REMOVEME? if ! ynh_permission_exists --permission="admin"; then - # Create the required permissions -#REMOVEME? ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin -fi - -# Create a permission if needed -#REMOVEME? if ! ynh_permission_exists --permission="api"; then -#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -111,26 +32,16 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 - # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" fi -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - #================================================= # INSTALL PYTHON DEPENDENCIES #================================================= - -#REMOVEME? ynh_script_progression --message="Installing python dependencies..." --weight=1 +ynh_script_progression --message="Installing python dependencies..." --weight=1 pushd $install_dir python3 -m venv venv @@ -147,10 +58,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC UPGRADE -#================================================= - #================================================= # SETUP SYSTEMD #================================================= @@ -163,21 +70,9 @@ fi # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" #================================================= @@ -187,13 +82,6 @@ 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 -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= From 77a104ad380026d022908a9d838d07820b423d38 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 2 Jan 2024 13:46:33 +0000 Subject: [PATCH 03/22] Auto-update README --- README.md | 7 ++----- README_fr.md | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3c33388..a516284 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,10 @@ https://github.com/wasi-master/13ft - Provide *some* web articles that are normally protected by paywalls. -**Shipped version:** 0.2.0~ynh1 -## Disclaimers / important information - - - +**Shipped version:** 0.2.3~ynh1 ## Documentation and resources +* Official app website: * Upstream app code repository: * YunoHost Store: * Report a bug: diff --git a/README_fr.md b/README_fr.md index 75115dd..4340541 100644 --- a/README_fr.md +++ b/README_fr.md @@ -23,13 +23,10 @@ https://github.com/wasi-master/13ft - Provide *some* web articles that are normally protected by paywalls. -**Version incluse :** 0.2.0~ynh1 -## Avertissements / informations importantes - - - +**Version incluse :** 0.2.3~ynh1 ## Documentations et ressources +* Site officiel de l’app : * Dépôt de code officiel de l’app : * YunoHost Store: * Signaler un bug : From a1d64adad3b49c979c2f9a857cb495d8a0a07e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:49:15 +0100 Subject: [PATCH 04/22] v2 --- check_process | 34 ---------------------------------- scripts/backup | 21 --------------------- scripts/change_url | 4 ++-- scripts/install | 11 ++--------- scripts/remove | 6 +----- scripts/restore | 5 ++--- scripts/upgrade | 13 ++----------- tests.toml | 3 +++ 8 files changed, 12 insertions(+), 85 deletions(-) delete mode 100644 check_process create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index 2bffd5c..0000000 --- a/check_process +++ /dev/null @@ -1,34 +0,0 @@ -# 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" - path="/path" - is_public=1 - language="fr" - admin="john" - password="1Strong-Password" - port="666" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - #upgrade=1 from_commit=CommitHash - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666& diff --git a/scripts/backup b/scripts/backup index ae8e15c..7189d8c 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? 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 -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url index ae914ad..3a9b28d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers #================================================= 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" #================================================= # MODIFY URL IN NGINX CONF @@ -32,7 +32,7 @@ ynh_change_url_nginx_config #================================================= 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" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 2326298..531183b 100755 --- a/scripts/install +++ b/scripts/install @@ -36,18 +36,11 @@ popd #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -# Create a dedicated NGINX config ynh_add_nginx_config -if [ ! -d /var/log/$app ]; then - mkdir /var/log/$app -fi - - -# Create a dedicated systemd config ynh_add_systemd_config -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -55,7 +48,7 @@ yunohost service add $app --description="A short description of the app" --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" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 6bd5329..3bfbdf7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -14,20 +14,16 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 -# 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 then ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi -# Remove the dedicated systemd config ynh_remove_systemd_config -ynh_secure_remove --file=/var/log/$app - -# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= diff --git a/scripts/restore b/scripts/restore index 4878f90..28aee4c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -30,14 +29,14 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/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" +yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$app.log" #================================================= # 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" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 8780028..2d3d1b6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,29 +58,20 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 - -if [ ! -d /var/log/$app ]; then - mkdir /var/log/$app -fi - # Create a dedicated systemd config ynh_add_systemd_config # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$app.log" #================================================= # 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" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..eb73b8d --- /dev/null +++ b/tests.toml @@ -0,0 +1,3 @@ +test_format = 1.0 + +[default] \ No newline at end of file From 08937000c79e677b7b5498081f6f640012bfa00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:54:24 +0100 Subject: [PATCH 05/22] v2 --- manifest.toml | 2 +- scripts/install | 28 ++++++++++++++-------------- scripts/restore | 2 +- scripts/upgrade | 26 +++++++++++++------------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/manifest.toml b/manifest.toml index 1cfd415..ec13810 100644 --- a/manifest.toml +++ b/manifest.toml @@ -55,4 +55,4 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "python3-venv" + packages = "python3-venv, python3, python3-pip" diff --git a/scripts/install b/scripts/install index 531183b..1980dca 100755 --- a/scripts/install +++ b/scripts/install @@ -20,21 +20,9 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# INSTALL PYTHON DEPENDENCIES +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Installing python dependencies..." --weight=1 - -pushd $install_dir - python3 -m venv venv - venv/bin/pip install --upgrade pip - venv/bin/pip install -r requirements.txt # should only be flask for now, but just in case - venv/bin/pip install requests -popd - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 ynh_add_nginx_config @@ -42,6 +30,18 @@ ynh_add_systemd_config yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$app.log" +#================================================= +# INSTALL PYTHON DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing python dependencies..." --weight=1 + +pushd $install_dir + ynh_exec_as $app python3 -m venv $final_path/venv + ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip + ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt + ynh_exec_as $app "$install_dir/venv/bin/pip" install requests +popd + #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/restore b/scripts/restore index 28aee4c..ec987b6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -22,7 +22,7 @@ chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 2d3d1b6..f52ec0b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,22 +38,10 @@ fi chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# INSTALL PYTHON DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing python dependencies..." --weight=1 - -pushd $install_dir - python3 -m venv venv - venv/bin/pip install --upgrade pip - venv/bin/pip install -r requirements.txt # should only be flask for now, but just in case - venv/bin/pip install requests -popd - #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -66,6 +54,18 @@ ynh_use_logrotate --non-append yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$app.log" +#================================================= +# INSTALL PYTHON DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing python dependencies..." --weight=1 + +pushd $install_dir + ynh_exec_as $app python3 -m venv $final_path/venv + ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip + ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt + ynh_exec_as $app "$install_dir/venv/bin/pip" install requests +popd + #================================================= # START SYSTEMD SERVICE #================================================= From 021b96fc7efd2dcc61ed97d10760cb921c7598d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:56:25 +0100 Subject: [PATCH 06/22] Update manifest.toml --- manifest.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index ec13810..62f19ab 100644 --- a/manifest.toml +++ b/manifest.toml @@ -12,7 +12,6 @@ maintainers = ["Lapineige"] [upstream] license = "MIT" code = "https://github.com/wasi-master/13ft" -website = "https://github.com/wasi-master/13ft" [integration] yunohost = ">= 11.2" From b37d580ea3b59208020ecac012a3a402ea6613ef Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 2 Jan 2024 13:56:29 +0000 Subject: [PATCH 07/22] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index a516284..2270348 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ https://github.com/wasi-master/13ft **Shipped version:** 0.2.3~ynh1 ## Documentation and resources -* Official app website: * Upstream app code repository: * YunoHost Store: * Report a bug: diff --git a/README_fr.md b/README_fr.md index 4340541..5259743 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,7 +26,6 @@ https://github.com/wasi-master/13ft **Version incluse :** 0.2.3~ynh1 ## Documentations et ressources -* Site officiel de l’app : * Dépôt de code officiel de l’app : * YunoHost Store: * Signaler un bug : From 971ec066ed6578dcd0831c0b360ee1dc745e49c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:57:32 +0100 Subject: [PATCH 08/22] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 1980dca..d95ba7a 100755 --- a/scripts/install +++ b/scripts/install @@ -36,7 +36,7 @@ yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$a ynh_script_progression --message="Installing python dependencies..." --weight=1 pushd $install_dir - ynh_exec_as $app python3 -m venv $final_path/venv + ynh_exec_as $app python3 -m venv $install_dir/venv ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt ynh_exec_as $app "$install_dir/venv/bin/pip" install requests From 93180d97872888356ec651bc09562d2e1fa5e1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:05:13 +0100 Subject: [PATCH 09/22] fix --- conf/nginx.conf | 11 ++++++++++- scripts/install | 1 - scripts/upgrade | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 2a9a08b..3747ff0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,16 @@ location __PATH__/ { proxy_pass http://127.0.0.1:__PORT__; - proxy_set_header Host $host; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + 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_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; more_set_headers "X-Frame-Options: ALLOWALL"; # Include SSOWAT user panel. diff --git a/scripts/install b/scripts/install index d95ba7a..5eb1128 100755 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,6 @@ pushd $install_dir ynh_exec_as $app python3 -m venv $install_dir/venv ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt - ynh_exec_as $app "$install_dir/venv/bin/pip" install requests popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f52ec0b..d246afd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -63,7 +63,6 @@ pushd $install_dir ynh_exec_as $app python3 -m venv $final_path/venv ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt - ynh_exec_as $app "$install_dir/venv/bin/pip" install requests popd #================================================= From a4bd9397809dbd3c0be790efb3c3f9ced51d5ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:06:43 +0100 Subject: [PATCH 10/22] Update manifest.toml --- manifest.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.toml b/manifest.toml index 62f19ab..6fe0a38 100644 --- a/manifest.toml +++ b/manifest.toml @@ -49,6 +49,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.ports] + main.default = 5000 [resources.permissions] main.url = "/" From d6cd9922fddabbe1e07bedef285b88d330b26db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:35:13 +0100 Subject: [PATCH 11/22] Update manifest.toml --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 6fe0a38..8d39d4f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -55,4 +55,4 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "python3-venv, python3, python3-pip" + packages = "python3-venv" From e965b44025ae397248f49db7d40560e63a13b151 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sat, 6 Jan 2024 18:22:11 +0100 Subject: [PATCH 12/22] Update scripts/upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d246afd..f9817c6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -60,7 +60,7 @@ yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$a ynh_script_progression --message="Installing python dependencies..." --weight=1 pushd $install_dir - ynh_exec_as $app python3 -m venv $final_path/venv + ynh_exec_as $app python3 -m venv $install_dir/venv ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt popd From cd10f499b3ed7fa3b399d2c39209bec0be8e02d4 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sat, 6 Jan 2024 18:22:22 +0100 Subject: [PATCH 13/22] Update scripts/install: tmp debug --- scripts/install | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/install b/scripts/install index 5eb1128..e978177 100755 --- a/scripts/install +++ b/scripts/install @@ -41,6 +41,12 @@ pushd $install_dir ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt popd +# Tmp debug ... +ls -l $install_dir +ls -l $install_dir/venv/ +ls -l $install_dir/venv/bin/ +ls -l $install_dir/venv/bin/python3 + #================================================= # START SYSTEMD SERVICE #================================================= From 6a640997a13281a821320f6f7c8cb4ebe601692d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:13:50 +0100 Subject: [PATCH 14/22] Update conf/systemd.service --- conf/systemd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index 2f4a85e..8a1f78b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/index.py +ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/app/index.py StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit From fd437a62acb125c7ee3fc068a7f65958b907c756 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:14:06 +0100 Subject: [PATCH 15/22] Update install: remove tmp debug --- scripts/install | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/install b/scripts/install index e978177..5eb1128 100755 --- a/scripts/install +++ b/scripts/install @@ -41,12 +41,6 @@ pushd $install_dir ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt popd -# Tmp debug ... -ls -l $install_dir -ls -l $install_dir/venv/ -ls -l $install_dir/venv/bin/ -ls -l $install_dir/venv/bin/python3 - #================================================= # START SYSTEMD SERVICE #================================================= From 99f5a4e661ff0d37c5f87ebd4ad4b7d0102adde0 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:55:44 +0100 Subject: [PATCH 16/22] zgrmbl --- scripts/install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/install b/scripts/install index 5eb1128..dac0303 100755 --- a/scripts/install +++ b/scripts/install @@ -41,6 +41,10 @@ pushd $install_dir ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt popd +ls -l $install_dir +ls -l $install_dir/app +ls -l $install_dir/app/index.py + #================================================= # START SYSTEMD SERVICE #================================================= From 0973ada50d94ec992917128ddf8ff138704d1592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 15 Feb 2024 10:39:33 +0100 Subject: [PATCH 17/22] fix --- conf/systemd.service | 2 -- manifest.toml | 2 +- scripts/install | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 8a1f78b..6d5cac9 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,8 +8,6 @@ User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ ExecStart=__INSTALL_DIR__/venv/bin/python3 __INSTALL_DIR__/app/index.py -StandardOutput=append:/var/log/__APP__/__APP__.log -StandardError=inherit # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these diff --git a/manifest.toml b/manifest.toml index 8d39d4f..0824322 100644 --- a/manifest.toml +++ b/manifest.toml @@ -55,4 +55,4 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "python3-venv" + packages = "python3-venv, python3-pip" diff --git a/scripts/install b/scripts/install index dac0303..f861aca 100755 --- a/scripts/install +++ b/scripts/install @@ -35,10 +35,10 @@ yunohost service add $app --description="Bypass paywall" --log="/var/log/$app/$a #================================================= ynh_script_progression --message="Installing python dependencies..." --weight=1 -pushd $install_dir - ynh_exec_as $app python3 -m venv $install_dir/venv - ynh_exec_as $app "$install_dir/venv/bin/pip" install --upgrade pip - ynh_exec_as $app "$install_dir/venv/bin/pip" install -r requirements.txt +pushd "$install_dir" + python3 -m venv venv + venv/bin/pip install --upgrade pip + venv/bin/pip install -r requirements.txt popd ls -l $install_dir From d951e9a9198c2786a8cf22f4e087e2978cc9b56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 15 Feb 2024 10:41:29 +0100 Subject: [PATCH 18/22] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index f9817c6..3c5e294 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= 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" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE From 995c27388774248ceb0367815b7c81c9f140465e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 15 Feb 2024 10:48:26 +0100 Subject: [PATCH 19/22] Add fr --- doc/DESCRIPTION.md | 1 - doc/DESCRIPTION_fr.md | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 doc/DESCRIPTION_fr.md diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 9c97e54..ab24b6b 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,5 +1,4 @@ 13ft is an [12ft ladder](https://12ft.io) selfhosted alternative that allows you to bypass some paywalls and read the article content anyway. -https://github.com/wasi-master/13ft ### Features - Provide *some* web articles that are normally protected by paywalls. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..043e01c --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1,4 @@ +13ft est une alternative auto-hébergée de [12ft ladder](https://12ft.io) qui vous permet de contourner certains paywalls et de lire quand même le contenu de l'article. + +### Caractéristiques +- Fournissez *quelques* articles Web qui sont normalement protégés par des paywalls. \ No newline at end of file From 79a55e062919a415dbcb780494c1068d7ff616fa Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 15 Feb 2024 09:48:30 +0000 Subject: [PATCH 20/22] Auto-update README --- README.md | 1 - README_fr.md | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2270348..fa2e38a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview 13ft is an [12ft ladder](https://12ft.io) selfhosted alternative that allows you to bypass some paywalls and read the article content anyway. -https://github.com/wasi-master/13ft ### Features - Provide *some* web articles that are normally protected by paywalls. diff --git a/README_fr.md b/README_fr.md index 5259743..34c9394 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,12 +16,10 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -13ft is an [12ft ladder](https://12ft.io) selfhosted alternative that allows you to bypass some paywalls and read the article content anyway. -https://github.com/wasi-master/13ft - -### Features -- Provide *some* web articles that are normally protected by paywalls. +13ft est une alternative auto-hébergée de [12ft ladder](https://12ft.io) qui vous permet de contourner certains paywalls et de lire quand même le contenu de l'article. +### Caractéristiques +- Fournissez *quelques* articles Web qui sont normalement protégés par des paywalls. **Version incluse :** 0.2.3~ynh1 ## Documentations et ressources From a18341a9f86d6c4b18ee94a40d276fb29bd976b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 15 Feb 2024 10:51:16 +0100 Subject: [PATCH 21/22] remove sudir install --- manifest.toml | 4 ---- tests.toml | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/manifest.toml b/manifest.toml index 0824322..b633888 100644 --- a/manifest.toml +++ b/manifest.toml @@ -30,10 +30,6 @@ ram.runtime = "50M" [install.domain] type = "domain" - [install.path] - type = "path" - default = "/13ft" - [install.init_main_permission] type = "group" default = "visitors" diff --git a/tests.toml b/tests.toml index eb73b8d..882baca 100644 --- a/tests.toml +++ b/tests.toml @@ -1,3 +1,9 @@ test_format = 1.0 -[default] \ No newline at end of file +[default] + + # ------------------------------------------------------------------------------- + # EVERYTHING PAST THIS POINT IS OPTIONAL AND MOST LIKELY UNNECESSARY FOR NEW APPS + #-------------------------------------------------------------------------------- + + exclude = ["install.subdir"] \ No newline at end of file From 21efe7c096a8ce85f4cd5439ecbcb247882a583f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:58:03 +0100 Subject: [PATCH 22/22] remove multi --- manifest.toml | 2 +- tests.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index b633888..a1ba266 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,7 @@ code = "https://github.com/wasi-master/13ft" [integration] yunohost = ">= 11.2" architectures = "all" -multi_instance = true +multi_instance = false ldap = false diff --git a/tests.toml b/tests.toml index 882baca..534f43c 100644 --- a/tests.toml +++ b/tests.toml @@ -6,4 +6,4 @@ test_format = 1.0 # EVERYTHING PAST THIS POINT IS OPTIONAL AND MOST LIKELY UNNECESSARY FOR NEW APPS #-------------------------------------------------------------------------------- - exclude = ["install.subdir"] \ No newline at end of file + exclude = ["install.subdir", "install.multi"] \ No newline at end of file