From 68c33bb04837bf9126dd4599ff82038fe9c5da1a Mon Sep 17 00:00:00 2001 From: JimboJoe Date: Thu, 27 Feb 2020 20:59:48 +0100 Subject: [PATCH 1/3] Upgrade to upstream version 2020-02-26 (#19) --- README.md | 2 +- manifest.json | 2 +- scripts/_common.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3a58e50..f187068 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ rss-bridge for Yunohost This is a rss-bridge package for YunoHost. -**Shipped version:** 2019-12-01 +**Shipped version:** 2020-02-26 [rss-bridge](https://github.com/RSS-Bridge/rss-bridge) is a PHP project capable of generating ATOM feeds for websites which don't have one. diff --git a/manifest.json b/manifest.json index bc5c58d..f985be0 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ }, "url": "https://github.com/RSS-Bridge/rss-bridge", "license": "Unlicense", - "version": "2019-12-01~ynh2", + "version": "2020-02-26~ynh1", "maintainer": { "name": "JimboJoe", "email": "jimmy@monin.net" diff --git a/scripts/_common.sh b/scripts/_common.sh index fe071c8..d706d3d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,13 +3,13 @@ # # Package version -VERSION="8697e1e1a26c5b8c1dca284bd3b46b517063a9f2" +VERSION="2020-02-26" # Full sources tarball URL SOURCE_URL="https://github.com/RSS-Bridge/rss-bridge/archive/${VERSION}.tar.gz" # Full sources tarball checksum -SOURCE_SHA256="1f8314dc665b0aa23492b7f73e7f5c861408de18260d1de29fb18852c44891af" +SOURCE_SHA256="f4dd0dc07828cca0c533eb112134f2a29efe1e083d2e92f4c474e961af62b391" # App package root directory should be the parent folder PKGDIR=$(cd ../; pwd) From bdd2a98b53962f6ae2c3e65f6bbe6be401689e77 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 31 Mar 2020 05:07:19 +0200 Subject: [PATCH 2/3] Cleaning of the package, use more modern practices --- manifest.json | 4 ++-- scripts/_common.sh | 31 ------------------------------- scripts/backup | 4 ++-- scripts/install | 24 +++++++++++++----------- scripts/restore | 22 ++++++++++++---------- scripts/upgrade | 16 ++++++++-------- 6 files changed, 37 insertions(+), 64 deletions(-) diff --git a/manifest.json b/manifest.json index f985be0..36a9d44 100644 --- a/manifest.json +++ b/manifest.json @@ -8,14 +8,14 @@ }, "url": "https://github.com/RSS-Bridge/rss-bridge", "license": "Unlicense", - "version": "2020-02-26~ynh1", + "version": "2020-02-26~ynh2", "maintainer": { "name": "JimboJoe", "email": "jimmy@monin.net" }, "multi_instance": true, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.7" }, "services": [ "nginx", diff --git a/scripts/_common.sh b/scripts/_common.sh index d706d3d..c2656dd 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -63,10 +63,6 @@ WARNING () { # Print on error output $@ >&2 } -QUIET () { # redirect standard output to /dev/null - $@ > /dev/null -} - CHECK_SIZE () { # Check if enough disk space available on backup storage file_to_analyse=$1 backup_size=$(sudo du --summarize "$file_to_analyse" | cut -f1) @@ -80,32 +76,5 @@ CHECK_SIZE () { # Check if enough disk space available on backup storage fi } -CHECK_USER () { # Check user validity -# $1 = User - ynh_user_exists "$1" || ynh_die "Wrong user" -} -CHECK_DOMAINPATH () { # Check domain/path availability - sudo yunohost app checkurl $domain$path_url -a $app -} -CHECK_FINALPATH () { # Check if destination directory already exists - final_path="/var/www/$app" - test ! -e "$final_path" || ynh_die "This path already contains a folder" -} - -#================================================= -# FUTURE YUNOHOST HELPERS - TO BE REMOVED LATER -#================================================= - -# Normalize the url path syntax -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: file - The file for which the checksum will be deleted -ynh_delete_file_checksum () { - local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} diff --git a/scripts/backup b/scripts/backup index 02b2865..272454e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,8 +6,8 @@ if [ ! -e _common.sh ]; then # Fetch helpers file if not in current directory - sudo cp ../settings/scripts/_common.sh ./_common.sh - sudo chmod a+rx _common.sh + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh fi source _common.sh source /usr/share/yunohost/helpers diff --git a/scripts/install b/scripts/install index f06a1f6..a9dc8b5 100644 --- a/scripts/install +++ b/scripts/install @@ -30,9 +30,11 @@ path_url=$YNH_APP_ARG_PATH # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -path_url=$(ynh_normalize_url_path $path_url) # Check and normalize path -CHECK_DOMAINPATH # Check domain and path availability -CHECK_FINALPATH # Check if destination directory is not already in use +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" + +# Register (book) web path +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST @@ -65,16 +67,16 @@ ynh_system_user_create $app # Create a dedicated system user #================================================= # Install files and set permissions -sudo mv "$TMPDIR" "$final_path" +mv "$TMPDIR" "$final_path" # Set rights on directory -sudo chown -R root: $final_path -sudo chown -R $app: $final_path/cache -sudo chmod 755 $final_path +chown -R root: $final_path +chown -R $app: $final_path/cache +chmod 755 $final_path # Enable every bridge for i in $final_path/bridges/*.php ; do - echo $(basename $i) | sed "s|Bridge.php$||g" | sudo tee -a $final_path/whitelist.txt + echo $(basename $i) | sed "s|Bridge.php$||g" | tee -a $final_path/whitelist.txt done #================================================= @@ -89,7 +91,7 @@ phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" ynh_replace_string "{POOLNAME}" "${app}" "$PKGDIR/conf/php-fpm.conf" ynh_replace_string "{DESTDIR}" "${final_path}" "$PKGDIR/conf/php-fpm.conf" ynh_replace_string "{USER}" "${app}" "$PKGDIR/conf/php-fpm.conf" -sudo cp $PKGDIR/conf/php-fpm.conf "$phpfpm_conf" +cp $PKGDIR/conf/php-fpm.conf "$phpfpm_conf" # Set SSOwat rules ynh_app_setting_set "$app" skipped_uris "/" @@ -97,5 +99,5 @@ ynh_app_setting_set "$app" skipped_uris "/" #================================================= # RELOAD NGINX #================================================= -sudo systemctl restart php5-fpm -sudo systemctl reload nginx +systemctl restart php5-fpm +systemctl reload nginx diff --git a/scripts/restore b/scripts/restore index b7baa5c..839c269 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,8 +6,8 @@ if [ ! -e _common.sh ]; then # Fetch helpers file if not in current directory - sudo cp ../settings/scripts/_common.sh ./_common.sh - sudo chmod a+rx _common.sh + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh fi source _common.sh source /usr/share/yunohost/helpers @@ -35,8 +35,10 @@ db_name=$(ynh_app_setting_get $app db_name) # CHECK IF THE APP CAN BE RESTORED #================================================= -CHECK_DOMAINPATH # Check domain and path availability -CHECK_FINALPATH # Check if destination directory is not already in use +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORE STEPS @@ -44,13 +46,13 @@ CHECK_FINALPATH # Check if destination directory is not already in use # RESTORE NGINX CONFIGURATION #================================================= -sudo cp -a ./nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf +cp -a ./nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf #================================================= # RESTORE APP MAIN DIR #================================================= -sudo cp -a ./sources/. $final_path +cp -a ./sources/. $final_path #================================================= # RECREATE OF THE DEDICATED USER @@ -62,13 +64,13 @@ ynh_system_user_create $app # Recreate the dedicated user, if not existing # RESTORE USER RIGHTS #================================================= -sudo chown -R $app: $final_path +chown -R $app: $final_path #================================================= # RESTORE PHP-FPM CONFIGURATION #================================================= -sudo cp -a ./php-fpm.conf /etc/php5/fpm/pool.d/$app.conf +cp -a ./php-fpm.conf /etc/php5/fpm/pool.d/$app.conf #================================================= # GENERIC FINALIZATION @@ -76,5 +78,5 @@ sudo cp -a ./php-fpm.conf /etc/php5/fpm/pool.d/$app.conf # RELOAD NGINX AND PHP-FPM #================================================= -sudo systemctl reload php5-fpm -sudo systemctl reload nginx +systemctl reload php5-fpm +systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index 09b04e4..5f4b986 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,16 +62,16 @@ ynh_system_user_create $app # Create dedicated user if not existing ynh_secure_remove "$final_path" # Install files and set permissions -sudo mv "$TMPDIR" "$final_path" +mv "$TMPDIR" "$final_path" # Set rights on directory -sudo chown -R root: $final_path -sudo chown -R $app: $final_path/cache -sudo chmod 755 $final_path +chown -R root: $final_path +chown -R $app: $final_path/cache +chmod 755 $final_path # Enable every bridge for i in $final_path/bridges/*.php ; do - echo $(basename $i) | sed "s|Bridge.php$||g" | sudo tee -a $final_path/whitelist.txt + echo $(basename $i) | sed "s|Bridge.php$||g" | tee -a $final_path/whitelist.txt done #================================================= @@ -86,7 +86,7 @@ phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" ynh_replace_string "{POOLNAME}" "${app}" "$PKGDIR/conf/php-fpm.conf" ynh_replace_string "{DESTDIR}" "${final_path}" "$PKGDIR/conf/php-fpm.conf" ynh_replace_string "{USER}" "${app}" "$PKGDIR/conf/php-fpm.conf" -sudo cp $PKGDIR/conf/php-fpm.conf "$phpfpm_conf" +cp $PKGDIR/conf/php-fpm.conf "$phpfpm_conf" # Set SSOwat rules @@ -95,5 +95,5 @@ ynh_app_setting_set "$app" skipped_uris "/" #================================================= # RELOAD NGINX #================================================= -sudo systemctl restart php5-fpm -sudo systemctl reload nginx \ No newline at end of file +systemctl restart php5-fpm +systemctl reload nginx From 12dc5fdec441bce4d648759c1fcf289b9469a990 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 7 Apr 2020 14:13:57 +0200 Subject: [PATCH 3/3] More tweaks to make package linter happier --- scripts/_common.sh | 6 +++--- scripts/backup | 7 +------ scripts/change_url | 4 ++-- scripts/remove | 6 ++---- scripts/restore | 7 +------ 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c2656dd..0b96083 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -31,7 +31,7 @@ exec_as() { eval $@ else # use sudo twice to be root and be allowed to use another user - sudo sudo -u "$USER" "$@" + sudo -u "$USER" "$@" fi } @@ -65,8 +65,8 @@ WARNING () { # Print on error output CHECK_SIZE () { # Check if enough disk space available on backup storage file_to_analyse=$1 - backup_size=$(sudo du --summarize "$file_to_analyse" | cut -f1) - free_space=$(sudo df --output=avail "/home/yunohost.backup" | sed 1d) + backup_size=$(du --summarize "$file_to_analyse" | cut -f1) + free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d) if [ $free_space -le $backup_size ] then diff --git a/scripts/backup b/scripts/backup index 272454e..76fd1be 100644 --- a/scripts/backup +++ b/scripts/backup @@ -4,12 +4,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Fetch helpers file if not in current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/change_url b/scripts/change_url index 7499f2b..452bbdb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -79,7 +79,7 @@ fi if [ $change_domain -eq 1 ] then ynh_delete_file_checksum "$nginx_conf_path" - sudo mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + 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 "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi @@ -90,4 +90,4 @@ fi # RELOAD NGINX #================================================= -sudo systemctl reload nginx +systemctl reload nginx diff --git a/scripts/remove b/scripts/remove index 4f370d4..a996d89 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,7 +19,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) -domain=$(ynh_app_setting_get "$app" domain) #================================================= # STANDARD REMOVE @@ -34,10 +33,9 @@ ynh_secure_remove "/var/www/$app" #================================================= # REMOVE NGINX AND PHP-FPM CONFIGURATION #================================================= -# Delete app directory and configurations -ynh_secure_remove --file="/var/www/${app}" + ynh_secure_remove --file="/etc/php5/fpm/pool.d/${app}.conf" -[[ -n $domain ]] && sudo ynh_secure_remove --file="/etc/nginx/conf.d/${domain}.d/${app}.conf" +ynh_secure_remove --file="/etc/nginx/conf.d/${domain}.d/${app}.conf" # Reload services systemctl restart php5-fpm diff --git a/scripts/restore b/scripts/restore index 839c269..fb9dda4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -4,12 +4,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Fetch helpers file if not in current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #=================================================