diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..783a4ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.sw[op] diff --git a/manifest.json b/manifest.json index f4cf2d3..7d15b16 100644 --- a/manifest.json +++ b/manifest.json @@ -53,21 +53,21 @@ }, { "name": "is_public", + "type": "boolean", "ask": { "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, - "choices": ["Yes", "No"], - "default": "Yes" + "default": true }, { - "name": "my_boolean", - "type": "boolean", - "ask": { - "en": "Do you want to check this boolean ?", - "fr": "Tu veux cocher ce booléen ?" + "name": "language", + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" }, - "default": true + "choices": ["fr", "en"], + "default": "fr" } ] } diff --git a/scripts/backup b/scripts/backup index 0ea89b7..56fe444 100755 --- a/scripts/backup +++ b/scripts/backup @@ -5,10 +5,9 @@ set -e app=$YNH_APP_INSTANCE_NAME -# The parameter $1 is the backup directory location -# which will be compressed afterward -backup_dir=$1/apps/$app -sudo mkdir -p $backup_dir +# The first argument is the backup directory location for the app +# from where the script is executed and which will be compressed afterward +backup_dir=$1 # Backup sources & data sudo cp -a /var/www/$app/. $backup_dir/sources diff --git a/scripts/install b/scripts/install index 8963e29..e85d91d 100755 --- a/scripts/install +++ b/scripts/install @@ -20,10 +20,12 @@ domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +language=$YNH_APP_ARG_LANGUAGE # Save app settings sudo yunohost app setting $app admin -v "$admin" sudo yunohost app setting $app is_public -v "$is_public" +sudo yunohost app setting $app language -v "$language" # Check domain/path availability sudo yunohost app checkurl $domain$path -a $app \ @@ -65,7 +67,7 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf #sudo chmod 644 $finalphpconf # If app is public, add url to SSOWat conf as skipped_uris -if [ "$is_public" = "Yes" ]; +if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. sudo yunohost app setting $app unprotected_uris -v "/" @@ -78,4 +80,3 @@ fi # Restart services sudo service nginx reload -sudo yunohost app ssowatconf diff --git a/scripts/remove b/scripts/remove index bb1556d..54028f3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,5 +1,7 @@ #!/bin/bash -app=ynhexample + +# The last argument is the app instance name +app=${!#} # Retrieve arguments domain=$(sudo yunohost app setting $app domain) @@ -24,4 +26,3 @@ sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf # Restart services sudo service nginx reload -sudo yunohost app ssowatconf diff --git a/scripts/restore b/scripts/restore index 83c2693..c50b429 100755 --- a/scripts/restore +++ b/scripts/restore @@ -5,11 +5,13 @@ set -e app=$YNH_APP_INSTANCE_NAME -# The parameter $1 is the uncompressed restore directory location -backup_dir=$1/apps/$app +# The first argument is the backup directory location of the app +# from where the script is executed +backup_dir=$1 # Restore sources & data -sudo cp -a $backup_dir/sources/. /var/www/$app +final_path=/var/www/$app +sudo cp -a $backup_dir/sources/. $final_path # Restore permissions to app files # you may need to make some file and/or directory writeable by www-data (nginx user) diff --git a/scripts/upgrade b/scripts/upgrade index 07c7daf..37d8816 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -11,6 +11,7 @@ domain=$(sudo yunohost app setting $app domain) path=$(sudo yunohost app setting $app path) admin=$(sudo yunohost app setting $app admin) is_public=$(sudo yunohost app setting $app is_public) +language=$(sudo yunohost app setting $app language) # Remove trailing "/" for next commands path=${path%/} @@ -43,7 +44,7 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf #sudo chmod 644 $finalphpconf # If app is public, add url to SSOWat conf as skipped_uris -if [ "$is_public" = "Yes" ]; +if [[ $is_public -eq 1 ]]; then # See install script sudo yunohost app setting $app unprotected_uris -v "/" @@ -57,5 +58,3 @@ fi # Restart services sudo service nginx reload -sudo yunohost app ssowatconf -