diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..610dfcb --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,59 @@ +#!/bin/bash + +# Exit on command errors and treat unset variables as an error +set -eu + +source .fonctions + +# Source YunoHost helpers +source /usr/share/yunohost/helpers + +# Récupère les infos de l'application. +app=$YNH_APP_INSTANCE_NAME + +# Retrieve arguments +domain=$(ynh_app_setting_get "$app" domain) +path=$(ynh_app_setting_get "$app" path) +is_public=$(ynh_app_setting_get "$app" is_public) + +# Install the app + +# Copy files to the right place +final_path=/var/www/$app +extract_source + + # Files owned by root, www-data can just read +sudo chown www-data:www-data $final_path -R +sudo chmod 755 $final_path -R + + # Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@__PORT__@$port@g" ../conf/nginx.conf +sed -i "s@__PORT__@$port@g" ../conf/os.js.service +sed -i "s@__FINALPATH__@$final_path@g" ../conf/os.js.service +nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf +sudo cp ../conf/nginx.conf $nginxconf +sudo chown root: $nginxconf +sudo chmod 600 $nginxconf +pushd $final_path +sudo npm install --production +sudo node osjs build +popd +sudo yunohost firewall allow Both 85 +pre_inst_os.js +sudo service $app start +sudo systemctl start "$app".service + + + +ynh_app_setting_set "$app" is_public "$is_public" +if [ "$is_public" = 0 ]; +then + ynh_app_setting_set "$app" unprotected_uris "/" +fi + +sudo service nginx reload +sudo yunohost service add "$app" --log /var/log/"$app"/"$app".log +sudo yunohost app ssowatconf + +# Start OS.js +sudo systemctl restart "$app".service