mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
commit
2e554e5fb0
10 changed files with 58 additions and 132 deletions
|
@ -3,6 +3,9 @@ Minimalist Drag & drop file sharing app
|
|||
|
||||
[![Install BoZoN with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=bozon)
|
||||
|
||||
[![Integration level](https://dash.yunohost.org/integration/bozon.svg)](https://ci-apps.yunohost.org/jenkins/job/bozon%20%28Community%29/lastBuild/consoleFull)
|
||||
|
||||
## Links
|
||||
* [BoZoN website](http://bozon.pw)
|
||||
* [BoZoN git repository](https://github.com/broncowdd/BoZoN)
|
||||
* [YunoHost website](https://yunohost.org/)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/06f2a665f45e3e8f4c4bf71bf4146e8accb27776.zip
|
||||
SOURCE_SUM=d82dddd968a8cb31e21d1fb3e0518f4b88d92ec95948d652c0c378fce4dc8e65
|
||||
SOURCE_URL=https://github.com/broncowdd/BoZoN/archive/670d3fa88f2e3c0f5cee1de14e7a1d5c113b106d.zip
|
||||
SOURCE_SUM=93030a6e4ac9910e849228ddefb81bba1b78520c1e7407b78a331ccc5aa01f5c
|
||||
SOURCE_FORMAT=zip
|
||||
|
||||
#sha256sum obtain with shasum -a 256 $SOURCE_URL
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
1bc078ddfcbdfebb301b49fe87fd805b6cb89a5a
|
|
@ -14,7 +14,7 @@
|
|||
"email": "ewilly@neuf.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.6.3"
|
||||
"yunohost": ">= 2.7.2"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -30,6 +30,12 @@ myynh_check_disk_space () {
|
|||
fi
|
||||
}
|
||||
|
||||
# Clean & copy files needed to final folder
|
||||
myynh_clean_source () {
|
||||
find "$TMPDIR" -type f -name ".htaccess" | xargs rm
|
||||
[ -e "$TMPDIR/.gitignore" ] && rm -r "$TMPDIR/.gitignore"
|
||||
}
|
||||
|
||||
# Create a dedicated nginx config
|
||||
myynh_add_nginx_config () {
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf" 1
|
||||
|
@ -52,12 +58,6 @@ myynh_add_nginx_config () {
|
|||
sudo systemctl reload nginx
|
||||
}
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
myynh_remove_nginx_config () {
|
||||
ynh_secure_remove "$nginx_conf"
|
||||
sudo systemctl reload nginx
|
||||
}
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
myynh_add_fpm_config () {
|
||||
ynh_backup_if_checksum_is_different "$phpfpm_conf" 1
|
||||
|
@ -82,65 +82,3 @@ myynh_set_permissions () {
|
|||
sudo chown -R "$app": "$data_path"
|
||||
sudo chown root: "$data_path"
|
||||
}
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
myynh_remove_fpm_config () {
|
||||
ynh_secure_remove "$phpfpm_conf"
|
||||
sudo systemctl restart php5-fpm
|
||||
}
|
||||
|
||||
# Update the according fo filesize
|
||||
myynh_update_bozon_auto_dropzone () {
|
||||
case ${filesize: -1} in
|
||||
g|G)
|
||||
max_length=$((${filesize%?}*1024))
|
||||
;;
|
||||
*)
|
||||
max_length=${filesize%?}
|
||||
;;
|
||||
esac
|
||||
if [ -e "$bozon_auto_dropzone_php" ];then
|
||||
ynh_replace_string "'max_length'=>2048" "'max_length'=>$max_length" "$bozon_auto_dropzone_php"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# FUTURE YUNOHOST HELPERS - TO BE REMOVED LATER
|
||||
#=================================================
|
||||
# Restore a previous backup if the upgrade process failed
|
||||
ynh_backup_after_failed_upgrade () {
|
||||
echo "Upgrade failed." >&2
|
||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||
# Check if a existing backup can be found before remove and restore the application.
|
||||
if sudo yunohost backup list | grep -q $app_bck-upg$backup_number; then
|
||||
# Remove the application then restore it
|
||||
sudo yunohost app remove $app
|
||||
# Restore the backup if the upgrade failed
|
||||
sudo yunohost backup restore --ignore-system $app_bck-upg$backup_number --apps $app --force
|
||||
ynh_die "The app was restored to the way it was before the failed upgrade."
|
||||
fi
|
||||
}
|
||||
|
||||
# Make a backup in case of failed upgrade
|
||||
ynh_backup_before_upgrade () {
|
||||
backup_number=1
|
||||
old_backup_number=2
|
||||
app_bck=${app//_/-} # Replace all '_' by '-'
|
||||
# Check if a backup already exist with the prefix 1.
|
||||
if sudo yunohost backup list | grep -q $app_bck-upg1; then
|
||||
# Prefix become 2 to preserve the previous backup
|
||||
backup_number=2
|
||||
old_backup_number=1
|
||||
fi
|
||||
# Create another backup
|
||||
sudo yunohost backup create --ignore-system --apps $app --name $app_bck-upg$backup_number
|
||||
if [ "$?" -eq 0 ]; then
|
||||
# If the backup succedded, remove the previous backup
|
||||
if sudo yunohost backup list | grep -q $app_bck-upg$old_backup_number; then
|
||||
# Remove the previous backup only if it exists
|
||||
sudo yunohost backup delete $app_bck-upg$old_backup_number > /dev/null
|
||||
fi
|
||||
else
|
||||
ynh_die "Backup failed, the upgrade process was aborted."
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
set -eu
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the 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
|
||||
|
|
|
@ -55,28 +55,32 @@ TMPDIR=$(mktemp -d)
|
|||
ynh_setup_source "$TMPDIR"
|
||||
|
||||
# clean & copy files needed to final folder
|
||||
sudo find "$TMPDIR" -type f -name ".htaccess" | xargs sudo rm
|
||||
if [ -e "$TMPDIR/.gitignore" ]; then
|
||||
for f in $(sudo cat "$TMPDIR/.gitignore") ; do
|
||||
[ -e "$TMPDIR$f" ] && sudo rm -R "$TMPDIR$f"
|
||||
done
|
||||
sudo rm "$TMPDIR/.gitignore"
|
||||
fi
|
||||
sudo mv "$TMPDIR" "$final_path"
|
||||
myynh_clean_source
|
||||
mv "$TMPDIR" "$final_path"
|
||||
|
||||
# configure config file
|
||||
# language
|
||||
ynh_replace_string "default_language='en'" "default_language='$language'" "$bozon_conf"
|
||||
ynh_store_file_checksum "$bozon_conf"
|
||||
|
||||
# update auto_dropzone.php
|
||||
myynh_update_bozon_auto_dropzone
|
||||
# max upload file size
|
||||
case ${filesize: -1} in
|
||||
g|G)
|
||||
max_length=$((${filesize%?}*1024))
|
||||
;;
|
||||
*)
|
||||
max_length=${filesize%?}
|
||||
;;
|
||||
esac
|
||||
ynh_replace_string "max_length=2048" "max_length=$max_length" "$bozon_conf"
|
||||
|
||||
ynh_store_file_checksum "$bozon_conf"
|
||||
|
||||
# create private & data folders
|
||||
myynh_create_dir "$final_path/private"
|
||||
myynh_create_dir "$data_path/uploads"
|
||||
myynh_create_dir "$data_path/thumbs"
|
||||
sudo ln -s "$data_path/uploads" "$final_path/uploads"
|
||||
sudo ln -s "$data_path/thumbs" "$final_path/thumbs"
|
||||
ln -s "$data_path/uploads" "$final_path/uploads"
|
||||
ln -s "$data_path/thumbs" "$final_path/thumbs"
|
||||
|
||||
# set permissions
|
||||
myynh_set_permissions
|
||||
|
@ -89,7 +93,7 @@ myynh_add_fpm_config
|
|||
|
||||
# set temporary public access for curl call
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
sudo yunohost app ssowatconf
|
||||
yunohost app ssowatconf
|
||||
|
||||
# fill the superadmin creation form (helper ynh_local_curl doesn't work due to --data vs --data-urlencode ?)
|
||||
curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 https://localhost"$path_url"/ > /dev/null 2>&1
|
||||
|
@ -109,5 +113,4 @@ then
|
|||
pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g')
|
||||
regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$"
|
||||
ynh_app_setting_set "$app" protected_regex "$regexList"
|
||||
sudo yunohost app ssowatconf
|
||||
fi
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
set -u
|
||||
if [ ! -e _common.sh ]; then
|
||||
# Get the _common.sh file if it's not in the 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
|
||||
|
@ -25,10 +25,10 @@ nginx_conf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
phpfpm_conf="/etc/php5/fpm/pool.d/$app.conf"
|
||||
|
||||
# create a full backup (core+datas) if app installed
|
||||
if [ $(sudo yunohost app list -i -f "$app" | wc -l) -gt 1 ]; then
|
||||
if [ $(yunohost app list -i -f "$app" | wc -l) -gt 1 ]; then
|
||||
ynh_app_setting_set "$app" backup_core_only 0
|
||||
app_bck=${app//_/-}
|
||||
sudo yunohost backup create --ignore-system --apps "$app" --name "${app_bck}_$(date '+%Y%m%d-%H%M%S')"
|
||||
yunohost backup create --ignore-system --apps "$app" --name "${app_bck}_$(date '+%Y%m%d-%H%M%S')"
|
||||
echo "BoZon fully backuped." >&2
|
||||
fi
|
||||
|
||||
|
@ -39,10 +39,10 @@ ynh_remove_app_dependencies
|
|||
ynh_secure_remove "$final_path"
|
||||
|
||||
# remove the dedicated nginx config
|
||||
myynh_remove_nginx_config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
# remove the dedicated php-fpm config
|
||||
myynh_remove_fpm_config
|
||||
ynh_remove_fpm_config
|
||||
|
||||
# remove a directory securely
|
||||
ynh_secure_remove "$data_path"
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
set -eu
|
||||
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
|
||||
|
@ -61,5 +61,5 @@ fi
|
|||
myynh_set_permissions
|
||||
|
||||
# restart services
|
||||
sudo systemctl reload php5-fpm
|
||||
sudo systemctl reload nginx
|
||||
systemctl reload php5-fpm
|
||||
systemctl reload nginx
|
||||
|
|
|
@ -33,26 +33,6 @@ if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then
|
|||
}
|
||||
fi
|
||||
|
||||
# retrieve & save real/right value if argument was not saved as a app setting in a previous realease
|
||||
if [ -z "$filesize" ]; then # in old script filesize was not saved as a setting
|
||||
filesize=$(cat "$nginx_conf" | grep -Po "client_max_body_size \K.*?(?=;)")
|
||||
ynh_app_setting_set "$app" filesize "$filesize"
|
||||
fi
|
||||
if [ -z "$language" ]; then # in old script language was not saved as a setting
|
||||
language=$(cat "$bozon_conf" | grep -Po "default_language='\K.*?(?=')")
|
||||
ynh_app_setting_set "$app" language "$language"
|
||||
fi
|
||||
if [ "$is_public" = "Yes" ]; then # in old script is_public was not a boolean
|
||||
ynh_app_setting_set "$app" is_public 1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set "$app" is_public 0
|
||||
is_public=0
|
||||
fi
|
||||
if [ -z "$backup_core_only" ]; then # in old script backup_core_only was not a setting
|
||||
ynh_app_setting_set "$app" backup_core_only 1
|
||||
fi
|
||||
|
||||
# add required packages
|
||||
ynh_install_app_dependencies "$PKG_DEPENDENCIES"
|
||||
|
||||
|
@ -64,19 +44,23 @@ TMPDIR=$(mktemp -d)
|
|||
ynh_setup_source "$TMPDIR"
|
||||
|
||||
# clean & copy files needed to final folder
|
||||
sudo find "$TMPDIR" -type f -name ".htaccess" | xargs sudo rm
|
||||
if [ -e "$TMPDIR/.gitignore" ]; then
|
||||
for f in $(sudo cat "$TMPDIR/.gitignore") ; do
|
||||
[ -e "$TMPDIR$f" ] && sudo rm -R "$TMPDIR$f"
|
||||
done
|
||||
sudo rm "$TMPDIR/.gitignore"
|
||||
fi
|
||||
[ -e "$TMPDIR/config.php" ] && sudo rm "$TMPDIR/config.php"
|
||||
sudo cp -a "$TMPDIR/." "$final_path"
|
||||
sudo rm -R "$TMPDIR"
|
||||
myynh_clean_source
|
||||
[ -e "$TMPDIR/config.php" ] && rm "$TMPDIR/config.php"
|
||||
cp -a "$TMPDIR/." "$final_path"
|
||||
rm -R "$TMPDIR"
|
||||
|
||||
# update auto_dropzone.php
|
||||
myynh_update_bozon_auto_dropzone
|
||||
# Only add 'max_length' line in config.php if does not exist yet
|
||||
if [ $(grep "max_length=" "$bozon_conf" | wc -l) -eq 0 ]; then
|
||||
case ${filesize: -1} in
|
||||
g|G)
|
||||
max_length=$((${filesize%?}*1024))
|
||||
;;
|
||||
*)
|
||||
max_length=${filesize%?}
|
||||
;;
|
||||
esac
|
||||
sed -i "54i\$max_length=$max_length;" "$bozon_conf"
|
||||
fi
|
||||
|
||||
# set permissions
|
||||
myynh_set_permissions
|
||||
|
@ -99,7 +83,6 @@ then
|
|||
else
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
fi
|
||||
sudo yunohost app ssowatconf
|
||||
|
||||
# Purge php sessions stored in /var/lib/php5/sessions
|
||||
[ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean
|
||||
|
|
Loading…
Reference in a new issue