1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/rss-bridge_ynh.git synced 2024-09-03 20:25:51 +02:00

Merge pull request #20 from YunoHost-Apps/cleaning

Cleaning
This commit is contained in:
Alexandre Aubin 2020-04-07 23:01:27 +02:00 committed by GitHub
commit 99255d97da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 81 deletions

View file

@ -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",

View file

@ -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
}
@ -63,14 +63,10 @@ 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)
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
@ -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
}

View file

@ -4,12 +4,7 @@
# IMPORT GENERIC HELPERS
#=================================================
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
fi
source _common.sh
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -4,12 +4,7 @@
# IMPORT GENERIC HELPERS
#=================================================
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
fi
source _common.sh
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
@ -35,8 +30,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 +41,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 +59,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 +73,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

View file

@ -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
systemctl restart php5-fpm
systemctl reload nginx