diff --git a/scripts/install b/scripts/install index 5c6c08a..0684ade 100644 --- a/scripts/install +++ b/scripts/install @@ -5,6 +5,8 @@ set -eu # Define app app=phpsysinfo +version=3.2.5 +md5_source=08875b31a9a7a662473d8cbe866059e7 # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN @@ -13,9 +15,6 @@ is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE display_mode=$YNH_APP_ARG_DISPLAY_MODE -# Version of PhpSysInfo -version=3.2.5 - # Source YunoHost helpers . /usr/share/yunohost/helpers @@ -30,8 +29,17 @@ ynh_app_setting_set "$app" display_mode "$display_mode" sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" -# Download source, untar and copy it +# Download source, check md5, untar, copy it sudo wget https://github.com/phpsysinfo/phpsysinfo/archive/v$version.tar.gz -O /tmp/phpsysinfo.tar.gz + +# Check md5 +md5_check=($(md5sum /tmp/phpsysinfo.tar.gz)) +if [ $md5_source != $md5_check ] +then + ynh_die "the download is corrupted (md5 different)" +fi + +# untar and copy it sudo tar -xvf /tmp/phpsysinfo.tar.gz -C /tmp/ final_path=/var/www/$app sudo mkdir -p $final_path diff --git a/scripts/remove b/scripts/remove index 98e1665..f84322a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -13,7 +13,7 @@ domain=$(ynh_app_setting_get "$app" domain) sudo rm -rf /var/www/$app # Remove configuration files -sudo rm -f /etc/nginx/conf.d/$domain.d/phpsysinfo.conf +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf # Restart services sudo service nginx reload \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 493b48d..a10c227 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,8 +3,10 @@ # Exit on command errors and treat unset variables as an error set -eu -# See comments in install script +# Define app app=phpsysinfo +version=3.2.5 +md5_source=08875b31a9a7a662473d8cbe866059e7 # Source YunoHost helpers . /usr/share/yunohost/helpers @@ -16,18 +18,23 @@ is_public=$(ynh_app_setting_get "$app" is_public) language=$(ynh_app_setting_get "$app" language) display_mode=$(ynh_app_setting_get "$app" display_mode) -# Version of PhpSysInfo -version=3.2.5 - -# Download source, untar and copy it +# Download source, check md5, untar, copy it sudo wget https://github.com/phpsysinfo/phpsysinfo/archive/v$version.tar.gz -O /tmp/phpsysinfo.tar.gz + +# Check md5 +md5_check=($(md5sum /tmp/phpsysinfo.tar.gz)) +if [ $md5_source != $md5_check ] +then + ynh_die "the download is corrupted (md5 different)" +fi + +# untar and copy it sudo tar -xvf /tmp/phpsysinfo.tar.gz -C /tmp/ final_path=/var/www/$app sudo mkdir -p $final_path -sudo cp /tmp/phpsysinfo-$version/. $final_path +sudo cp -a /tmp/phpsysinfo-$version/. $final_path # Set permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) sudo chown -R root:root $final_path # Modify Nginx configuration file and copy it to Nginx conf directory