mirror of
https://github.com/YunoHost-Apps/zerobin_ynh.git
synced 2024-09-03 18:06:01 +02:00
[fix] add secure rm
This commit is contained in:
parent
c0cebb4dec
commit
ac1e353dc2
3 changed files with 23 additions and 3 deletions
|
@ -15,3 +15,8 @@ extract_source() {
|
||||||
|| ynh_die "Unable to extract source tarball"
|
|| ynh_die "Unable to extract source tarball"
|
||||||
sudo rm "$rc_tarball"
|
sudo rm "$rc_tarball"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ynh_secure_rm () {
|
||||||
|
[[ "/var/www /opt /home/yunohost.app" =~ $1 ]] \
|
||||||
|
|| (test -n "$1" && sudo rm -Rf $1 )
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ set -u
|
||||||
|
|
||||||
# Source app helpers
|
# Source app helpers
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
source ./_common
|
||||||
|
|
||||||
# Get multi-instances specific variables
|
# Get multi-instances specific variables
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
@ -12,7 +13,7 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
sudo rm -rf /var/www/$app
|
ynh_secure_rm /var/www/$app
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
ynh_secure_rm /etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
sudo systemctl reload nginx
|
|
@ -23,7 +23,21 @@ final_path=/var/www/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
|
|
||||||
# Clean all files and directory except the data directory
|
# Clean all files and directory except the data directory
|
||||||
sudo rm -rf $final_path/{cfg,CREDITS.md,i18n,index.php,js,README.md,tmp,CHANGELOG.md,css,favicon.ico,img,INSTALL.md,lib,robots.txt,tpl}
|
ynh_secure_rm $final_path/cfg
|
||||||
|
ynh_secure_rm $final_path/CREDITS.md
|
||||||
|
ynh_secure_rm $final_path/i18n
|
||||||
|
ynh_secure_rm $final_path/index.php
|
||||||
|
ynh_secure_rm $final_path/js
|
||||||
|
ynh_secure_rm $final_path/README.md
|
||||||
|
ynh_secure_rm $final_path/tmp
|
||||||
|
ynh_secure_rm $final_path/CHANGELOG.md
|
||||||
|
ynh_secure_rm $final_path/css
|
||||||
|
ynh_secure_rm $final_path/favicon.ico
|
||||||
|
ynh_secure_rm $final_path/img
|
||||||
|
ynh_secure_rm $final_path/INSTALL.md
|
||||||
|
ynh_secure_rm $final_path/lib
|
||||||
|
ynh_secure_rm $final_path/robots.txt
|
||||||
|
ynh_secure_rm $final_path/tpl
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
extract_source $final_path
|
extract_source $final_path
|
||||||
|
|
Loading…
Add table
Reference in a new issue